Hello all. I will probably be frequenting these discussions in the future. I am a graduate student in physics learning C++ on the fly.
This is probably an easy quesiton, but my background in this subject is very limited. I have tried a few permutations of what I think SHOULD be right, but the compiler is giving me very cryptic errors (like 'template argument is invalid'). I cannot find any examples of what I want to do on line, and I am tied to the Boost/Rational class, as that is what my collaborators are using.
I want to construct a matrix using the vector class. This is not a problem, but all of the entries in that matrix should be rational numbers. For example, I can declare a 2d vector using
vector <vector< int> > vec;
Is the corresponding statement for the rational class
vector <vector< rational<int> > > vec;
or
vector< vector< rational> >
(or none of these)?
Secondly, I wish to write a function that returns a rational number, or a matrix of rational numbers. When I declare that function at the onset of my program, how should I do so? These functions take in and spit out vectors and matrices. I have tried something like
rational<int> Length( const vector<rational>& vec );
but I get an error that says "expected constructor, destructor, or type conversion before < token".
Any help in these matters would be appreciated---feel free to direct me to a website or some other resource.
PS---If anyone needs help in physics or math, I am a moderator at livephysics.com and frequent the boards at ilovephysics.com.