Ask Your Question
0

strings and other objects in matrices

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

SLOtoSF gravatar image

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

Hi,

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?http://www.sagemath.org/doc/reference/sage/matrix/constructor.html

Thanks!

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2012-10-08 17:33:33 +0100

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
0

answered 2012-10-06 18:05:37 +0100

SLOtoSF gravatar image

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

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

Stats

Asked: 2012-10-04 17:27:09 +0100

Seen: 1,122 times

Last updated: Oct 08 '12