From 05491528318e3cd256738d174fed13bc91132787 Mon Sep 17 00:00:00 2001 From: "jussi.koskela" Date: Tue, 24 Feb 2015 13:35:10 +0000 Subject: [PATCH] (fixes #5681) Vector*matrix not implemented git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@30972 ac1ea38d-2e2b-0410-8846-a27921b304fc --- .../src/fi/semantum/sysdyn/solver/Array.java | 14 ++++++++++++++ .../fi/semantum/sysdyn/solver/Multiplication.java | 2 ++ 2 files changed, 16 insertions(+) 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 { -- 2.47.1