dimanche 5 avril 2015

How to design :: Linear Algebra Routines for a matrix

In C++ , for education purposes , I am building a linear algebra package. My question is how can a design a good interface for the user.


I have a matrix class which can be created as



matrix<int> A (3,3)


This class deals with the data that is stored in the matrix, how to traverse through them , get a particular element, printing the matrix etc...


I have another class Linear Algebra , which does the mathematical computations on the matrix. So it will work like this



LA<int> B ;

// I have a method in LA , which gives the determinant.

matrix<int> C = B.determinant(A);

// Just doesn't look good to me, I want to be able to do this

matrix<int> C = determinant(A); // This seems more natural

// Is there any way to eliminate the need to create an LA object ?


One way would be to define determinant within A and call A.determinant(). But this does not give me modularity.


So how can I do this ?


Additionally



  • Do you know some way to cut down on the user having to type matrix< int>. Can I use a typedef ?


  • if you were using this class , would you prefer determinant() or some short form of determinant. Using the short form would mean less typing, but that would make the code less understandable too. How do I make this trade off.




  • I plan on looking at how other Linear Algebra classes like bltiz do this. But I am afraid it would be too high level for me to understand the technique they use. Would you make any suggestions (books , website etc.) where I can learn about design patterns , and about how to write huge code without it breaking down.




  • Thank you




Aucun commentaire:

Enregistrer un commentaire