I am getting started with GiNaC. I tried using evalm() and naively assumed that evaluating an expression involving matrices would return a matrix. It looks like a matrix but for instance the line below with A(0,0) causes an error. If I change "ex A" to "matrix A" it also causes an error. Could someone explain this please? Also, have I missed something? or do I have to use mul add sub? matrix S1(2,2); S1 = q, 0, 1, -1/q; matrix S2(2,2); S2 = -1/q, 1, 0, q; ex A = evalm(S1*S2*S1-S2*S1*S2); cout << endl << A << endl; cout << endl << A(0,0) << endl; cout << endl << A.is_zero_matrix() << endl; Bruce Westbury
Hi, On Fri, Nov 28, 2008 at 9:37 AM, Westbury, Bruce <Bruce.Westbury@warwick.ac.uk> wrote:
looks like a matrix but for instance the line below with A(0,0) causes an error. If I change "ex A" to "matrix A" it also causes an error.
Leave "ex A" as the type definition but try ex_to<matrix>(A)(0,0) for a correct conversion of types. You will get used to it after a while. Best wishes, Vladimir
participants (2)
-
Vladimir V. Kisil
-
Westbury, Bruce