Hi,
I want to use ginac to evaluate some complex expressions that evolve some vector algebra. However, have some trouble working with the matrix class. I have 2 questions:
1: Am I correct, that if i want to compute the Subtraction of two vectors I should use the indexed variant?
2: How do I access elements of an expression?
I have included a small file that illustrates my problem?
Kind regards,
Spooky
#include <ginac/ginac.h> #include <iostream> int main(int argc, char **argv) { using namespace GiNaC; idx d(symbol("d"), 3); matrix m0 = matrix({{0, 0, 0}}), m1 = matrix({{1, 0, 0}}); indexed v0 = indexed(m0,d), v1 = indexed(m1,d); // This seems wrong: std::cout << (m1-m0).eval() << std::endl; // -> [[1,0,0]]-[[0,0,0]] // This seems right: std::cout << (v1-v0).simplify_indexed()<< std::endl; // -> [[1,0,0]].d // I can normally access matrix element using std::cout << m1(0,0) << std::endl; // -> 0 // But how can I access matrix elements of an expression? // does not compile: // std::cout << "(v1-v0)(0,0): " << (v1-v0)(0,0) << std::end; return 0; }