First time here? Check out the FAQ!

Ask Your Question
0

strings and other objects in matrices

asked 12 years ago

SLOtoSF gravatar image

updated 12 years ago

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!

Preview: (hide)

2 Answers

Sort by » oldest newest most voted
0

answered 12 years ago

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).

Preview: (hide)
link
0

answered 12 years ago

SLOtoSF gravatar image

updated 12 years ago

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.

Preview: (hide)
link

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: 12 years ago

Seen: 1,184 times

Last updated: Oct 08 '12