vkostyukov / la4j

Linear Algebra for Java
http://la4j.org
Apache License 2.0
373 stars 109 forks source link

Define the 'type system' rules for vectors #237

Closed vkostyukov closed 9 years ago

vkostyukov commented 9 years ago

Since, we want to move out of the factories, we have to provide the explicit set of rules for common operations. This ticket is only about vectors. There idea is to have the table like this:

Operand A Operand B Operation Result Type
DenseVector DenseVector any operation DenseVector like A
DenseVector double any operation DenseVector like A
DenseVector SparseVector A + B or A - B DenseVector like A
SparseVector DenseVector A * B SparseVector like A
SparseVector SparseVector A * B SparseVector like A
SparseVector SparseVector A + B or A - B SparseVector like A
SparseVector double A * B or A / B SparseVector like A
SparseVector double A + B or A - B the default DenseVector

Here like means that the resulting vector should has the same type as A or B. Simple speaking, we should do a.blank() or b.blank() for those cases.