From: jussi.koskela Date: Tue, 24 Feb 2015 13:35:10 +0000 (+0000) Subject: (fixes #5681) Vector*matrix not implemented X-Git-Tag: v1.29.0~117 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=05491528318e3cd256738d174fed13bc91132787;p=simantics%2Fsysdyn.git (fixes #5681) Vector*matrix not implemented git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@30972 ac1ea38d-2e2b-0410-8846-a27921b304fc --- diff --git a/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Array.java b/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Array.java index cb16d4b9..3f9693c0 100644 --- a/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Array.java +++ b/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Array.java @@ -327,6 +327,20 @@ public class Array implements IExpression { return result; } + /* + * Other array is matrix (this is vector) + */ + public Array vectorMulMatrix(Array other) { + Array result = new Array(); + Array transposed = other.transposed(); + for(Object o : transposed.elements) { + // Objects are columns + Array a = (Array)o; + result.addElement(this.inner(a)); + } + return result; + } + /* * Other array is vector (this is matrix) */ diff --git a/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Multiplication.java b/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Multiplication.java index 97791824..ad6f3f07 100644 --- a/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Multiplication.java +++ b/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Multiplication.java @@ -40,6 +40,8 @@ public class Multiplication implements IExpression { Array ra = (Array)right; if(la.isVector && ra.isVector) { return la.inner(ra); + } else if(la.isVector) { + return la.vectorMulMatrix(ra); } else if(ra.isVector) { return la.matrixMulVector(ra); } else {