Matrix<Rational> in C++

Questions and problems about using polymake go here.
ebbe1990
Posts: 2
Joined: 20 Jun 2013, 18:14

Matrix<Rational> in C++

Postby ebbe1990 » 20 Jun 2013, 18:20

Hello

can anybody tell my why for a Matrix<Rational> matrix(n,m); the following expression is wrong?

matrix.row(0).col(0)

or is there an easier way to accesses the elements of a matrix?

thank you :)

User avatar
gawrilow
Main Author
Posts: 423
Joined: 25 Dec 2010, 17:40

Re: Matrix<Rational> in C++

Postby gawrilow » 20 Jun 2013, 20:07

row(i) gives you a selected row represented by an object with Vector-like interface, that is, access to a single element there is provided via operator[]. The same for columns: col(j) returns something behaving like a Vector. The following four expressions are functionally equivalent:

m[j] m.row(i)[j] m.col(j) m(i,j)

The last one is the most efficient, because it does not create any temporary intermediate objects.

ebbe1990
Posts: 2
Joined: 20 Jun 2013, 18:14

Re: Matrix<Rational> in C++

Postby ebbe1990 » 20 Jun 2013, 20:22

That helps alot. Thank you


Return to “Helpdesk”