posted 20 years ago
Yea, as your previous respondents have already said, it totally depends on the problem domain you're trying to cover. If you want to do simple matrix operations, then just use 2D arrays (or n-D arrays for tensors...ooh).
...and so on. I must say, though, this approach sort of rubs me the wrong way because it seems more or less like a non-OO approach. Better to make a class called MatrixCalculator instead that allows running operations and can do validity checks and such, allowing you to get the result any time you wish:
Here's how you might use your newfound MatrixCalculator:
The above will print out:
[ 20 15 ]
[ 15 20 ]
sev