ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Fri, 03 Jul 2020 14:32:53 +0200Right choice for a dictionary of matrices with non constant coefficients.https://ask.sagemath.org/question/52312/right-choice-for-a-dictionary-of-matrices-with-non-constant-coefficients/Hi,
K is any field.
I need to store matrices in a dictionary.
Some of them have constant coefficients in K (let M1 be such a matrix),
and some have non constant coefficients, say these coeffcients are functions from t to K (let M2 be such a matrix).
I need to get M2 from the dictionary, and then be able to manipulate it as if it was a function of t.
(T) In particular, I need to be able to manipulate the matrices obtained from M2 by setting t to be equal to some specific values.
Since my functions are polynomials for now, I have tried doing something like this:
```
var('t')
sample = {}
sample[('M1')] = matrix(QQ, 2, [7, 5, 2, 4])
sample[('M2')] = matrix(QQ['t'], 2, [t^2, 2, 3, 1 - t])
```
But then I don't know how to proceed to perform the task (T).
And I have the feeling that there are much better options.
What should I do?
Thanks.BostonFri, 03 Jul 2020 14:32:53 +0200https://ask.sagemath.org/question/52312/How do I define (and work with) a set of matrices?https://ask.sagemath.org/question/30102/how-do-i-define-and-work-with-a-set-of-matrices/Suppose $a,b,c$
are matrices, and I want to define the set $S=$ { $a,b,c$ }.
What is the proper syntax for this? More generally, how do I define a set by specifying its elements (regardless of their nature). I am only finding documentation for sets of numbers.
I'm also interested in doing functions that take sets like $S$
as input.
For instance, if I had a matrix $d$,
I want to be able to define a set like $S'=$ { $da,db,dc$ },
but I want to be able to do this via the Sage equivalent of $f(S):=$ {$ ms\mid s\in S $}.j0equ1nnMon, 19 Oct 2015 02:25:38 +0200https://ask.sagemath.org/question/30102/