Ask Your Question

strings and other objects in matrices

asked 2012-10-04 10:27:09 -0500

SLOtoSF gravatar image

updated 2012-10-04 16:55:08 -0500


Rather than me starting by creating a thin wrapper around a list of lists and calling it a SpecialMatrix, does anyone have any ideas creating SpecialMatrix class deriving from some base matrix class such that I can load up the matrix with objects in the entries?

Ultimately I would not like to recreate matrix addition and matrix multiplication and instead leverage what's currently in existence.

In the documentation, it specifically says it can pull callable objects. Any tips?


edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted

answered 2012-10-08 10:33:33 -0500

Jason Grout gravatar image

The entries to a matrix are assumed to belong to a Sage ring structure. You can see various examples of overriding in the matrix/ directory (for example, the matrix_symbolic_dense.pyx).

edit flag offensive delete link more

answered 2012-10-06 11:05:37 -0500

SLOtoSF gravatar image

updated 2012-10-06 11:06:51 -0500

import numpy as np a = np.array([['apple', 'frog'],[[3,2], 3]], dtype=object); a

array([[apple, frog], [[3, 2], 3]], dtype=object)

Sage Matrices have entries as ring elements.... so this can be done in numpy instead.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2012-10-04 10:27:09 -0500

Seen: 425 times

Last updated: Oct 08 '12