Static Typing and Writing a Simple Matrix Library
Posted
by duckworthd
on Stack Overflow
See other posts from Stack Overflow
or by duckworthd
Published on 2010-06-05T07:54:04Z
Indexed on
2010/06/05
8:02 UTC
Read the original article
Hit count: 378
Aye it's been done a million times before, but damnit I want to do it again. I'm writing a simple Matrix Library for C++ with the intention of doing it right. I've come across something that's fairly obvious in mathematics, but not so obvious to a strongly typed system -- the fact that a 1x1 matrix is just a number. To avoid this, I started walking down the hairy path of matrices as a composition of vectors, but also stumbled upon the fact that two vectors multiplied together could either be a number or a dyad, depending on the orientation of the two.
My question is, what is the right way to deal with this situation in a strongly typed language like C++ or Java?
© Stack Overflow or respective owner