Ask Your Question

strings and other objects in matrices

asked 2012-10-04 17:27:09 +0200

SLOtoSF gravatar image

updated 2012-10-04 23:55:08 +0200


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 17:33:33 +0200

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 18:05:37 +0200

SLOtoSF gravatar image

updated 2012-10-06 18:06:51 +0200

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 17:27:09 +0200

Seen: 1,049 times

Last updated: Oct 08 '12