diff --git a/build.gradle.kts b/build.gradle.kts index 7b8fa953..934e03ee 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -34,11 +34,27 @@ sourceSets { create("kvector") { } + + create("kbox2d") { + + } +} + +sourceSets["kbox2d"].compileClasspath += sourceSets["kvector"].output +sourceSets["kbox2d"].runtimeClasspath += sourceSets["kvector"].output + +sourceSets.main { + compileClasspath += sourceSets["kvector"].output + runtimeClasspath += sourceSets["kvector"].output + compileClasspath += sourceSets["kbox2d"].output + runtimeClasspath += sourceSets["kbox2d"].output } sourceSets.test { compileClasspath += sourceSets["kvector"].output runtimeClasspath += sourceSets["kvector"].output + compileClasspath += sourceSets["kbox2d"].output + runtimeClasspath += sourceSets["kbox2d"].output } dependencies { diff --git a/src/main/kotlin/ru/dbotthepony/kbox2d/api/B2TimeStep.kt b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/api/B2TimeStep.kt similarity index 98% rename from src/main/kotlin/ru/dbotthepony/kbox2d/api/B2TimeStep.kt rename to src/kbox2d/kotlin/ru/dbotthepony/kbox2d/api/B2TimeStep.kt index fdb51783..5013809e 100644 --- a/src/main/kotlin/ru/dbotthepony/kbox2d/api/B2TimeStep.kt +++ b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/api/B2TimeStep.kt @@ -1,6 +1,6 @@ package ru.dbotthepony.kbox2d.api -import ru.dbotthepony.kstarbound.math.Vector2d +import ru.dbotthepony.kvector.vector.ndouble.Vector2d /** * Profiling data. Times are in milliseconds. diff --git a/src/main/kotlin/ru/dbotthepony/kbox2d/api/Body.kt b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/api/Body.kt similarity index 92% rename from src/main/kotlin/ru/dbotthepony/kbox2d/api/Body.kt rename to src/kbox2d/kotlin/ru/dbotthepony/kbox2d/api/Body.kt index 466eb6a8..a0446169 100644 --- a/src/main/kotlin/ru/dbotthepony/kbox2d/api/Body.kt +++ b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/api/Body.kt @@ -1,30 +1,6 @@ package ru.dbotthepony.kbox2d.api -/* -MIT License - -Original author Erin Catto (c) 2019 - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -*/ - -import ru.dbotthepony.kstarbound.math.Vector2d +import ru.dbotthepony.kvector.vector.ndouble.Vector2d /// The body type. /// static: zero mass, zero velocity, may be manually moved diff --git a/src/main/kotlin/ru/dbotthepony/kbox2d/api/BroadPhase.kt b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/api/BroadPhase.kt similarity index 92% rename from src/main/kotlin/ru/dbotthepony/kbox2d/api/BroadPhase.kt rename to src/kbox2d/kotlin/ru/dbotthepony/kbox2d/api/BroadPhase.kt index a32de111..479dc765 100644 --- a/src/main/kotlin/ru/dbotthepony/kbox2d/api/BroadPhase.kt +++ b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/api/BroadPhase.kt @@ -1,8 +1,5 @@ package ru.dbotthepony.kbox2d.api -import ru.dbotthepony.kstarbound.math.AABB -import ru.dbotthepony.kstarbound.math.Vector2d - typealias b2Pair = Pair const val e_nullProxy = -1 diff --git a/src/main/kotlin/ru/dbotthepony/kbox2d/api/Collision.kt b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/api/Collision.kt similarity index 98% rename from src/main/kotlin/ru/dbotthepony/kbox2d/api/Collision.kt rename to src/kbox2d/kotlin/ru/dbotthepony/kbox2d/api/Collision.kt index 43d11587..8b0b5622 100644 --- a/src/main/kotlin/ru/dbotthepony/kbox2d/api/Collision.kt +++ b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/api/Collision.kt @@ -1,6 +1,6 @@ package ru.dbotthepony.kbox2d.api -import ru.dbotthepony.kstarbound.math.Vector2d +import ru.dbotthepony.kvector.vector.ndouble.Vector2d /// The features that intersect to form the contact point /// This must be 4 bytes or less. ? diff --git a/src/main/kotlin/ru/dbotthepony/kbox2d/api/Constants.kt b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/api/Constants.kt similarity index 100% rename from src/main/kotlin/ru/dbotthepony/kbox2d/api/Constants.kt rename to src/kbox2d/kotlin/ru/dbotthepony/kbox2d/api/Constants.kt diff --git a/src/main/kotlin/ru/dbotthepony/kbox2d/api/Contact.kt b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/api/Contact.kt similarity index 100% rename from src/main/kotlin/ru/dbotthepony/kbox2d/api/Contact.kt rename to src/kbox2d/kotlin/ru/dbotthepony/kbox2d/api/Contact.kt diff --git a/src/main/kotlin/ru/dbotthepony/kbox2d/api/ContactManager.kt b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/api/ContactManager.kt similarity index 100% rename from src/main/kotlin/ru/dbotthepony/kbox2d/api/ContactManager.kt rename to src/kbox2d/kotlin/ru/dbotthepony/kbox2d/api/ContactManager.kt diff --git a/src/main/kotlin/ru/dbotthepony/kbox2d/api/Distance.kt b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/api/Distance.kt similarity index 96% rename from src/main/kotlin/ru/dbotthepony/kbox2d/api/Distance.kt rename to src/kbox2d/kotlin/ru/dbotthepony/kbox2d/api/Distance.kt index 5872d657..8d10b461 100644 --- a/src/main/kotlin/ru/dbotthepony/kbox2d/api/Distance.kt +++ b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/api/Distance.kt @@ -1,6 +1,6 @@ package ru.dbotthepony.kbox2d.api -import ru.dbotthepony.kstarbound.math.Vector2d +import ru.dbotthepony.kvector.vector.ndouble.Vector2d /** * A distance proxy is used by the GJK algorithm. diff --git a/src/main/kotlin/ru/dbotthepony/kbox2d/api/DynamicTree.kt b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/api/DynamicTree.kt similarity index 76% rename from src/main/kotlin/ru/dbotthepony/kbox2d/api/DynamicTree.kt rename to src/kbox2d/kotlin/ru/dbotthepony/kbox2d/api/DynamicTree.kt index 6339eddc..e8b4d620 100644 --- a/src/main/kotlin/ru/dbotthepony/kbox2d/api/DynamicTree.kt +++ b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/api/DynamicTree.kt @@ -1,9 +1,8 @@ package ru.dbotthepony.kbox2d.api -import it.unimi.dsi.fastutil.ints.IntArraySet import ru.dbotthepony.kbox2d.collision.DynamicTree import ru.dbotthepony.kbox2d.collision.b2_nullNode -import ru.dbotthepony.kstarbound.math.AABB +import ru.dbotthepony.kvector.util2d.AABB private const val DEBUG_CYCLIC_REFERENCES = true @@ -30,23 +29,6 @@ data class TreeNode( var parent by this::_union var next by this::_union - - internal fun validate() { - if (!DEBUG_CYCLIC_REFERENCES) - return - - val seen = IntArraySet() - var parent = parent - - while (parent != b2_nullNode) { - if (!seen.add(parent)) { - throw IllegalStateException("Cycle detected: $seen") - } - - seen.add(parent) - parent = tree.nodes[parent].parent - } - } } interface IDynamicTree : IProxieable, IMovable { diff --git a/src/main/kotlin/ru/dbotthepony/kbox2d/api/Fixture.kt b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/api/Fixture.kt similarity index 98% rename from src/main/kotlin/ru/dbotthepony/kbox2d/api/Fixture.kt rename to src/kbox2d/kotlin/ru/dbotthepony/kbox2d/api/Fixture.kt index 38b3c1b8..48fd87f9 100644 --- a/src/main/kotlin/ru/dbotthepony/kbox2d/api/Fixture.kt +++ b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/api/Fixture.kt @@ -1,7 +1,7 @@ package ru.dbotthepony.kbox2d.api -import ru.dbotthepony.kstarbound.math.AABB -import ru.dbotthepony.kstarbound.math.Vector2d +import ru.dbotthepony.kvector.util2d.AABB +import ru.dbotthepony.kvector.vector.ndouble.Vector2d sealed interface IFilter { /** diff --git a/src/main/kotlin/ru/dbotthepony/kbox2d/api/IDebugDraw.kt b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/api/IDebugDraw.kt similarity index 91% rename from src/main/kotlin/ru/dbotthepony/kbox2d/api/IDebugDraw.kt rename to src/kbox2d/kotlin/ru/dbotthepony/kbox2d/api/IDebugDraw.kt index 45655724..c7ff46c7 100644 --- a/src/main/kotlin/ru/dbotthepony/kbox2d/api/IDebugDraw.kt +++ b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/api/IDebugDraw.kt @@ -1,7 +1,7 @@ package ru.dbotthepony.kbox2d.api -import ru.dbotthepony.kstarbound.math.Vector2d -import ru.dbotthepony.kstarbound.util.Color +import ru.dbotthepony.kvector.vector.Color +import ru.dbotthepony.kvector.vector.ndouble.Vector2d /** * Implement and register this class with a b2World to provide debug drawing of physics diff --git a/src/main/kotlin/ru/dbotthepony/kbox2d/api/IMovable.kt b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/api/IMovable.kt similarity index 83% rename from src/main/kotlin/ru/dbotthepony/kbox2d/api/IMovable.kt rename to src/kbox2d/kotlin/ru/dbotthepony/kbox2d/api/IMovable.kt index 19dd3b0a..db1c9a1b 100644 --- a/src/main/kotlin/ru/dbotthepony/kbox2d/api/IMovable.kt +++ b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/api/IMovable.kt @@ -1,6 +1,6 @@ package ru.dbotthepony.kbox2d.api -import ru.dbotthepony.kstarbound.math.Vector2d +import ru.dbotthepony.kvector.vector.ndouble.Vector2d interface IMovable { /** diff --git a/src/main/kotlin/ru/dbotthepony/kbox2d/api/IProxieable.kt b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/api/IProxieable.kt similarity index 96% rename from src/main/kotlin/ru/dbotthepony/kbox2d/api/IProxieable.kt rename to src/kbox2d/kotlin/ru/dbotthepony/kbox2d/api/IProxieable.kt index 2d0280c1..8f24c9aa 100644 --- a/src/main/kotlin/ru/dbotthepony/kbox2d/api/IProxieable.kt +++ b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/api/IProxieable.kt @@ -1,7 +1,7 @@ package ru.dbotthepony.kbox2d.api -import ru.dbotthepony.kstarbound.math.AABB -import ru.dbotthepony.kstarbound.math.Vector2d +import ru.dbotthepony.kvector.util2d.AABB +import ru.dbotthepony.kvector.vector.ndouble.Vector2d fun interface ProxyQueryCallback { fun invoke(nodeId: Int, userData: Any?): Boolean diff --git a/src/main/kotlin/ru/dbotthepony/kbox2d/api/Joint.kt b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/api/Joint.kt similarity index 98% rename from src/main/kotlin/ru/dbotthepony/kbox2d/api/Joint.kt rename to src/kbox2d/kotlin/ru/dbotthepony/kbox2d/api/Joint.kt index 19238fe4..ea12faad 100644 --- a/src/main/kotlin/ru/dbotthepony/kbox2d/api/Joint.kt +++ b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/api/Joint.kt @@ -1,8 +1,7 @@ package ru.dbotthepony.kbox2d.api -import org.apache.logging.log4j.LogManager import ru.dbotthepony.kbox2d.dynamics.joint.AbstractJoint -import ru.dbotthepony.kstarbound.math.Vector2d +import ru.dbotthepony.kvector.vector.ndouble.Vector2d import kotlin.math.PI data class StiffnessResult(val stiffness: Double, val damping: Double) @@ -758,7 +757,7 @@ interface IJoint : IMovable { /** * Dump this joint to the log file. */ - fun dump() { LOGGER.warn("Dump is not supported for this join type: $this") } + fun dump() { } /** * Debug draw this joint @@ -766,8 +765,4 @@ interface IJoint : IMovable { fun draw(draw: IDebugDraw) { } var userData: Any? - - companion object { - private val LOGGER = LogManager.getLogger() - } } diff --git a/src/main/kotlin/ru/dbotthepony/kbox2d/api/Math.kt b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/api/Math.kt similarity index 79% rename from src/main/kotlin/ru/dbotthepony/kbox2d/api/Math.kt rename to src/kbox2d/kotlin/ru/dbotthepony/kbox2d/api/Math.kt index fd344639..c0221bc2 100644 --- a/src/main/kotlin/ru/dbotthepony/kbox2d/api/Math.kt +++ b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/api/Math.kt @@ -1,6 +1,12 @@ package ru.dbotthepony.kbox2d.api -import ru.dbotthepony.kstarbound.math.* +import ru.dbotthepony.kvector.api.concrete.IMatrix2d +import ru.dbotthepony.kvector.api.concrete.IMatrix3d +import ru.dbotthepony.kvector.matrix.multiplyMatrix +import ru.dbotthepony.kvector.vector.ndouble.MutableVector2d +import ru.dbotthepony.kvector.vector.ndouble.Vector2d +import ru.dbotthepony.kvector.vector.ndouble.Vector3d +import ru.dbotthepony.kvector.vector.ndouble.cross import kotlin.math.* /// "Next Largest Power of 2 @@ -115,11 +121,11 @@ class Rotation( ) } - operator fun times(v: IVector2d<*>): Vector2d { + operator fun times(v: Vector2d): Vector2d { return Vector2d(c * v.x - s * v.y, s * v.x + c * v.y) } - fun timesT(v: IVector2d<*>): Vector2d { + fun timesT(v: Vector2d): Vector2d { return Vector2d(c * v.x + s * v.y, -s * v.x + c * v.y) } } @@ -157,7 +163,7 @@ class Transform( } /// Set this based on the position and angle. - fun set(position: IVector2d<*>, angle: Double) { + fun set(position: Vector2d, angle: Double) { this.position = Vector2d(position.x, position.y) rotation.set(angle) } @@ -176,14 +182,14 @@ class Transform( ) } - operator fun times(v: IVector2d<*>): Vector2d { + operator fun times(v: Vector2d): Vector2d { return Vector2d( x = rotation.c * v.x - rotation.s * v.y + position.x, y = rotation.s * v.x + rotation.c * v.y + position.y ) } - fun timesT(v: IVector2d<*>): Vector2d { + fun timesT(v: Vector2d): Vector2d { val px = v.x - position.x val py = v.y - position.y @@ -330,7 +336,7 @@ class Sweep { */ @Suppress("NOTHING_TO_INLINE") internal inline fun b2Dot(a: Vector2d, b: Vector2d): Double { - return a.dotProduct(b) + return a.dot(b) } /** @@ -338,7 +344,7 @@ internal inline fun b2Dot(a: Vector2d, b: Vector2d): Double { */ @Suppress("NOTHING_TO_INLINE") internal inline fun b2Cross(a: Vector2d, b: Vector2d): Double { - return a.crossProduct(b) + return a.cross(b) } /** @@ -346,7 +352,7 @@ internal inline fun b2Cross(a: Vector2d, b: Vector2d): Double { */ @Suppress("NOTHING_TO_INLINE") internal inline fun b2Cross(a: Vector2d, b: Double): Vector2d { - return a.crossProduct(b) + return a.cross(b) } /** @@ -354,7 +360,7 @@ internal inline fun b2Cross(a: Vector2d, b: Double): Vector2d { */ @Suppress("NOTHING_TO_INLINE") internal inline fun b2Cross(a: Double, b: Vector2d): Vector2d { - return a.crossProduct(b) + return a.cross(b) } /** @@ -362,7 +368,7 @@ internal inline fun b2Cross(a: Double, b: Vector2d): Vector2d { */ @Suppress("NOTHING_TO_INLINE") internal inline fun b2Abs(a: Vector2d): Vector2d { - return a.absoluteVector + return a.absoluteValue } /** @@ -409,8 +415,9 @@ internal inline fun b2MulT(t: Transform, v: Vector2d): Vector2d { * Shortcut for faster porting of C++ code */ @Suppress("NOTHING_TO_INLINE") -internal inline fun b2Mul22(t: AbstractMatrix3d<*>, v: Vector2d): Vector2d { - return v.times(t) +internal inline fun b2Mul22(t: IMatrix3d<*>, v: Vector2d): Vector2d { + val result = multiplyMatrix(t.toMatrix2d(), v) + return Vector2d(result[0, 0], result[0, 1]) } /** @@ -433,16 +440,18 @@ internal inline fun b2MulT(t: Transform, v: Transform): Transform { * Shortcut for faster porting of C++ code */ @Suppress("NOTHING_TO_INLINE") -internal inline fun b2Mul(t: AbstractMatrix2d<*>, v: Vector2d): Vector2d { - return v.times(t) +internal inline fun b2Mul(t: IMatrix2d<*>, v: Vector2d): Vector2d { + val result = multiplyMatrix(t, v) + return Vector2d(result[0, 0], result[0, 1]) } /** * Shortcut for faster porting of C++ code */ @Suppress("NOTHING_TO_INLINE") -internal inline fun b2Mul(t: AbstractMatrix3d<*>, v: Vector3d): Vector3d { - return v.times(t) +internal inline fun b2Mul(t: IMatrix3d<*>, v: Vector3d): Vector3d { + val result = multiplyMatrix(t, v) + return Vector3d(result[0, 0], result[0, 1], result[0, 2]) } /** @@ -458,7 +467,7 @@ internal inline fun b2Min(a: Double, b: Double): Double { */ @Suppress("NOTHING_TO_INLINE") internal inline fun b2Min(a: Vector2d, b: Vector2d): Vector2d { - return a.minimumPerComponent(b) + return a.coerceAtMost(b) } /** @@ -482,7 +491,7 @@ internal inline fun b2Max(a: Double, b: Double): Double { */ @Suppress("NOTHING_TO_INLINE") internal inline fun b2Max(a: Vector2d, b: Vector2d): Vector2d { - return a.maximumPerComponent(b) + return a.coerceAtLeast(b) } /** @@ -508,3 +517,89 @@ internal inline fun b2DistanceSquared(a: Vector2d, b: Vector2d): Double { internal inline fun b2Clamp(a: Double, min: Double, max: Double): Double { return b2Max(min, b2Min(a, max)) } + +private fun scalarDotWithCross( + ax: Double, + ay: Double, + az: Double, + + bx: Double, + by: Double, + bz: Double, + + cx: Double, + cy: Double, + cz: Double, +): Double { + val crossX = by * cz - bz * cy + val crossY = bz * cx - bx * cz + val crossZ = bx * cy - by * cx + + return ax * crossX + ay * crossY + az * crossZ +} + +/** + * Solve A * x = b, where b is a column vector. This is more efficient + * than computing the inverse in one-shot cases. + */ +internal fun IMatrix3d<*>.solve(b: Vector3d): Vector3d { + var determinant = determinant!! + + if (determinant != 0.0) { + determinant = 1.0 / determinant + } + + return Vector3d( + x = determinant * scalarDotWithCross( + b.x, b.y, b.z, + r01, r11, r21, + r02, r12, r22, + ), + + y = determinant * scalarDotWithCross( + r00, r10, r20, + b.x, b.y, b.z, + r02, r12, r22, + ), + + z = determinant * scalarDotWithCross( + r00, r10, r20, + r01, r11, r21, + b.x, b.y, b.z, + ), + ) +} + +/** + * Solve A * x = b, where b is a column vector. This is more efficient + * than computing the inverse in one-shot cases. + */ +internal fun IMatrix3d<*>.solve(b: Vector2d): Vector2d { + var determinant = determinant!! + + if (determinant != 0.0) { + determinant = 1.0 / determinant + } + + return Vector2d( + x = determinant * (r11 * b.x - r01 * b.y), + y = determinant * (r00 * b.y - r10 * b.x), + ) +} + +/** + * Solve A * x = b, where b is a column vector. This is more efficient + * than computing the inverse in one-shot cases. + */ +internal fun IMatrix2d<*>.solve(b: Vector2d): Vector2d { + var determinant = determinant!! + + if (determinant != 0.0) { + determinant = 1.0 / determinant + } + + return Vector2d( + x = determinant * (r11 * b.x - r01 * b.y), + y = determinant * (r00 * b.y - r10 * b.x), + ) +} \ No newline at end of file diff --git a/src/main/kotlin/ru/dbotthepony/kbox2d/api/Shape.kt b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/api/Shape.kt similarity index 95% rename from src/main/kotlin/ru/dbotthepony/kbox2d/api/Shape.kt rename to src/kbox2d/kotlin/ru/dbotthepony/kbox2d/api/Shape.kt index a6ae264c..97ca3c83 100644 --- a/src/main/kotlin/ru/dbotthepony/kbox2d/api/Shape.kt +++ b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/api/Shape.kt @@ -1,7 +1,7 @@ package ru.dbotthepony.kbox2d.api -import ru.dbotthepony.kstarbound.math.AABB -import ru.dbotthepony.kstarbound.math.Vector2d +import ru.dbotthepony.kvector.util2d.AABB +import ru.dbotthepony.kvector.vector.ndouble.Vector2d data class MassData( val mass: Double, diff --git a/src/main/kotlin/ru/dbotthepony/kbox2d/api/ShapeDefs.kt b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/api/ShapeDefs.kt similarity index 100% rename from src/main/kotlin/ru/dbotthepony/kbox2d/api/ShapeDefs.kt rename to src/kbox2d/kotlin/ru/dbotthepony/kbox2d/api/ShapeDefs.kt diff --git a/src/main/kotlin/ru/dbotthepony/kbox2d/api/TimeOfImpact.kt b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/api/TimeOfImpact.kt similarity index 100% rename from src/main/kotlin/ru/dbotthepony/kbox2d/api/TimeOfImpact.kt rename to src/kbox2d/kotlin/ru/dbotthepony/kbox2d/api/TimeOfImpact.kt diff --git a/src/main/kotlin/ru/dbotthepony/kbox2d/api/World.kt b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/api/World.kt similarity index 97% rename from src/main/kotlin/ru/dbotthepony/kbox2d/api/World.kt rename to src/kbox2d/kotlin/ru/dbotthepony/kbox2d/api/World.kt index 4379e7e2..a4354ae5 100644 --- a/src/main/kotlin/ru/dbotthepony/kbox2d/api/World.kt +++ b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/api/World.kt @@ -1,8 +1,7 @@ package ru.dbotthepony.kbox2d.api -import ru.dbotthepony.kstarbound.client.gl.GLStateTracker -import ru.dbotthepony.kstarbound.math.AABB -import ru.dbotthepony.kstarbound.math.Vector2d +import ru.dbotthepony.kvector.util2d.AABB +import ru.dbotthepony.kvector.vector.ndouble.Vector2d /** * The world class manages all physics entities, dynamic simulation, diff --git a/src/main/kotlin/ru/dbotthepony/kbox2d/api/WorldCallbacks.kt b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/api/WorldCallbacks.kt similarity index 98% rename from src/main/kotlin/ru/dbotthepony/kbox2d/api/WorldCallbacks.kt rename to src/kbox2d/kotlin/ru/dbotthepony/kbox2d/api/WorldCallbacks.kt index 3386ec31..cc243454 100644 --- a/src/main/kotlin/ru/dbotthepony/kbox2d/api/WorldCallbacks.kt +++ b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/api/WorldCallbacks.kt @@ -1,6 +1,6 @@ package ru.dbotthepony.kbox2d.api -import ru.dbotthepony.kstarbound.math.Vector2d +import ru.dbotthepony.kvector.vector.ndouble.Vector2d /** * Implement this interface to provide collision filtering. In other words, you can implement diff --git a/src/main/kotlin/ru/dbotthepony/kbox2d/collision/BroadPhase.kt b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/collision/BroadPhase.kt similarity index 80% rename from src/main/kotlin/ru/dbotthepony/kbox2d/collision/BroadPhase.kt rename to src/kbox2d/kotlin/ru/dbotthepony/kbox2d/collision/BroadPhase.kt index 239ab603..5cffc7e3 100644 --- a/src/main/kotlin/ru/dbotthepony/kbox2d/collision/BroadPhase.kt +++ b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/collision/BroadPhase.kt @@ -1,9 +1,37 @@ package ru.dbotthepony.kbox2d.collision -import it.unimi.dsi.fastutil.ints.IntArrayList import ru.dbotthepony.kbox2d.api.* -import ru.dbotthepony.kstarbound.math.AABB -import ru.dbotthepony.kstarbound.math.Vector2d +import ru.dbotthepony.kvector.util2d.AABB +import ru.dbotthepony.kvector.vector.ndouble.Vector2d + +private class IntArrayList { + private var buffer = IntArray(16) + var size: Int = 0 + private set + + operator fun set(index: Int, value: Int) { + require(index in 0 until size) { "Index out of bounds: $index" } + buffer[index] = value + } + + operator fun get(index: Int): Int { + require(index in 0 until size) { "Index out of bounds: $index" } + return buffer[index] + } + + fun add(value: Int) { + if (size == buffer.size) { + val old = buffer + buffer = IntArray(size * 2) + + for (i in 0 until size) { + buffer[i] = old[i] + } + } + + buffer[size++] = value + } +} class BroadPhase : IBroadPhase { private val moveBuffer = IntArrayList() @@ -53,7 +81,7 @@ class BroadPhase : IBroadPhase { private fun unBufferMove(proxyId: Int) { for (i in 0 until moveCount) { - if (moveBuffer.getInt(i) == proxyId) { + if (moveBuffer[i] == proxyId) { moveBuffer[i] = e_nullProxy } } @@ -119,7 +147,7 @@ class BroadPhase : IBroadPhase { pairBuffer.clear() for (i in 0 until moveCount) { - val value = moveBuffer.getInt(i) + val value = moveBuffer[i] if (value == e_nullProxy) continue @@ -139,7 +167,7 @@ class BroadPhase : IBroadPhase { // Clear move flags for (i in 0 until moveCount) { - val value = moveBuffer.getInt(i) + val value = moveBuffer[i] if (value != e_nullProxy) { tree.clearMoved(value) diff --git a/src/main/kotlin/ru/dbotthepony/kbox2d/collision/Collision.kt b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/collision/Collision.kt similarity index 96% rename from src/main/kotlin/ru/dbotthepony/kbox2d/collision/Collision.kt rename to src/kbox2d/kotlin/ru/dbotthepony/kbox2d/collision/Collision.kt index a813fc89..8b84eca0 100644 --- a/src/main/kotlin/ru/dbotthepony/kbox2d/collision/Collision.kt +++ b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/collision/Collision.kt @@ -1,10 +1,9 @@ package ru.dbotthepony.kbox2d.collision import ru.dbotthepony.kbox2d.api.* -import ru.dbotthepony.kstarbound.math.Vector2d -import ru.dbotthepony.kstarbound.math.times +import ru.dbotthepony.kvector.vector.ndouble.Vector2d +import ru.dbotthepony.kvector.vector.ndouble.times import java.util.* -import kotlin.collections.ArrayList /// Compute the point states given two manifolds. The states pertain to the transition from manifold1 /// to manifold2. So state1 is either persist or remove while state2 is either add or persist. @@ -61,7 +60,7 @@ class WorldManifold(manifold: Manifold, xfA: Transform, radiusA: Double, xfB: Tr if (manifold.points.isNotEmpty()) { when (manifold.type) { Manifold.Type.CIRCLES -> { - normal = Vector2d.RIGHT + normal = Vector2d.POSITIVE_X val pointA = b2Mul(xfA, manifold.localPoint); val pointB = b2Mul(xfB, manifold.points[0].localPoint); diff --git a/src/main/kotlin/ru/dbotthepony/kbox2d/collision/Distance.kt b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/collision/Distance.kt similarity index 96% rename from src/main/kotlin/ru/dbotthepony/kbox2d/collision/Distance.kt rename to src/kbox2d/kotlin/ru/dbotthepony/kbox2d/collision/Distance.kt index bb34e8f8..06f7a1b3 100644 --- a/src/main/kotlin/ru/dbotthepony/kbox2d/collision/Distance.kt +++ b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/collision/Distance.kt @@ -1,14 +1,12 @@ package ru.dbotthepony.kbox2d.collision -import com.google.common.collect.ImmutableList import ru.dbotthepony.kbox2d.api.* import ru.dbotthepony.kbox2d.collision.shapes.ChainShape import ru.dbotthepony.kbox2d.collision.shapes.CircleShape import ru.dbotthepony.kbox2d.collision.shapes.EdgeShape import ru.dbotthepony.kbox2d.collision.shapes.PolygonShape -import ru.dbotthepony.kstarbound.math.Vector2d -import ru.dbotthepony.kstarbound.math.crossProduct -import ru.dbotthepony.kstarbound.math.times +import ru.dbotthepony.kvector.vector.ndouble.Vector2d +import ru.dbotthepony.kvector.vector.ndouble.times var b2_gjkCalls = 0 private set @@ -67,10 +65,10 @@ class DistanceProxy : IDistanceProxy { override fun getSupport(d: Vector2d): Int { var bestIndex = 0 - var bestValue = vertices[0].dotProduct(d) + var bestValue = b2Dot(vertices[0], d) for (i in 1 until vertices.size) { - val value = vertices[i].dotProduct(d) + val value = b2Dot(vertices[i], d) if (value > bestValue) { bestIndex = i @@ -271,7 +269,7 @@ class Simplex() { val e12 = w2 - w1 // w1 region - val d12_2 = -w1.dotProduct(e12) + val d12_2 = b2Dot(-w1, e12) if (d12_2 <= 0.0) { // a2 <= 0, so we clamp it to 0 v1.a = 1.0 @@ -280,7 +278,7 @@ class Simplex() { } // w2 region - val d12_1 = w2.dotProduct(e12) + val d12_1 = b2Dot(w2, e12) if (d12_1 <= 0.0) { // a1 <= 0, so we clamp it to 0 v2.a = 1.0 @@ -313,8 +311,8 @@ class Simplex() { // [w1.e12 w2.e12][a2] = [0] // a3 = 0 val e12 = w2 - w1 - val w1e12 = w1.dotProduct(e12) - val w2e12 = w2.dotProduct(e12) + val w1e12 = b2Dot(w1, e12) + val w2e12 = b2Dot(w2, e12) val d12_1 = w2e12 val d12_2 = -w1e12 @@ -323,8 +321,8 @@ class Simplex() { // [w1.e13 w3.e13][a3] = [0] // a2 = 0 val e13 = w3 - w1 - val w1e13 = w1.dotProduct(e13) - val w3e13 = w3.dotProduct(e13) + val w1e13 = b2Dot(w1, e13) + val w3e13 = b2Dot(w3, e13) val d13_1 = w3e13 val d13_2 = -w1e13 @@ -333,8 +331,8 @@ class Simplex() { // [w2.e23 w3.e23][a3] = [0] // a1 = 0 val e23 = w3 - w2 - val w2e23 = w2.dotProduct(e23) - val w3e23 = w3.dotProduct(e23) + val w2e23 = b2Dot(w2, e23) + val w3e23 = b2Dot(w3, e23) val d23_1 = w3e23 val d23_2 = -w2e23 @@ -611,8 +609,8 @@ fun b2ShapeCast( v = v.normalized // Intersect ray with plane - val vp = v.dotProduct(p) - val vr = v.dotProduct(r) + val vp = b2Dot(v, p) + val vr = b2Dot(v, r) if (vp - sigma > lambda * vr) { if (vr <= 0.0) { diff --git a/src/main/kotlin/ru/dbotthepony/kbox2d/collision/DynamicTree.kt b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/collision/DynamicTree.kt similarity index 97% rename from src/main/kotlin/ru/dbotthepony/kbox2d/collision/DynamicTree.kt rename to src/kbox2d/kotlin/ru/dbotthepony/kbox2d/collision/DynamicTree.kt index 9bcbe1f8..ad3bad09 100644 --- a/src/main/kotlin/ru/dbotthepony/kbox2d/collision/DynamicTree.kt +++ b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/collision/DynamicTree.kt @@ -1,8 +1,8 @@ package ru.dbotthepony.kbox2d.collision import ru.dbotthepony.kbox2d.api.* -import ru.dbotthepony.kstarbound.math.AABB -import ru.dbotthepony.kstarbound.math.Vector2d +import ru.dbotthepony.kvector.util2d.AABB +import ru.dbotthepony.kvector.vector.ndouble.Vector2d import kotlin.math.absoluteValue const val b2_nullNode = -1 @@ -111,8 +111,8 @@ class DynamicTree : IDynamicTree { check(nodes[proxyID].isLeaf) { "Can't move whole branch" } // Extend AABB - val mins = aabb.mins.toMutableVector() - R - val maxs = aabb.maxs.toMutableVector() + R + val mins = (aabb.mins - R).toMutableVector() + val maxs = (aabb.maxs + R).toMutableVector() // Predict AABB movement val d = displacement * b2_aabbMultiplier @@ -648,7 +648,7 @@ class DynamicTree : IDynamicTree { // v is perpendicular to the segment. val v = b2Cross(1.0, r) - val abs_v = v.absoluteVector + val abs_v = v.absoluteValue // Separating axis for segment (Gino, p80). // |dot(v, p1 - c)| > dot(|v|, h) @@ -660,8 +660,8 @@ class DynamicTree : IDynamicTree { var t = p1 + diff * maxFraction var segmentAABB = AABB( - mins = p1.minimumPerComponent(t), - maxs = p1.maximumPerComponent(t) + mins = p1.coerceAtMost(t), + maxs = p1.coerceAtLeast(t) ) val stack = ArrayDeque(256) @@ -683,7 +683,7 @@ class DynamicTree : IDynamicTree { // Separating axis for segment (Gino, p80). // |dot(v, p1 - c)| > dot(|v|, h) - if (v.dotProduct(p1 - nodeAABB.centre).absoluteValue > abs_v.dotProduct(nodeAABB.extents)) { + if (v.dot(p1 - nodeAABB.centre).absoluteValue > abs_v.dot(nodeAABB.extents)) { continue } @@ -698,8 +698,8 @@ class DynamicTree : IDynamicTree { maxFraction = value t = p1 + diff * maxFraction segmentAABB = AABB( - mins = p1.minimumPerComponent(t), - maxs = p1.maximumPerComponent(t) + mins = p1.coerceAtMost(t), + maxs = p1.coerceAtLeast(t) ) } } else { diff --git a/src/main/kotlin/ru/dbotthepony/kbox2d/collision/TimeOfImpact.kt b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/collision/TimeOfImpact.kt similarity index 95% rename from src/main/kotlin/ru/dbotthepony/kbox2d/collision/TimeOfImpact.kt rename to src/kbox2d/kotlin/ru/dbotthepony/kbox2d/collision/TimeOfImpact.kt index baec4960..ab2f10ef 100644 --- a/src/main/kotlin/ru/dbotthepony/kbox2d/collision/TimeOfImpact.kt +++ b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/collision/TimeOfImpact.kt @@ -1,8 +1,8 @@ package ru.dbotthepony.kbox2d.collision import ru.dbotthepony.kbox2d.api.* -import ru.dbotthepony.kstarbound.math.Vector2d -import ru.dbotthepony.kstarbound.math.times +import ru.dbotthepony.kvector.vector.ndouble.Vector2d +import ru.dbotthepony.kvector.vector.ndouble.times import kotlin.math.absoluteValue var b2_toiCalls = 0 @@ -133,7 +133,7 @@ private class SeparationFunction( return MinSeparationResult( indexA = indexA, indexB = indexB, - separation = (pointB - pointA).dotProduct(axis) + separation = (pointB - pointA).dot(axis) ) } @@ -149,7 +149,7 @@ private class SeparationFunction( val localPointB = proxyB.vertices[indexB] val pointB = xfB.times(localPointB) - val separation = (pointB - pointA).dotProduct(normal) + val separation = (pointB - pointA).dot(normal) return MinSeparationResult( indexA = indexA, indexB = indexB, @@ -169,7 +169,7 @@ private class SeparationFunction( val localPointA = proxyA.vertices[indexA] val pointA = xfA.times(localPointA) - val separation = (pointA - pointB).dotProduct(normal) + val separation = (pointA - pointB).dot(normal) return MinSeparationResult( indexA = indexA, indexB = indexB, @@ -191,7 +191,7 @@ private class SeparationFunction( val pointA = xfA.times(localPointA) val pointB = xfB.times(localPointB) - return (pointB - pointA).dotProduct(axis) + return (pointB - pointA).dot(axis) } Type.FACE_A -> { @@ -201,7 +201,7 @@ private class SeparationFunction( val localPointB = proxyB.vertices[indexB] val pointB = xfB.times(localPointB) - return (pointB - pointA).dotProduct(normal) + return (pointB - pointA).dot(normal) } Type.FACE_B -> { @@ -211,7 +211,7 @@ private class SeparationFunction( val localPointA = proxyA.vertices[indexA] val pointA = xfA.times(localPointA) - return (pointA - pointB).dotProduct(normal) + return (pointA - pointB).dot(normal) } } } diff --git a/src/main/kotlin/ru/dbotthepony/kbox2d/collision/handler/CollideCircle.kt b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/collision/handler/CollideCircle.kt similarity index 98% rename from src/main/kotlin/ru/dbotthepony/kbox2d/collision/handler/CollideCircle.kt rename to src/kbox2d/kotlin/ru/dbotthepony/kbox2d/collision/handler/CollideCircle.kt index 678941d3..760d2865 100644 --- a/src/main/kotlin/ru/dbotthepony/kbox2d/collision/handler/CollideCircle.kt +++ b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/collision/handler/CollideCircle.kt @@ -5,7 +5,7 @@ import ru.dbotthepony.kbox2d.api.b2Dot import ru.dbotthepony.kbox2d.api.b2Mul import ru.dbotthepony.kbox2d.collision.shapes.CircleShape import ru.dbotthepony.kbox2d.collision.shapes.PolygonShape -import ru.dbotthepony.kstarbound.math.times +import ru.dbotthepony.kvector.vector.ndouble.times internal fun b2CollideCircles( circleA: CircleShape, diff --git a/src/main/kotlin/ru/dbotthepony/kbox2d/collision/handler/CollideEdge.kt b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/collision/handler/CollideEdge.kt similarity index 99% rename from src/main/kotlin/ru/dbotthepony/kbox2d/collision/handler/CollideEdge.kt rename to src/kbox2d/kotlin/ru/dbotthepony/kbox2d/collision/handler/CollideEdge.kt index cc3b8e52..577b2f89 100644 --- a/src/main/kotlin/ru/dbotthepony/kbox2d/collision/handler/CollideEdge.kt +++ b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/collision/handler/CollideEdge.kt @@ -7,8 +7,8 @@ import ru.dbotthepony.kbox2d.collision.b2ClipSegmentToLine import ru.dbotthepony.kbox2d.collision.shapes.CircleShape import ru.dbotthepony.kbox2d.collision.shapes.EdgeShape import ru.dbotthepony.kbox2d.collision.shapes.PolygonShape -import ru.dbotthepony.kstarbound.math.Vector2d -import ru.dbotthepony.kstarbound.math.times +import ru.dbotthepony.kvector.vector.ndouble.Vector2d +import ru.dbotthepony.kvector.vector.ndouble.times import java.util.* import kotlin.collections.ArrayList diff --git a/src/main/kotlin/ru/dbotthepony/kbox2d/collision/handler/CollidePolygon.kt b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/collision/handler/CollidePolygon.kt similarity index 99% rename from src/main/kotlin/ru/dbotthepony/kbox2d/collision/handler/CollidePolygon.kt rename to src/kbox2d/kotlin/ru/dbotthepony/kbox2d/collision/handler/CollidePolygon.kt index 45f5aab4..ae0dc234 100644 --- a/src/main/kotlin/ru/dbotthepony/kbox2d/collision/handler/CollidePolygon.kt +++ b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/collision/handler/CollidePolygon.kt @@ -6,7 +6,7 @@ import ru.dbotthepony.kbox2d.api.b2Mul import ru.dbotthepony.kbox2d.api.b2MulT import ru.dbotthepony.kbox2d.collision.b2ClipSegmentToLine import ru.dbotthepony.kbox2d.collision.shapes.PolygonShape -import ru.dbotthepony.kstarbound.math.times +import ru.dbotthepony.kvector.vector.ndouble.times import java.util.* import kotlin.collections.ArrayList diff --git a/src/main/kotlin/ru/dbotthepony/kbox2d/collision/shapes/ChainShape.kt b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/collision/shapes/ChainShape.kt similarity index 96% rename from src/main/kotlin/ru/dbotthepony/kbox2d/collision/shapes/ChainShape.kt rename to src/kbox2d/kotlin/ru/dbotthepony/kbox2d/collision/shapes/ChainShape.kt index 1060c58b..a70e03bb 100644 --- a/src/main/kotlin/ru/dbotthepony/kbox2d/collision/shapes/ChainShape.kt +++ b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/collision/shapes/ChainShape.kt @@ -1,8 +1,8 @@ package ru.dbotthepony.kbox2d.collision.shapes import ru.dbotthepony.kbox2d.api.* -import ru.dbotthepony.kstarbound.math.AABB -import ru.dbotthepony.kstarbound.math.Vector2d +import ru.dbotthepony.kvector.util2d.AABB +import ru.dbotthepony.kvector.vector.ndouble.Vector2d /** * A chain shape is a free form sequence of line segments. @@ -27,8 +27,8 @@ class ChainShape : IShape { val v1 = vertices[i - 1] val v2 = vertices[i] - v1.isFiniteOrThrow { "Vertex at ${i - 1} is invalid" } - v2.isFiniteOrThrow { "Vertex at $i is invalid" } + v1.requireIsValid { "Vertex at ${i - 1} is invalid" } + v2.requireIsValid { "Vertex at $i is invalid" } require(b2DistanceSquared(v1, v2) > b2_linearSlop * b2_linearSlop) { "Vertices are too close together, at indices ${i - 1} ($v1) and $i ($v2)" diff --git a/src/main/kotlin/ru/dbotthepony/kbox2d/collision/shapes/CircleShape.kt b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/collision/shapes/CircleShape.kt similarity index 93% rename from src/main/kotlin/ru/dbotthepony/kbox2d/collision/shapes/CircleShape.kt rename to src/kbox2d/kotlin/ru/dbotthepony/kbox2d/collision/shapes/CircleShape.kt index 69d6e70b..0cd8bf7a 100644 --- a/src/main/kotlin/ru/dbotthepony/kbox2d/collision/shapes/CircleShape.kt +++ b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/collision/shapes/CircleShape.kt @@ -1,9 +1,9 @@ package ru.dbotthepony.kbox2d.collision.shapes import ru.dbotthepony.kbox2d.api.* -import ru.dbotthepony.kstarbound.math.AABB -import ru.dbotthepony.kstarbound.math.Vector2d -import ru.dbotthepony.kstarbound.math.times +import ru.dbotthepony.kvector.util2d.AABB +import ru.dbotthepony.kvector.vector.ndouble.Vector2d +import ru.dbotthepony.kvector.vector.ndouble.times import kotlin.math.PI import kotlin.math.sqrt diff --git a/src/main/kotlin/ru/dbotthepony/kbox2d/collision/shapes/EdgeShape.kt b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/collision/shapes/EdgeShape.kt similarity index 96% rename from src/main/kotlin/ru/dbotthepony/kbox2d/collision/shapes/EdgeShape.kt rename to src/kbox2d/kotlin/ru/dbotthepony/kbox2d/collision/shapes/EdgeShape.kt index 516b744c..55795f0f 100644 --- a/src/main/kotlin/ru/dbotthepony/kbox2d/collision/shapes/EdgeShape.kt +++ b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/collision/shapes/EdgeShape.kt @@ -1,9 +1,9 @@ package ru.dbotthepony.kbox2d.collision.shapes import ru.dbotthepony.kbox2d.api.* -import ru.dbotthepony.kstarbound.math.AABB -import ru.dbotthepony.kstarbound.math.Vector2d -import ru.dbotthepony.kstarbound.math.times +import ru.dbotthepony.kvector.util2d.AABB +import ru.dbotthepony.kvector.vector.ndouble.Vector2d +import ru.dbotthepony.kvector.vector.ndouble.times /** * A line segment (edge) shape. These can be connected in chains or loops diff --git a/src/main/kotlin/ru/dbotthepony/kbox2d/collision/shapes/PolygonShape.kt b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/collision/shapes/PolygonShape.kt similarity index 95% rename from src/main/kotlin/ru/dbotthepony/kbox2d/collision/shapes/PolygonShape.kt rename to src/kbox2d/kotlin/ru/dbotthepony/kbox2d/collision/shapes/PolygonShape.kt index 864002bf..4ad461e4 100644 --- a/src/main/kotlin/ru/dbotthepony/kbox2d/collision/shapes/PolygonShape.kt +++ b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/collision/shapes/PolygonShape.kt @@ -1,10 +1,9 @@ package ru.dbotthepony.kbox2d.collision.shapes -import it.unimi.dsi.fastutil.ints.IntArrayList import ru.dbotthepony.kbox2d.api.* -import ru.dbotthepony.kstarbound.math.AABB -import ru.dbotthepony.kstarbound.math.Vector2d -import ru.dbotthepony.kstarbound.math.times +import ru.dbotthepony.kvector.util2d.AABB +import ru.dbotthepony.kvector.vector.ndouble.Vector2d +import ru.dbotthepony.kvector.vector.ndouble.times private const val inv3 = 1.0 / 3.0 @@ -100,7 +99,7 @@ class PolygonShape : IShape { } } - val hull = IntArrayList() + val hull = ArrayList() var ih = i0 while (true) { @@ -139,7 +138,7 @@ class PolygonShape : IShape { // Copy vertices. for (i in hull.indices) { - this.vertices.add(ps[hull.getInt(i)]) + this.vertices.add(ps[hull[i]]) } // Compute normals. Ensure the edges have non-zero length. @@ -168,10 +167,10 @@ class PolygonShape : IShape { vertices.add(Vector2d(hx, hy)) vertices.add(Vector2d(-hx, hy)) - normals.add(Vector2d.DOWN) - normals.add(Vector2d.RIGHT) - normals.add(Vector2d.UP) - normals.add(Vector2d.LEFT) + normals.add(Vector2d.NEGATIVE_Y) + normals.add(Vector2d.POSITIVE_X) + normals.add(Vector2d.POSITIVE_Y) + normals.add(Vector2d.NEGATIVE_X) centroid = Vector2d.ZERO } @@ -192,10 +191,10 @@ class PolygonShape : IShape { vertices.add(Vector2d(hx, hy)) vertices.add(Vector2d(-hx, hy)) - normals.add(Vector2d.DOWN) - normals.add(Vector2d.RIGHT) - normals.add(Vector2d.UP) - normals.add(Vector2d.LEFT) + normals.add(Vector2d.NEGATIVE_Y) + normals.add(Vector2d.POSITIVE_X) + normals.add(Vector2d.POSITIVE_Y) + normals.add(Vector2d.NEGATIVE_X) centroid = center diff --git a/src/main/kotlin/ru/dbotthepony/kbox2d/dynamics/B2World.kt b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/dynamics/B2World.kt similarity index 98% rename from src/main/kotlin/ru/dbotthepony/kbox2d/dynamics/B2World.kt rename to src/kbox2d/kotlin/ru/dbotthepony/kbox2d/dynamics/B2World.kt index e3594d07..89d8fe4f 100644 --- a/src/main/kotlin/ru/dbotthepony/kbox2d/dynamics/B2World.kt +++ b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/dynamics/B2World.kt @@ -10,10 +10,10 @@ import ru.dbotthepony.kbox2d.collision.shapes.PolygonShape import ru.dbotthepony.kbox2d.dynamics.contact.AbstractContact import ru.dbotthepony.kbox2d.dynamics.internal.Island import ru.dbotthepony.kbox2d.dynamics.joint.AbstractJoint -import ru.dbotthepony.kstarbound.math.AABB -import ru.dbotthepony.kstarbound.math.Vector2d -import ru.dbotthepony.kstarbound.math.times -import ru.dbotthepony.kstarbound.util.Color +import ru.dbotthepony.kvector.util2d.AABB +import ru.dbotthepony.kvector.vector.Color +import ru.dbotthepony.kvector.vector.ndouble.Vector2d +import ru.dbotthepony.kvector.vector.ndouble.times class B2World(override var gravity: Vector2d) : IB2World { override var bodyCount: Int = 0 @@ -762,7 +762,7 @@ class B2World(override var gravity: Vector2d) : IB2World { val circle = fixture.shape as CircleShape val center = b2Mul(xf, circle.p) val radius = circle.radius - val axis = b2Mul(xf.q, Vector2d.RIGHT) + val axis = b2Mul(xf.q, Vector2d.POSITIVE_X) debugDraw?.drawSolidCircle(center, radius, axis, color) } diff --git a/src/main/kotlin/ru/dbotthepony/kbox2d/dynamics/Body.kt b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/dynamics/Body.kt similarity index 97% rename from src/main/kotlin/ru/dbotthepony/kbox2d/dynamics/Body.kt rename to src/kbox2d/kotlin/ru/dbotthepony/kbox2d/dynamics/Body.kt index e82d44fc..d83e7abe 100644 --- a/src/main/kotlin/ru/dbotthepony/kbox2d/dynamics/Body.kt +++ b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/dynamics/Body.kt @@ -1,7 +1,7 @@ package ru.dbotthepony.kbox2d.dynamics import ru.dbotthepony.kbox2d.api.* -import ru.dbotthepony.kstarbound.math.Vector2d +import ru.dbotthepony.kvector.vector.ndouble.Vector2d open class Body(def: BodyDef, world: IB2World) : IBody { private var _world: IB2World? = world @@ -62,7 +62,7 @@ open class Body(def: BodyDef, world: IB2World) : IBody { if (type == BodyType.STATIC) return - if (value.dotProduct(value) > 0.0) + if (value.dot(value) > 0.0) isAwake = true field = value @@ -369,7 +369,7 @@ open class Body(def: BodyDef, world: IB2World) : IBody { if (rotInertia > 0.0 && !isFixedRotation) { // Center the inertia about the center of mass. - rotInertia -= mass * localCenter.dotProduct(localCenter) + rotInertia -= mass * localCenter.dot(localCenter) check(rotInertia > 0.0) rotInertiaInv = 1.0 / rotInertia } else { @@ -413,7 +413,7 @@ open class Body(def: BodyDef, world: IB2World) : IBody { invMass = 1.0 / mass if (value.inertia > 0.0 && !isFixedRotation) { - rotInertia = value.inertia - mass * value.center.dotProduct(value.center) + rotInertia = value.inertia - mass * value.center.dot(value.center) check(rotInertia > 0.0) rotInertiaInv = 1.0 / rotInertia } @@ -478,7 +478,7 @@ open class Body(def: BodyDef, world: IB2World) : IBody { } override val inertia: Double - get() = rotInertia + mass * sweep.localCenter.dotProduct(sweep.localCenter) + get() = rotInertia + mass * sweep.localCenter.dot(sweep.localCenter) override val localCenter: Vector2d get() = sweep.localCenter diff --git a/src/main/kotlin/ru/dbotthepony/kbox2d/dynamics/ContactManager.kt b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/dynamics/ContactManager.kt similarity index 100% rename from src/main/kotlin/ru/dbotthepony/kbox2d/dynamics/ContactManager.kt rename to src/kbox2d/kotlin/ru/dbotthepony/kbox2d/dynamics/ContactManager.kt diff --git a/src/main/kotlin/ru/dbotthepony/kbox2d/dynamics/Fixture.kt b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/dynamics/Fixture.kt similarity index 100% rename from src/main/kotlin/ru/dbotthepony/kbox2d/dynamics/Fixture.kt rename to src/kbox2d/kotlin/ru/dbotthepony/kbox2d/dynamics/Fixture.kt diff --git a/src/main/kotlin/ru/dbotthepony/kbox2d/dynamics/contact/AbstractContact.kt b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/dynamics/contact/AbstractContact.kt similarity index 95% rename from src/main/kotlin/ru/dbotthepony/kbox2d/dynamics/contact/AbstractContact.kt rename to src/kbox2d/kotlin/ru/dbotthepony/kbox2d/dynamics/contact/AbstractContact.kt index 5d776daa..ac4c7382 100644 --- a/src/main/kotlin/ru/dbotthepony/kbox2d/dynamics/contact/AbstractContact.kt +++ b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/dynamics/contact/AbstractContact.kt @@ -1,11 +1,11 @@ package ru.dbotthepony.kbox2d.dynamics.contact -import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap -import it.unimi.dsi.fastutil.objects.Object2ObjectFunction import ru.dbotthepony.kbox2d.api.* import ru.dbotthepony.kbox2d.collision.WorldManifold import ru.dbotthepony.kbox2d.collision.b2TestOverlap import ru.dbotthepony.kbox2d.dynamics.Body +import java.util.* +import kotlin.collections.HashMap fun interface ContactFactory { fun factorize(fixtureA: IFixture, childIndexA: Int, fixtureB: IFixture, childIndexB: Int): AbstractContact @@ -161,11 +161,10 @@ sealed class AbstractContact( companion object { private val registry = - Object2ObjectArrayMap>() + EnumMap>(IShape.Type::class.java) internal fun register(type1: IShape.Type, type2: IShape.Type, factory: ContactFactory) { - registry.computeIfAbsent(type1, Object2ObjectFunction { Object2ObjectArrayMap() }) - .put(type2, factory) + registry.computeIfAbsent(type1) { EnumMap(IShape.Type::class.java) }[type2] = factory } internal fun create( diff --git a/src/main/kotlin/ru/dbotthepony/kbox2d/dynamics/contact/ChainCircleContact.kt b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/dynamics/contact/ChainCircleContact.kt similarity index 100% rename from src/main/kotlin/ru/dbotthepony/kbox2d/dynamics/contact/ChainCircleContact.kt rename to src/kbox2d/kotlin/ru/dbotthepony/kbox2d/dynamics/contact/ChainCircleContact.kt diff --git a/src/main/kotlin/ru/dbotthepony/kbox2d/dynamics/contact/ChainPolygonContact.kt b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/dynamics/contact/ChainPolygonContact.kt similarity index 100% rename from src/main/kotlin/ru/dbotthepony/kbox2d/dynamics/contact/ChainPolygonContact.kt rename to src/kbox2d/kotlin/ru/dbotthepony/kbox2d/dynamics/contact/ChainPolygonContact.kt diff --git a/src/main/kotlin/ru/dbotthepony/kbox2d/dynamics/contact/CircleContact.kt b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/dynamics/contact/CircleContact.kt similarity index 100% rename from src/main/kotlin/ru/dbotthepony/kbox2d/dynamics/contact/CircleContact.kt rename to src/kbox2d/kotlin/ru/dbotthepony/kbox2d/dynamics/contact/CircleContact.kt diff --git a/src/main/kotlin/ru/dbotthepony/kbox2d/dynamics/contact/EdgeCircleContact.kt b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/dynamics/contact/EdgeCircleContact.kt similarity index 100% rename from src/main/kotlin/ru/dbotthepony/kbox2d/dynamics/contact/EdgeCircleContact.kt rename to src/kbox2d/kotlin/ru/dbotthepony/kbox2d/dynamics/contact/EdgeCircleContact.kt diff --git a/src/main/kotlin/ru/dbotthepony/kbox2d/dynamics/contact/EdgePolygonContact.kt b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/dynamics/contact/EdgePolygonContact.kt similarity index 100% rename from src/main/kotlin/ru/dbotthepony/kbox2d/dynamics/contact/EdgePolygonContact.kt rename to src/kbox2d/kotlin/ru/dbotthepony/kbox2d/dynamics/contact/EdgePolygonContact.kt diff --git a/src/main/kotlin/ru/dbotthepony/kbox2d/dynamics/contact/PolygonCircleContact.kt b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/dynamics/contact/PolygonCircleContact.kt similarity index 100% rename from src/main/kotlin/ru/dbotthepony/kbox2d/dynamics/contact/PolygonCircleContact.kt rename to src/kbox2d/kotlin/ru/dbotthepony/kbox2d/dynamics/contact/PolygonCircleContact.kt diff --git a/src/main/kotlin/ru/dbotthepony/kbox2d/dynamics/contact/PolygonContact.kt b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/dynamics/contact/PolygonContact.kt similarity index 100% rename from src/main/kotlin/ru/dbotthepony/kbox2d/dynamics/contact/PolygonContact.kt rename to src/kbox2d/kotlin/ru/dbotthepony/kbox2d/dynamics/contact/PolygonContact.kt diff --git a/src/main/kotlin/ru/dbotthepony/kbox2d/dynamics/internal/ContactSolver.kt b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/dynamics/internal/ContactSolver.kt similarity index 97% rename from src/main/kotlin/ru/dbotthepony/kbox2d/dynamics/internal/ContactSolver.kt rename to src/kbox2d/kotlin/ru/dbotthepony/kbox2d/dynamics/internal/ContactSolver.kt index beb242bb..2352f7a4 100644 --- a/src/main/kotlin/ru/dbotthepony/kbox2d/dynamics/internal/ContactSolver.kt +++ b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/dynamics/internal/ContactSolver.kt @@ -4,9 +4,10 @@ import ru.dbotthepony.kbox2d.api.* import ru.dbotthepony.kbox2d.collision.WorldManifold import ru.dbotthepony.kbox2d.dynamics.contact.AbstractContact import ru.dbotthepony.kbox2d.dynamics.Body -import ru.dbotthepony.kstarbound.math.MutableMatrix2d -import ru.dbotthepony.kstarbound.math.Vector2d -import ru.dbotthepony.kstarbound.math.times +import ru.dbotthepony.kvector.matrix.ndouble.Matrix2d +import ru.dbotthepony.kvector.matrix.ndouble.MutableMatrix2d +import ru.dbotthepony.kvector.vector.ndouble.Vector2d +import ru.dbotthepony.kvector.vector.ndouble.times import java.lang.IllegalArgumentException import kotlin.math.absoluteValue @@ -161,8 +162,8 @@ internal class ContactSolver( invIA = bodyA.rotInertiaInv, invIB = bodyB.rotInertiaInv, contactIndex = i, - K = MutableMatrix2d(m00 = 0.0, m11 = 0.0), - normalMass = MutableMatrix2d(m00 = 0.0, m11 = 0.0), + K = MutableMatrix2d.zero(), + normalMass = MutableMatrix2d.zero(), normal = Vector2d.ZERO, points = Array(manifold.points.size) { VelocityCostantPoint() } ) @@ -301,11 +302,11 @@ internal class ContactSolver( // vc->K.ex.Set(k11, k12); // vc->K.ey.Set(k12, k22); - vc.K.m00 = k11 - vc.K.m10 = k12 - vc.K.m01 = k12 - vc.K.m11 = k22 - vc.normalMass = vc.K.getInverse().asMutableMatrix() + vc.K.r00 = k11 + vc.K.r10 = k12 + vc.K.r01 = k12 + vc.K.r11 = k22 + vc.normalMass = (vc.K.inverse ?: Matrix2d.ZERO).toMutableMatrix2d() } else { // The constraints are redundant, just use one. // TODO_ERIN use deepest? @@ -514,8 +515,8 @@ internal class ContactSolver( dv2 = vB + b2Cross(wB, cp2.rB) - vA - b2Cross(wA, cp2.rA) // Compute normal velocity - vn1 = dv1.dotProduct(normal) - vn2 = dv2.dotProduct(normal) + vn1 = b2Dot(dv1, normal) + vn2 = b2Dot(dv2, normal) check((vn1 - cp1.velocityBias).absoluteValue < k_errorTol) { (vn1 - cp1.velocityBias).absoluteValue } check((vn2 - cp2.velocityBias).absoluteValue < k_errorTol) { (vn2 - cp2.velocityBias).absoluteValue } @@ -534,7 +535,7 @@ internal class ContactSolver( vn1 = 0.0 // vn2 = vc->K.ex.y * x.x + b.y; - vn2 = vc.K.m10 * x.x + b.y + vn2 = vc.K.r10 * x.x + b.y if (x.x >= 0.0 && vn2 >= 0.0) { // Get the incremental impulse @@ -574,7 +575,7 @@ internal class ContactSolver( // 0 = a21 * 0 + a22 * x2 + b2' // x = Vector2d(y = -cp2.normalMass * b.y) - vn1 = vc.K.m01 * x.y + b.x + vn1 = vc.K.r01 * x.y + b.x vn2 = 0.0 if (x.y >= 0.0 && vn1 >= 0.0) { diff --git a/src/main/kotlin/ru/dbotthepony/kbox2d/dynamics/internal/Island.kt b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/dynamics/internal/Island.kt similarity index 97% rename from src/main/kotlin/ru/dbotthepony/kbox2d/dynamics/internal/Island.kt rename to src/kbox2d/kotlin/ru/dbotthepony/kbox2d/dynamics/internal/Island.kt index 4c0c6369..9ed5c1b2 100644 --- a/src/main/kotlin/ru/dbotthepony/kbox2d/dynamics/internal/Island.kt +++ b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/dynamics/internal/Island.kt @@ -6,8 +6,8 @@ import ru.dbotthepony.kbox2d.collision.b2Distance import ru.dbotthepony.kbox2d.dynamics.contact.AbstractContact import ru.dbotthepony.kbox2d.dynamics.joint.AbstractJoint import ru.dbotthepony.kbox2d.dynamics.Body -import ru.dbotthepony.kstarbound.math.Vector2d -import ru.dbotthepony.kstarbound.math.times +import ru.dbotthepony.kvector.vector.ndouble.Vector2d +import ru.dbotthepony.kvector.vector.ndouble.times import java.util.* import kotlin.collections.ArrayList import kotlin.math.absoluteValue @@ -266,7 +266,7 @@ internal class Island( // Check for large velocities val translation = h * v - if (translation.dotProduct(translation) > b2_maxTranslationSquared) { + if (translation.dot(translation) > b2_maxTranslationSquared) { v *= b2_maxTranslation / translation.length } @@ -330,7 +330,7 @@ internal class Island( if ( !body.allowAutoSleep || body.angularVelocity * body.angularVelocity > angTolSqr || - body.linearVelocity.dotProduct(body.linearVelocity) > linTolSqr + body.linearVelocity.dot(body.linearVelocity) > linTolSqr ) { body.sleepTime = 0.0 minSleepTime = 0.0 @@ -434,7 +434,7 @@ internal class Island( // Check for large velocities val translation = h * v - if (translation.dotProduct(translation) > b2_maxTranslationSquared) { + if (translation.dot(translation) > b2_maxTranslationSquared) { v *= b2_maxTranslation / translation.length } diff --git a/src/main/kotlin/ru/dbotthepony/kbox2d/dynamics/joint/AbstractJoint.kt b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/dynamics/joint/AbstractJoint.kt similarity index 95% rename from src/main/kotlin/ru/dbotthepony/kbox2d/dynamics/joint/AbstractJoint.kt rename to src/kbox2d/kotlin/ru/dbotthepony/kbox2d/dynamics/joint/AbstractJoint.kt index 929417be..2fe27f92 100644 --- a/src/main/kotlin/ru/dbotthepony/kbox2d/dynamics/joint/AbstractJoint.kt +++ b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/dynamics/joint/AbstractJoint.kt @@ -1,10 +1,9 @@ package ru.dbotthepony.kbox2d.dynamics.joint -import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap import ru.dbotthepony.kbox2d.api.* import ru.dbotthepony.kbox2d.dynamics.Body -import ru.dbotthepony.kstarbound.math.Vector2d -import kotlin.math.PI +import ru.dbotthepony.kvector.vector.ndouble.Vector2d +import java.util.EnumMap fun interface JointFactory { fun factorize(jointDef: IJointDef): AbstractJoint @@ -85,7 +84,7 @@ sealed class AbstractJoint(def: IJointDef) : IJoint { } companion object { - private val registry = Object2ObjectArrayMap() + private val registry = EnumMap(JointType::class.java) internal fun register(jointType: JointType, factory: JointFactory) { require(registry.put(jointType, factory) == null) { "Re-registered $jointType factory" } diff --git a/src/main/kotlin/ru/dbotthepony/kbox2d/dynamics/joint/DistanceJoint.kt b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/dynamics/joint/DistanceJoint.kt similarity index 97% rename from src/main/kotlin/ru/dbotthepony/kbox2d/dynamics/joint/DistanceJoint.kt rename to src/kbox2d/kotlin/ru/dbotthepony/kbox2d/dynamics/joint/DistanceJoint.kt index 8fa5f763..b0f43f31 100644 --- a/src/main/kotlin/ru/dbotthepony/kbox2d/dynamics/joint/DistanceJoint.kt +++ b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/dynamics/joint/DistanceJoint.kt @@ -3,9 +3,9 @@ package ru.dbotthepony.kbox2d.dynamics.joint import ru.dbotthepony.kbox2d.api.* import ru.dbotthepony.kbox2d.api.B2SolverData import ru.dbotthepony.kbox2d.api.b2Max -import ru.dbotthepony.kstarbound.math.Vector2d -import ru.dbotthepony.kstarbound.math.times -import ru.dbotthepony.kstarbound.util.Color +import ru.dbotthepony.kvector.vector.Color +import ru.dbotthepony.kvector.vector.ndouble.Vector2d +import ru.dbotthepony.kvector.vector.ndouble.times class DistanceJoint(def: DistanceJointDef) : AbstractJoint(def) { var stiffness: Double = def.stiffness @@ -254,7 +254,7 @@ class DistanceJoint(def: DistanceJointDef) : AbstractJoint(def) { val rB = b2Mul(qB, localAnchorB - localCenterB) var u = cB + rB - cA - rA - u.isFiniteOrThrow { + u.requireIsValid { "u is invalid, $cB, $rB, $cA, $rA" } @@ -275,7 +275,7 @@ class DistanceJoint(def: DistanceJointDef) : AbstractJoint(def) { val impulse = -mass * C val P = impulse * u - P.isFiniteOrThrow { + P.requireIsValid { "P is not finite, impulse: $impulse, u: $u, mass: $mass, C: $C" } diff --git a/src/main/kotlin/ru/dbotthepony/kbox2d/dynamics/joint/FrictionJoint.kt b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/dynamics/joint/FrictionJoint.kt similarity index 92% rename from src/main/kotlin/ru/dbotthepony/kbox2d/dynamics/joint/FrictionJoint.kt rename to src/kbox2d/kotlin/ru/dbotthepony/kbox2d/dynamics/joint/FrictionJoint.kt index 4c8de0b4..5460b6dd 100644 --- a/src/main/kotlin/ru/dbotthepony/kbox2d/dynamics/joint/FrictionJoint.kt +++ b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/dynamics/joint/FrictionJoint.kt @@ -3,9 +3,10 @@ package ru.dbotthepony.kbox2d.dynamics.joint import ru.dbotthepony.kbox2d.api.* import ru.dbotthepony.kbox2d.api.B2SolverData import ru.dbotthepony.kbox2d.api.b2Mul -import ru.dbotthepony.kstarbound.math.MutableMatrix2d -import ru.dbotthepony.kstarbound.math.Vector2d -import ru.dbotthepony.kstarbound.math.times +import ru.dbotthepony.kvector.matrix.ndouble.Matrix2d +import ru.dbotthepony.kvector.matrix.ndouble.MutableMatrix2d +import ru.dbotthepony.kvector.vector.ndouble.Vector2d +import ru.dbotthepony.kvector.vector.ndouble.times // Point-to-point constraint // Cdot = v2 - v1 @@ -101,12 +102,12 @@ class FrictionJoint(def: FrictionJointDef) : AbstractJoint(def) { val iB = this.invIB val K = MutableMatrix2d() - K.m00 = mA + mB + iA * this.rA.y * this.rA.y + iB * this.rB.y * this.rB.y - K.m10 = -iA * this.rA.x * this.rA.y - iB * this.rB.x * this.rB.y - K.m01 = K.m10 - K.m11 = mA + mB + iA * this.rA.x * this.rA.x + iB * this.rB.x * this.rB.x + K.r00 = mA + mB + iA * this.rA.y * this.rA.y + iB * this.rB.y * this.rB.y + K.r10 = -iA * this.rA.x * this.rA.y - iB * this.rB.x * this.rB.y + K.r01 = K.r10 + K.r11 = mA + mB + iA * this.rA.x * this.rA.x + iB * this.rB.x * this.rB.x - this.linearMass = K.getInverse().asMutableMatrix() + this.linearMass = (K.inverse ?: Matrix2d.ZERO).toMutableMatrix2d() this.angularMass = iA + iB if (this.angularMass > 0.0) { diff --git a/src/main/kotlin/ru/dbotthepony/kbox2d/dynamics/joint/GearJoint.kt b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/dynamics/joint/GearJoint.kt similarity index 99% rename from src/main/kotlin/ru/dbotthepony/kbox2d/dynamics/joint/GearJoint.kt rename to src/kbox2d/kotlin/ru/dbotthepony/kbox2d/dynamics/joint/GearJoint.kt index 006b1da0..7eaa836c 100644 --- a/src/main/kotlin/ru/dbotthepony/kbox2d/dynamics/joint/GearJoint.kt +++ b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/dynamics/joint/GearJoint.kt @@ -2,8 +2,8 @@ package ru.dbotthepony.kbox2d.dynamics.joint import ru.dbotthepony.kbox2d.api.* import ru.dbotthepony.kbox2d.dynamics.Body -import ru.dbotthepony.kstarbound.math.Vector2d -import ru.dbotthepony.kstarbound.math.times +import ru.dbotthepony.kvector.vector.ndouble.Vector2d +import ru.dbotthepony.kvector.vector.ndouble.times // Gear Joint: // C0 = (coordinate1 + ratio * coordinate2)_initial diff --git a/src/main/kotlin/ru/dbotthepony/kbox2d/dynamics/joint/MotorJoint.kt b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/dynamics/joint/MotorJoint.kt similarity index 92% rename from src/main/kotlin/ru/dbotthepony/kbox2d/dynamics/joint/MotorJoint.kt rename to src/kbox2d/kotlin/ru/dbotthepony/kbox2d/dynamics/joint/MotorJoint.kt index 929e0393..139838e3 100644 --- a/src/main/kotlin/ru/dbotthepony/kbox2d/dynamics/joint/MotorJoint.kt +++ b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/dynamics/joint/MotorJoint.kt @@ -3,9 +3,10 @@ package ru.dbotthepony.kbox2d.dynamics.joint import ru.dbotthepony.kbox2d.api.* import ru.dbotthepony.kbox2d.api.B2SolverData import ru.dbotthepony.kbox2d.api.b2Mul -import ru.dbotthepony.kstarbound.math.MutableMatrix2d -import ru.dbotthepony.kstarbound.math.Vector2d -import ru.dbotthepony.kstarbound.math.times +import ru.dbotthepony.kvector.matrix.ndouble.Matrix2d +import ru.dbotthepony.kvector.matrix.ndouble.MutableMatrix2d +import ru.dbotthepony.kvector.vector.ndouble.Vector2d +import ru.dbotthepony.kvector.vector.ndouble.times class MotorJoint(def: MotorJointDef) : AbstractJoint(def) { // Solver shared @@ -112,12 +113,12 @@ class MotorJoint(def: MotorJointDef) : AbstractJoint(def) { // Upper 2 by 2 of K for point to point val K = MutableMatrix2d() - K.m00 = mA + mB + iA * this.rA.y * this.rA.y + iB * this.rB.y * this.rB.y - K.m10 = -iA * this.rA.x * this.rA.y - iB * this.rB.x * this.rB.y - K.m01 = K.m10 - K.m11 = mA + mB + iA * this.rA.x * this.rA.x + iB * this.rB.x * this.rB.x + K.r00 = mA + mB + iA * this.rA.y * this.rA.y + iB * this.rB.y * this.rB.y + K.r10 = -iA * this.rA.x * this.rA.y - iB * this.rB.x * this.rB.y + K.r01 = K.r10 + K.r11 = mA + mB + iA * this.rA.x * this.rA.x + iB * this.rB.x * this.rB.x - this.linearMass = K.getInverse().asMutableMatrix() + this.linearMass = (K.inverse ?: Matrix2d.ZERO).toMutableMatrix2d() this.angularMass = iA + iB if (this.angularMass > 0.0) { diff --git a/src/main/kotlin/ru/dbotthepony/kbox2d/dynamics/joint/MouseJoint.kt b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/dynamics/joint/MouseJoint.kt similarity index 86% rename from src/main/kotlin/ru/dbotthepony/kbox2d/dynamics/joint/MouseJoint.kt rename to src/kbox2d/kotlin/ru/dbotthepony/kbox2d/dynamics/joint/MouseJoint.kt index c9cc2cd3..ffe3d456 100644 --- a/src/main/kotlin/ru/dbotthepony/kbox2d/dynamics/joint/MouseJoint.kt +++ b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/dynamics/joint/MouseJoint.kt @@ -3,9 +3,10 @@ package ru.dbotthepony.kbox2d.dynamics.joint import ru.dbotthepony.kbox2d.api.* import ru.dbotthepony.kbox2d.api.B2SolverData import ru.dbotthepony.kbox2d.api.b2MulT -import ru.dbotthepony.kstarbound.math.MutableMatrix2d -import ru.dbotthepony.kstarbound.math.Vector2d -import ru.dbotthepony.kstarbound.math.times +import ru.dbotthepony.kvector.matrix.ndouble.Matrix2d +import ru.dbotthepony.kvector.matrix.ndouble.MutableMatrix2d +import ru.dbotthepony.kvector.vector.ndouble.Vector2d +import ru.dbotthepony.kvector.vector.ndouble.times // p = attached point, m = mouse point // C = p - m @@ -19,7 +20,7 @@ class MouseJoint(def: MouseJointDef) : AbstractJoint(def) { private val localAnchorB: Vector2d = b2MulT(bodyB.transform, def.target) var targetA: Vector2d = def.target set(value) { - value.isFiniteOrThrow { "Tried to set illegal target $value" } + value.requireIsValid { "Tried to set illegal target $value" } field = value bodyB.isAwake = true } @@ -40,7 +41,7 @@ class MouseJoint(def: MouseJointDef) : AbstractJoint(def) { private var localCenterB: Vector2d = Vector2d.ZERO private var invMassB: Double = 0.0 private var invIB: Double = 0.0 - private var mass: MutableMatrix2d = MutableMatrix2d().also { it.zero() } + private var mass: MutableMatrix2d = MutableMatrix2d.zero() private var C: Vector2d = Vector2d.ZERO override fun initVelocityConstraints(data: B2SolverData) { @@ -78,12 +79,12 @@ class MouseJoint(def: MouseJointDef) : AbstractJoint(def) { // = [1/m1+1/m2 0 ] + invI1 * [r1.y*r1.y -r1.x*r1.y] + invI2 * [r1.y*r1.y -r1.x*r1.y] // [ 0 1/m1+1/m2] [-r1.x*r1.y r1.x*r1.x] [-r1.x*r1.y r1.x*r1.x] val K = MutableMatrix2d() - K.m00 = invMassB + invIB * rB.y * rB.y + gamma - K.m10 = -invIB * rB.x * rB.y - K.m01 = K.m10 - K.m11 = invMassB + invIB * rB.x * rB.x + gamma + K.r00 = invMassB + invIB * rB.y * rB.y + gamma + K.r10 = -invIB * rB.x * rB.y + K.r01 = K.r10 + K.r11 = invMassB + invIB * rB.x * rB.x + gamma - mass = K.getInverse().asMutableMatrix() + mass = (K.inverse ?: Matrix2d.ZERO).toMutableMatrix2d() C = cB + rB - targetA C *= beta diff --git a/src/main/kotlin/ru/dbotthepony/kbox2d/dynamics/joint/PrismaticJoint.kt b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/dynamics/joint/PrismaticJoint.kt similarity index 96% rename from src/main/kotlin/ru/dbotthepony/kbox2d/dynamics/joint/PrismaticJoint.kt rename to src/kbox2d/kotlin/ru/dbotthepony/kbox2d/dynamics/joint/PrismaticJoint.kt index af5b6459..fc402620 100644 --- a/src/main/kotlin/ru/dbotthepony/kbox2d/dynamics/joint/PrismaticJoint.kt +++ b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/dynamics/joint/PrismaticJoint.kt @@ -4,8 +4,12 @@ import ru.dbotthepony.kbox2d.api.* import ru.dbotthepony.kbox2d.api.B2SolverData import ru.dbotthepony.kbox2d.api.b2Cross import ru.dbotthepony.kbox2d.api.b2Mul -import ru.dbotthepony.kstarbound.math.* -import ru.dbotthepony.kstarbound.util.Color +import ru.dbotthepony.kvector.matrix.ndouble.MutableMatrix2d +import ru.dbotthepony.kvector.matrix.ndouble.MutableMatrix3d +import ru.dbotthepony.kvector.vector.Color +import ru.dbotthepony.kvector.vector.ndouble.Vector2d +import ru.dbotthepony.kvector.vector.ndouble.Vector3d +import ru.dbotthepony.kvector.vector.ndouble.times // Linear constraint (point-to-line) // d = p2 - p1 = x2 + r2 - x1 - r1 @@ -145,11 +149,11 @@ class PrismaticJoint(def: PrismaticJointDef) : AbstractJoint(def) { k22 = 1.0 } - this.K.m00 = k11 - this.K.m10 = k12 + this.K.r00 = k11 + this.K.r10 = k12 - this.K.m01 = k12 - this.K.m11 = k22 + this.K.r01 = k12 + this.K.r11 = k22 } if (enableLimit) { @@ -374,17 +378,17 @@ class PrismaticJoint(def: PrismaticJointDef) : AbstractJoint(def) { val K = MutableMatrix3d() - K.m00 = k11 - K.m10 = k12 - K.m20 = k13 + K.r00 = k11 + K.r10 = k12 + K.r20 = k13 - K.m01 = k12 - K.m11 = k22 - K.m21 = k23 + K.r01 = k12 + K.r11 = k22 + K.r21 = k23 - K.m02 = k13 - K.m12 = k23 - K.m22 = k33 + K.r02 = k13 + K.r12 = k23 + K.r22 = k33 val C = Vector3d( x = C1.x, @@ -404,11 +408,11 @@ class PrismaticJoint(def: PrismaticJointDef) : AbstractJoint(def) { val K = MutableMatrix2d() - K.m00 = k11 - K.m10 = k12 + K.r00 = k11 + K.r10 = k12 - K.m01 = k12 - K.m11 = k22 + K.r01 = k12 + K.r11 = k22 val impulse1 = K.solve(-C1) impulse = Vector3d(impulse1.x, impulse1.y) diff --git a/src/main/kotlin/ru/dbotthepony/kbox2d/dynamics/joint/PulleyJoint.kt b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/dynamics/joint/PulleyJoint.kt similarity index 98% rename from src/main/kotlin/ru/dbotthepony/kbox2d/dynamics/joint/PulleyJoint.kt rename to src/kbox2d/kotlin/ru/dbotthepony/kbox2d/dynamics/joint/PulleyJoint.kt index 6c9c5e02..06288592 100644 --- a/src/main/kotlin/ru/dbotthepony/kbox2d/dynamics/joint/PulleyJoint.kt +++ b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/dynamics/joint/PulleyJoint.kt @@ -3,8 +3,8 @@ package ru.dbotthepony.kbox2d.dynamics.joint import ru.dbotthepony.kbox2d.api.* import ru.dbotthepony.kbox2d.api.B2SolverData import ru.dbotthepony.kbox2d.api.b2Mul -import ru.dbotthepony.kstarbound.math.Vector2d -import ru.dbotthepony.kstarbound.math.times +import ru.dbotthepony.kvector.vector.ndouble.Vector2d +import ru.dbotthepony.kvector.vector.ndouble.times /** * The pulley joint is connected to two bodies and two fixed ground points. diff --git a/src/main/kotlin/ru/dbotthepony/kbox2d/dynamics/joint/RevoluteJoint.kt b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/dynamics/joint/RevoluteJoint.kt similarity index 94% rename from src/main/kotlin/ru/dbotthepony/kbox2d/dynamics/joint/RevoluteJoint.kt rename to src/kbox2d/kotlin/ru/dbotthepony/kbox2d/dynamics/joint/RevoluteJoint.kt index 394e558b..48fea0b2 100644 --- a/src/main/kotlin/ru/dbotthepony/kbox2d/dynamics/joint/RevoluteJoint.kt +++ b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/dynamics/joint/RevoluteJoint.kt @@ -3,10 +3,10 @@ package ru.dbotthepony.kbox2d.dynamics.joint import ru.dbotthepony.kbox2d.api.* import ru.dbotthepony.kbox2d.api.B2SolverData import ru.dbotthepony.kbox2d.api.b2Mul -import ru.dbotthepony.kstarbound.math.MutableMatrix2d -import ru.dbotthepony.kstarbound.math.Vector2d -import ru.dbotthepony.kstarbound.math.times -import ru.dbotthepony.kstarbound.util.Color +import ru.dbotthepony.kvector.matrix.ndouble.MutableMatrix2d +import ru.dbotthepony.kvector.vector.Color +import ru.dbotthepony.kvector.vector.ndouble.Vector2d +import ru.dbotthepony.kvector.vector.ndouble.times import kotlin.math.cos import kotlin.math.sin @@ -44,7 +44,7 @@ class RevoluteJoint(def: RevoluteJointDef) : AbstractJoint(def) { private var invMassB: Double = 0.0 private var invIA: Double = 0.0 private var invIB: Double = 0.0 - private var K: MutableMatrix2d = MutableMatrix2d().also { it.zero() } + private var K: MutableMatrix2d = MutableMatrix2d.zero() private var angle: Double = 0.0 private var axialMass: Double = 0.0 @@ -84,10 +84,10 @@ class RevoluteJoint(def: RevoluteJointDef) : AbstractJoint(def) { val iA = invIA val iB = invIB - K.m00 = mA + mB + rA.y * rA.y * iA + rB.y * rB.y * iB - K.m01 = -rA.y * rA.x * iA - rB.y * rB.x * iB - K.m10 = K.m01 - K.m11 = mA + mB + rA.x * rA.x * iA + rB.x * rB.x * iB + K.r00 = mA + mB + rA.y * rA.y * iA + rB.y * rB.y * iB + K.r01 = -rA.y * rA.x * iA - rB.y * rB.x * iB + K.r10 = K.r01 + K.r11 = mA + mB + rA.x * rA.x * iA + rB.x * rB.x * iB axialMass = iA + iB val fixedRotation: Boolean @@ -266,10 +266,10 @@ class RevoluteJoint(def: RevoluteJointDef) : AbstractJoint(def) { val iB = this.invIB val K = MutableMatrix2d() - K.m00 = mA + mB + iA * rA.y * rA.y + iB * rB.y * rB.y - K.m10 = -iA * rA.x * rA.y - iB * rB.x * rB.y - K.m01 = K.m10 - K.m11 = mA + mB + iA * rA.x * rA.x + iB * rB.x * rB.x + K.r00 = mA + mB + iA * rA.y * rA.y + iB * rB.y * rB.y + K.r10 = -iA * rA.x * rA.y - iB * rB.x * rB.y + K.r01 = K.r10 + K.r11 = mA + mB + iA * rA.x * rA.x + iB * rB.x * rB.x val impulse = -K.solve(C) diff --git a/src/main/kotlin/ru/dbotthepony/kbox2d/dynamics/joint/WeldJoint.kt b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/dynamics/joint/WeldJoint.kt similarity index 81% rename from src/main/kotlin/ru/dbotthepony/kbox2d/dynamics/joint/WeldJoint.kt rename to src/kbox2d/kotlin/ru/dbotthepony/kbox2d/dynamics/joint/WeldJoint.kt index bcafe22a..1233dd6d 100644 --- a/src/main/kotlin/ru/dbotthepony/kbox2d/dynamics/joint/WeldJoint.kt +++ b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/dynamics/joint/WeldJoint.kt @@ -3,7 +3,12 @@ package ru.dbotthepony.kbox2d.dynamics.joint import ru.dbotthepony.kbox2d.api.* import ru.dbotthepony.kbox2d.api.B2SolverData import ru.dbotthepony.kbox2d.api.b2Mul -import ru.dbotthepony.kstarbound.math.* +import ru.dbotthepony.kvector.matrix.ndouble.Matrix2d +import ru.dbotthepony.kvector.matrix.ndouble.Matrix3d +import ru.dbotthepony.kvector.matrix.ndouble.MutableMatrix3d +import ru.dbotthepony.kvector.vector.ndouble.Vector2d +import ru.dbotthepony.kvector.vector.ndouble.Vector3d +import ru.dbotthepony.kvector.vector.ndouble.times class WeldJoint(def: WeldJointDef) : AbstractJoint(def) { var stiffness: Double = def.stiffness @@ -28,7 +33,7 @@ class WeldJoint(def: WeldJointDef) : AbstractJoint(def) { private var invMassB: Double = 0.0 private var invIA: Double = 0.0 private var invIB: Double = 0.0 - private var mass: MutableMatrix3d = MutableMatrix3d().also { it.zero() } + private var mass: MutableMatrix3d = MutableMatrix3d.zero() override fun initVelocityConstraints(data: B2SolverData) { this.indexA = this.bodyA.islandIndex @@ -69,20 +74,20 @@ class WeldJoint(def: WeldJointDef) : AbstractJoint(def) { val iB = this.invIB val K = MutableMatrix3d() - K.m00 = mA + mB + this.rA.y * this.rA.y * iA + this.rB.y * this.rB.y * iB - K.m01 = -this.rA.y * this.rA.x * iA - this.rB.y * this.rB.x * iB - K.m02 = -this.rA.y * iA - this.rB.y * iB + K.r00 = mA + mB + this.rA.y * this.rA.y * iA + this.rB.y * this.rB.y * iB + K.r01 = -this.rA.y * this.rA.x * iA - this.rB.y * this.rB.x * iB + K.r02 = -this.rA.y * iA - this.rB.y * iB - K.m10 = K.m01 - K.m11 = mA + mB + this.rA.x * this.rA.x * iA + this.rB.x * this.rB.x * iB - K.m12 = this.rA.x * iA + this.rB.x * iB + K.r10 = K.r01 + K.r11 = mA + mB + this.rA.x * this.rA.x * iA + this.rB.x * this.rB.x * iB + K.r12 = this.rA.x * iA + this.rB.x * iB - K.m20 = K.m02 - K.m21 = K.m12 - K.m22 = iA + iB + K.r20 = K.r02 + K.r21 = K.r12 + K.r22 = iA + iB if (this.stiffness > 0.0) { - this.mass = K.getInverse2().asMutableMatrix() + this.mass = K.toMatrix2d().inverse?.toMutableMatrix3d() ?: MutableMatrix3d.zero() var invM = iA + iB @@ -101,13 +106,13 @@ class WeldJoint(def: WeldJointDef) : AbstractJoint(def) { this.bias = C * h * k * this.gamma invM += this.gamma - this.mass.m22 = if (invM != 0.0) 1.0 / invM else 0.0 - } else if (K.m22 == 0.0) { - this.mass = K.getInverse2().asMutableMatrix() + this.mass.r22 = if (invM != 0.0) 1.0 / invM else 0.0 + } else if (K.r22 == 0.0) { + this.mass = K.toMatrix2d().inverse?.toMutableMatrix3d() ?: MutableMatrix3d.zero() this.gamma = 0.0 this.bias = 0.0 } else { - this.mass = K.getInverse().asMutableMatrix() + this.mass = K.inverse?.toMutableMatrix3d() ?: MutableMatrix3d.zero() this.gamma = 0.0 this.bias = 0.0 } @@ -147,7 +152,7 @@ class WeldJoint(def: WeldJointDef) : AbstractJoint(def) { if (this.stiffness > 0.0) { val Cdot2 = wB - wA - val impulse2 = -this.mass.m22 * (Cdot2 + this.bias + this.gamma * this.impulse.z) + val impulse2 = -this.mass.r22 * (Cdot2 + this.bias + this.gamma * this.impulse.z) this.impulse += Vector3d(z = impulse2) wA -= iA * impulse2 @@ -209,15 +214,15 @@ class WeldJoint(def: WeldJointDef) : AbstractJoint(def) { val angularError: Double val K = MutableMatrix3d() - K.m00 = mA + mB + rA.y * rA.y * iA + rB.y * rB.y * iB - K.m01 = -rA.y * rA.x * iA - rB.y * rB.x * iB - K.m02 = -rA.y * iA - rB.y * iB - K.m10 = K.m01 - K.m11 = mA + mB + rA.x * rA.x * iA + rB.x * rB.x * iB - K.m12 = rA.x * iA + rB.x * iB - K.m20 = K.m02 - K.m21 = K.m12 - K.m22 = iA + iB + K.r00 = mA + mB + rA.y * rA.y * iA + rB.y * rB.y * iB + K.r01 = -rA.y * rA.x * iA - rB.y * rB.x * iB + K.r02 = -rA.y * iA - rB.y * iB + K.r10 = K.r01 + K.r11 = mA + mB + rA.x * rA.x * iA + rB.x * rB.x * iB + K.r12 = rA.x * iA + rB.x * iB + K.r20 = K.r02 + K.r21 = K.r12 + K.r22 = iA + iB if (this.stiffness > 0.0f) { val C1 = cB + rB - cA - rA @@ -242,7 +247,7 @@ class WeldJoint(def: WeldJointDef) : AbstractJoint(def) { val C = Vector3d(C1.x, C1.y, C2) val impulse: Vector3d - if (K.m22 > 0.0) { + if (K.r22 > 0.0) { impulse = -K.solve(C) } else { val impulse2 = -K.solve(C1) diff --git a/src/main/kotlin/ru/dbotthepony/kbox2d/dynamics/joint/WheelJoint.kt b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/dynamics/joint/WheelJoint.kt similarity index 98% rename from src/main/kotlin/ru/dbotthepony/kbox2d/dynamics/joint/WheelJoint.kt rename to src/kbox2d/kotlin/ru/dbotthepony/kbox2d/dynamics/joint/WheelJoint.kt index 93096f16..9dfd6d27 100644 --- a/src/main/kotlin/ru/dbotthepony/kbox2d/dynamics/joint/WheelJoint.kt +++ b/src/kbox2d/kotlin/ru/dbotthepony/kbox2d/dynamics/joint/WheelJoint.kt @@ -3,9 +3,9 @@ package ru.dbotthepony.kbox2d.dynamics.joint import ru.dbotthepony.kbox2d.api.* import ru.dbotthepony.kbox2d.api.B2SolverData import ru.dbotthepony.kbox2d.api.b2Cross -import ru.dbotthepony.kstarbound.math.Vector2d -import ru.dbotthepony.kstarbound.math.times -import ru.dbotthepony.kstarbound.util.Color +import ru.dbotthepony.kvector.vector.Color +import ru.dbotthepony.kvector.vector.ndouble.Vector2d +import ru.dbotthepony.kvector.vector.ndouble.times class WheelJoint(def: WheelJointDef) : AbstractJoint(def) { val localAnchorA: Vector2d = def.localAnchorA diff --git a/src/kvector/java/ru/dbotthepony/kvector/matrix/generated/MultiplicationsByte.java b/src/kvector/java/ru/dbotthepony/kvector/matrix/generated/MultiplicationsByte.java index 5d873d7f..1eac7061 100644 --- a/src/kvector/java/ru/dbotthepony/kvector/matrix/generated/MultiplicationsByte.java +++ b/src/kvector/java/ru/dbotthepony/kvector/matrix/generated/MultiplicationsByte.java @@ -3,7 +3,6 @@ package ru.dbotthepony.kvector.matrix.generated; import ru.dbotthepony.kvector.api.*; import ru.dbotthepony.kvector.narray.*; -// Some metaprogramming ///////////////////////////////// // THIS FILE IS AUTO GENERATED // // DO NOT EDIT // @@ -11,2775 +10,4218 @@ import ru.dbotthepony.kvector.narray.*; public final class MultiplicationsByte { private MultiplicationsByte() {} + private static IMatrixSetterByte multiplyMatrix1x1x1(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte s00 = matrix2.get(0, 0); + output.set(0, 0, (byte) (f00 * s00)); + return output; + } + + private static IMatrixSetterByte multiplyMatrix1x1x2(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + output.set(0, 0, (byte) (f00 * s00)); + output.set(1, 0, (byte) (f00 * s10)); + return output; + } + + private static IMatrixSetterByte multiplyMatrix1x1x3(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + output.set(0, 0, (byte) (f00 * s00)); + output.set(1, 0, (byte) (f00 * s10)); + output.set(2, 0, (byte) (f00 * s20)); + return output; + } + + private static IMatrixSetterByte multiplyMatrix1x1x4(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + final byte s30 = matrix2.get(3, 0); + output.set(0, 0, (byte) (f00 * s00)); + output.set(1, 0, (byte) (f00 * s10)); + output.set(2, 0, (byte) (f00 * s20)); + output.set(3, 0, (byte) (f00 * s30)); + return output; + } + + private static IMatrixSetterByte multiplyMatrix1x1x5(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + final byte s30 = matrix2.get(3, 0); + final byte s40 = matrix2.get(4, 0); + output.set(0, 0, (byte) (f00 * s00)); + output.set(1, 0, (byte) (f00 * s10)); + output.set(2, 0, (byte) (f00 * s20)); + output.set(3, 0, (byte) (f00 * s30)); + output.set(4, 0, (byte) (f00 * s40)); + return output; + } + + private static IMatrixSetterByte multiplyMatrix2x1x1(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f01 = matrix1.get(0, 1); + final byte s00 = matrix2.get(0, 0); + output.set(0, 0, (byte) (f00 * s00)); + output.set(0, 1, (byte) (f01 * s00)); + return output; + } + + private static IMatrixSetterByte multiplyMatrix2x1x2(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f01 = matrix1.get(0, 1); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + output.set(0, 0, (byte) (f00 * s00)); + output.set(1, 0, (byte) (f00 * s10)); + output.set(0, 1, (byte) (f01 * s00)); + output.set(1, 1, (byte) (f01 * s10)); + return output; + } + + private static IMatrixSetterByte multiplyMatrix2x1x3(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f01 = matrix1.get(0, 1); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + output.set(0, 0, (byte) (f00 * s00)); + output.set(1, 0, (byte) (f00 * s10)); + output.set(2, 0, (byte) (f00 * s20)); + output.set(0, 1, (byte) (f01 * s00)); + output.set(1, 1, (byte) (f01 * s10)); + output.set(2, 1, (byte) (f01 * s20)); + return output; + } + + private static IMatrixSetterByte multiplyMatrix2x1x4(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f01 = matrix1.get(0, 1); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + final byte s30 = matrix2.get(3, 0); + output.set(0, 0, (byte) (f00 * s00)); + output.set(1, 0, (byte) (f00 * s10)); + output.set(2, 0, (byte) (f00 * s20)); + output.set(3, 0, (byte) (f00 * s30)); + output.set(0, 1, (byte) (f01 * s00)); + output.set(1, 1, (byte) (f01 * s10)); + output.set(2, 1, (byte) (f01 * s20)); + output.set(3, 1, (byte) (f01 * s30)); + return output; + } + + private static IMatrixSetterByte multiplyMatrix2x1x5(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f01 = matrix1.get(0, 1); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + final byte s30 = matrix2.get(3, 0); + final byte s40 = matrix2.get(4, 0); + output.set(0, 0, (byte) (f00 * s00)); + output.set(1, 0, (byte) (f00 * s10)); + output.set(2, 0, (byte) (f00 * s20)); + output.set(3, 0, (byte) (f00 * s30)); + output.set(4, 0, (byte) (f00 * s40)); + output.set(0, 1, (byte) (f01 * s00)); + output.set(1, 1, (byte) (f01 * s10)); + output.set(2, 1, (byte) (f01 * s20)); + output.set(3, 1, (byte) (f01 * s30)); + output.set(4, 1, (byte) (f01 * s40)); + return output; + } + + private static IMatrixSetterByte multiplyMatrix3x1x1(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f01 = matrix1.get(0, 1); + final byte f02 = matrix1.get(0, 2); + final byte s00 = matrix2.get(0, 0); + output.set(0, 0, (byte) (f00 * s00)); + output.set(0, 1, (byte) (f01 * s00)); + output.set(0, 2, (byte) (f02 * s00)); + return output; + } + + private static IMatrixSetterByte multiplyMatrix3x1x2(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f01 = matrix1.get(0, 1); + final byte f02 = matrix1.get(0, 2); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + output.set(0, 0, (byte) (f00 * s00)); + output.set(1, 0, (byte) (f00 * s10)); + output.set(0, 1, (byte) (f01 * s00)); + output.set(1, 1, (byte) (f01 * s10)); + output.set(0, 2, (byte) (f02 * s00)); + output.set(1, 2, (byte) (f02 * s10)); + return output; + } + + private static IMatrixSetterByte multiplyMatrix3x1x3(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f01 = matrix1.get(0, 1); + final byte f02 = matrix1.get(0, 2); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + output.set(0, 0, (byte) (f00 * s00)); + output.set(1, 0, (byte) (f00 * s10)); + output.set(2, 0, (byte) (f00 * s20)); + output.set(0, 1, (byte) (f01 * s00)); + output.set(1, 1, (byte) (f01 * s10)); + output.set(2, 1, (byte) (f01 * s20)); + output.set(0, 2, (byte) (f02 * s00)); + output.set(1, 2, (byte) (f02 * s10)); + output.set(2, 2, (byte) (f02 * s20)); + return output; + } + + private static IMatrixSetterByte multiplyMatrix3x1x4(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f01 = matrix1.get(0, 1); + final byte f02 = matrix1.get(0, 2); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + final byte s30 = matrix2.get(3, 0); + output.set(0, 0, (byte) (f00 * s00)); + output.set(1, 0, (byte) (f00 * s10)); + output.set(2, 0, (byte) (f00 * s20)); + output.set(3, 0, (byte) (f00 * s30)); + output.set(0, 1, (byte) (f01 * s00)); + output.set(1, 1, (byte) (f01 * s10)); + output.set(2, 1, (byte) (f01 * s20)); + output.set(3, 1, (byte) (f01 * s30)); + output.set(0, 2, (byte) (f02 * s00)); + output.set(1, 2, (byte) (f02 * s10)); + output.set(2, 2, (byte) (f02 * s20)); + output.set(3, 2, (byte) (f02 * s30)); + return output; + } + + private static IMatrixSetterByte multiplyMatrix3x1x5(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f01 = matrix1.get(0, 1); + final byte f02 = matrix1.get(0, 2); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + final byte s30 = matrix2.get(3, 0); + final byte s40 = matrix2.get(4, 0); + output.set(0, 0, (byte) (f00 * s00)); + output.set(1, 0, (byte) (f00 * s10)); + output.set(2, 0, (byte) (f00 * s20)); + output.set(3, 0, (byte) (f00 * s30)); + output.set(4, 0, (byte) (f00 * s40)); + output.set(0, 1, (byte) (f01 * s00)); + output.set(1, 1, (byte) (f01 * s10)); + output.set(2, 1, (byte) (f01 * s20)); + output.set(3, 1, (byte) (f01 * s30)); + output.set(4, 1, (byte) (f01 * s40)); + output.set(0, 2, (byte) (f02 * s00)); + output.set(1, 2, (byte) (f02 * s10)); + output.set(2, 2, (byte) (f02 * s20)); + output.set(3, 2, (byte) (f02 * s30)); + output.set(4, 2, (byte) (f02 * s40)); + return output; + } + + private static IMatrixSetterByte multiplyMatrix4x1x1(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f01 = matrix1.get(0, 1); + final byte f02 = matrix1.get(0, 2); + final byte f03 = matrix1.get(0, 3); + final byte s00 = matrix2.get(0, 0); + output.set(0, 0, (byte) (f00 * s00)); + output.set(0, 1, (byte) (f01 * s00)); + output.set(0, 2, (byte) (f02 * s00)); + output.set(0, 3, (byte) (f03 * s00)); + return output; + } + + private static IMatrixSetterByte multiplyMatrix4x1x2(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f01 = matrix1.get(0, 1); + final byte f02 = matrix1.get(0, 2); + final byte f03 = matrix1.get(0, 3); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + output.set(0, 0, (byte) (f00 * s00)); + output.set(1, 0, (byte) (f00 * s10)); + output.set(0, 1, (byte) (f01 * s00)); + output.set(1, 1, (byte) (f01 * s10)); + output.set(0, 2, (byte) (f02 * s00)); + output.set(1, 2, (byte) (f02 * s10)); + output.set(0, 3, (byte) (f03 * s00)); + output.set(1, 3, (byte) (f03 * s10)); + return output; + } + + private static IMatrixSetterByte multiplyMatrix4x1x3(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f01 = matrix1.get(0, 1); + final byte f02 = matrix1.get(0, 2); + final byte f03 = matrix1.get(0, 3); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + output.set(0, 0, (byte) (f00 * s00)); + output.set(1, 0, (byte) (f00 * s10)); + output.set(2, 0, (byte) (f00 * s20)); + output.set(0, 1, (byte) (f01 * s00)); + output.set(1, 1, (byte) (f01 * s10)); + output.set(2, 1, (byte) (f01 * s20)); + output.set(0, 2, (byte) (f02 * s00)); + output.set(1, 2, (byte) (f02 * s10)); + output.set(2, 2, (byte) (f02 * s20)); + output.set(0, 3, (byte) (f03 * s00)); + output.set(1, 3, (byte) (f03 * s10)); + output.set(2, 3, (byte) (f03 * s20)); + return output; + } + + private static IMatrixSetterByte multiplyMatrix4x1x4(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f01 = matrix1.get(0, 1); + final byte f02 = matrix1.get(0, 2); + final byte f03 = matrix1.get(0, 3); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + final byte s30 = matrix2.get(3, 0); + output.set(0, 0, (byte) (f00 * s00)); + output.set(1, 0, (byte) (f00 * s10)); + output.set(2, 0, (byte) (f00 * s20)); + output.set(3, 0, (byte) (f00 * s30)); + output.set(0, 1, (byte) (f01 * s00)); + output.set(1, 1, (byte) (f01 * s10)); + output.set(2, 1, (byte) (f01 * s20)); + output.set(3, 1, (byte) (f01 * s30)); + output.set(0, 2, (byte) (f02 * s00)); + output.set(1, 2, (byte) (f02 * s10)); + output.set(2, 2, (byte) (f02 * s20)); + output.set(3, 2, (byte) (f02 * s30)); + output.set(0, 3, (byte) (f03 * s00)); + output.set(1, 3, (byte) (f03 * s10)); + output.set(2, 3, (byte) (f03 * s20)); + output.set(3, 3, (byte) (f03 * s30)); + return output; + } + + private static IMatrixSetterByte multiplyMatrix4x1x5(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f01 = matrix1.get(0, 1); + final byte f02 = matrix1.get(0, 2); + final byte f03 = matrix1.get(0, 3); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + final byte s30 = matrix2.get(3, 0); + final byte s40 = matrix2.get(4, 0); + output.set(0, 0, (byte) (f00 * s00)); + output.set(1, 0, (byte) (f00 * s10)); + output.set(2, 0, (byte) (f00 * s20)); + output.set(3, 0, (byte) (f00 * s30)); + output.set(4, 0, (byte) (f00 * s40)); + output.set(0, 1, (byte) (f01 * s00)); + output.set(1, 1, (byte) (f01 * s10)); + output.set(2, 1, (byte) (f01 * s20)); + output.set(3, 1, (byte) (f01 * s30)); + output.set(4, 1, (byte) (f01 * s40)); + output.set(0, 2, (byte) (f02 * s00)); + output.set(1, 2, (byte) (f02 * s10)); + output.set(2, 2, (byte) (f02 * s20)); + output.set(3, 2, (byte) (f02 * s30)); + output.set(4, 2, (byte) (f02 * s40)); + output.set(0, 3, (byte) (f03 * s00)); + output.set(1, 3, (byte) (f03 * s10)); + output.set(2, 3, (byte) (f03 * s20)); + output.set(3, 3, (byte) (f03 * s30)); + output.set(4, 3, (byte) (f03 * s40)); + return output; + } + + private static IMatrixSetterByte multiplyMatrix5x1x1(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f01 = matrix1.get(0, 1); + final byte f02 = matrix1.get(0, 2); + final byte f03 = matrix1.get(0, 3); + final byte f04 = matrix1.get(0, 4); + final byte s00 = matrix2.get(0, 0); + output.set(0, 0, (byte) (f00 * s00)); + output.set(0, 1, (byte) (f01 * s00)); + output.set(0, 2, (byte) (f02 * s00)); + output.set(0, 3, (byte) (f03 * s00)); + output.set(0, 4, (byte) (f04 * s00)); + return output; + } + + private static IMatrixSetterByte multiplyMatrix5x1x2(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f01 = matrix1.get(0, 1); + final byte f02 = matrix1.get(0, 2); + final byte f03 = matrix1.get(0, 3); + final byte f04 = matrix1.get(0, 4); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + output.set(0, 0, (byte) (f00 * s00)); + output.set(1, 0, (byte) (f00 * s10)); + output.set(0, 1, (byte) (f01 * s00)); + output.set(1, 1, (byte) (f01 * s10)); + output.set(0, 2, (byte) (f02 * s00)); + output.set(1, 2, (byte) (f02 * s10)); + output.set(0, 3, (byte) (f03 * s00)); + output.set(1, 3, (byte) (f03 * s10)); + output.set(0, 4, (byte) (f04 * s00)); + output.set(1, 4, (byte) (f04 * s10)); + return output; + } + + private static IMatrixSetterByte multiplyMatrix5x1x3(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f01 = matrix1.get(0, 1); + final byte f02 = matrix1.get(0, 2); + final byte f03 = matrix1.get(0, 3); + final byte f04 = matrix1.get(0, 4); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + output.set(0, 0, (byte) (f00 * s00)); + output.set(1, 0, (byte) (f00 * s10)); + output.set(2, 0, (byte) (f00 * s20)); + output.set(0, 1, (byte) (f01 * s00)); + output.set(1, 1, (byte) (f01 * s10)); + output.set(2, 1, (byte) (f01 * s20)); + output.set(0, 2, (byte) (f02 * s00)); + output.set(1, 2, (byte) (f02 * s10)); + output.set(2, 2, (byte) (f02 * s20)); + output.set(0, 3, (byte) (f03 * s00)); + output.set(1, 3, (byte) (f03 * s10)); + output.set(2, 3, (byte) (f03 * s20)); + output.set(0, 4, (byte) (f04 * s00)); + output.set(1, 4, (byte) (f04 * s10)); + output.set(2, 4, (byte) (f04 * s20)); + return output; + } + + private static IMatrixSetterByte multiplyMatrix5x1x4(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f01 = matrix1.get(0, 1); + final byte f02 = matrix1.get(0, 2); + final byte f03 = matrix1.get(0, 3); + final byte f04 = matrix1.get(0, 4); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + final byte s30 = matrix2.get(3, 0); + output.set(0, 0, (byte) (f00 * s00)); + output.set(1, 0, (byte) (f00 * s10)); + output.set(2, 0, (byte) (f00 * s20)); + output.set(3, 0, (byte) (f00 * s30)); + output.set(0, 1, (byte) (f01 * s00)); + output.set(1, 1, (byte) (f01 * s10)); + output.set(2, 1, (byte) (f01 * s20)); + output.set(3, 1, (byte) (f01 * s30)); + output.set(0, 2, (byte) (f02 * s00)); + output.set(1, 2, (byte) (f02 * s10)); + output.set(2, 2, (byte) (f02 * s20)); + output.set(3, 2, (byte) (f02 * s30)); + output.set(0, 3, (byte) (f03 * s00)); + output.set(1, 3, (byte) (f03 * s10)); + output.set(2, 3, (byte) (f03 * s20)); + output.set(3, 3, (byte) (f03 * s30)); + output.set(0, 4, (byte) (f04 * s00)); + output.set(1, 4, (byte) (f04 * s10)); + output.set(2, 4, (byte) (f04 * s20)); + output.set(3, 4, (byte) (f04 * s30)); + return output; + } + + private static IMatrixSetterByte multiplyMatrix5x1x5(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f01 = matrix1.get(0, 1); + final byte f02 = matrix1.get(0, 2); + final byte f03 = matrix1.get(0, 3); + final byte f04 = matrix1.get(0, 4); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + final byte s30 = matrix2.get(3, 0); + final byte s40 = matrix2.get(4, 0); + output.set(0, 0, (byte) (f00 * s00)); + output.set(1, 0, (byte) (f00 * s10)); + output.set(2, 0, (byte) (f00 * s20)); + output.set(3, 0, (byte) (f00 * s30)); + output.set(4, 0, (byte) (f00 * s40)); + output.set(0, 1, (byte) (f01 * s00)); + output.set(1, 1, (byte) (f01 * s10)); + output.set(2, 1, (byte) (f01 * s20)); + output.set(3, 1, (byte) (f01 * s30)); + output.set(4, 1, (byte) (f01 * s40)); + output.set(0, 2, (byte) (f02 * s00)); + output.set(1, 2, (byte) (f02 * s10)); + output.set(2, 2, (byte) (f02 * s20)); + output.set(3, 2, (byte) (f02 * s30)); + output.set(4, 2, (byte) (f02 * s40)); + output.set(0, 3, (byte) (f03 * s00)); + output.set(1, 3, (byte) (f03 * s10)); + output.set(2, 3, (byte) (f03 * s20)); + output.set(3, 3, (byte) (f03 * s30)); + output.set(4, 3, (byte) (f03 * s40)); + output.set(0, 4, (byte) (f04 * s00)); + output.set(1, 4, (byte) (f04 * s10)); + output.set(2, 4, (byte) (f04 * s20)); + output.set(3, 4, (byte) (f04 * s30)); + output.set(4, 4, (byte) (f04 * s40)); + return output; + } + + private static IMatrixSetterByte multiplyMatrix1x2x1(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte s00 = matrix2.get(0, 0); + final byte s01 = matrix2.get(0, 1); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01)); + return output; + } + + private static IMatrixSetterByte multiplyMatrix1x2x2(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11)); + return output; + } + + private static IMatrixSetterByte multiplyMatrix1x2x3(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s21 = matrix2.get(2, 1); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11)); + output.set(2, 0, (byte) (f00 * s20 + f10 * s21)); + return output; + } + + private static IMatrixSetterByte multiplyMatrix1x2x4(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + final byte s30 = matrix2.get(3, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s21 = matrix2.get(2, 1); + final byte s31 = matrix2.get(3, 1); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11)); + output.set(2, 0, (byte) (f00 * s20 + f10 * s21)); + output.set(3, 0, (byte) (f00 * s30 + f10 * s31)); + return output; + } + + private static IMatrixSetterByte multiplyMatrix1x2x5(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + final byte s30 = matrix2.get(3, 0); + final byte s40 = matrix2.get(4, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s21 = matrix2.get(2, 1); + final byte s31 = matrix2.get(3, 1); + final byte s41 = matrix2.get(4, 1); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11)); + output.set(2, 0, (byte) (f00 * s20 + f10 * s21)); + output.set(3, 0, (byte) (f00 * s30 + f10 * s31)); + output.set(4, 0, (byte) (f00 * s40 + f10 * s41)); + return output; + } + + private static IMatrixSetterByte multiplyMatrix2x2x1(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte s00 = matrix2.get(0, 0); + final byte s01 = matrix2.get(0, 1); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01)); + return output; + } private static IMatrixSetterByte multiplyMatrix2x2x2(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final byte f_c00 = matrix1.get(0, 0); - final byte f_c10 = matrix1.get(1, 0); - final byte f_c01 = matrix1.get(0, 1); - final byte f_c11 = matrix1.get(1, 1); - final byte s_c00 = matrix2.get(0, 0); - final byte s_c10 = matrix2.get(1, 0); - final byte s_c01 = matrix2.get(0, 1); - final byte s_c11 = matrix2.get(1, 1); - output.set(0, 0, (byte) (f_c00*s_c00 + f_c10*s_c01)); - output.set(0, 1, (byte) (f_c01*s_c00 + f_c11*s_c01)); - output.set(1, 0, (byte) (f_c00*s_c10 + f_c10*s_c11)); - output.set(1, 1, (byte) (f_c01*s_c10 + f_c11*s_c11)); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01)); + output.set(1, 1, (byte) (f01 * s10 + f11 * s11)); return output; } private static IMatrixSetterByte multiplyMatrix2x2x3(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final byte f_c00 = matrix1.get(0, 0); - final byte f_c10 = matrix1.get(1, 0); - final byte f_c01 = matrix1.get(0, 1); - final byte f_c11 = matrix1.get(1, 1); - final byte s_c00 = matrix2.get(0, 0); - final byte s_c10 = matrix2.get(1, 0); - final byte s_c20 = matrix2.get(2, 0); - final byte s_c01 = matrix2.get(0, 1); - final byte s_c11 = matrix2.get(1, 1); - final byte s_c21 = matrix2.get(2, 1); - output.set(0, 0, (byte) (f_c00*s_c00 + f_c10*s_c01)); - output.set(0, 1, (byte) (f_c01*s_c00 + f_c11*s_c01)); - output.set(1, 0, (byte) (f_c00*s_c10 + f_c10*s_c11)); - output.set(1, 1, (byte) (f_c01*s_c10 + f_c11*s_c11)); - output.set(2, 0, (byte) (f_c00*s_c20 + f_c10*s_c21)); - output.set(2, 1, (byte) (f_c01*s_c20 + f_c11*s_c21)); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s21 = matrix2.get(2, 1); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11)); + output.set(2, 0, (byte) (f00 * s20 + f10 * s21)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01)); + output.set(1, 1, (byte) (f01 * s10 + f11 * s11)); + output.set(2, 1, (byte) (f01 * s20 + f11 * s21)); return output; } private static IMatrixSetterByte multiplyMatrix2x2x4(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final byte f_c00 = matrix1.get(0, 0); - final byte f_c10 = matrix1.get(1, 0); - final byte f_c01 = matrix1.get(0, 1); - final byte f_c11 = matrix1.get(1, 1); - final byte s_c00 = matrix2.get(0, 0); - final byte s_c10 = matrix2.get(1, 0); - final byte s_c20 = matrix2.get(2, 0); - final byte s_c30 = matrix2.get(3, 0); - final byte s_c01 = matrix2.get(0, 1); - final byte s_c11 = matrix2.get(1, 1); - final byte s_c21 = matrix2.get(2, 1); - final byte s_c31 = matrix2.get(3, 1); - output.set(0, 0, (byte) (f_c00*s_c00 + f_c10*s_c01)); - output.set(0, 1, (byte) (f_c01*s_c00 + f_c11*s_c01)); - output.set(1, 0, (byte) (f_c00*s_c10 + f_c10*s_c11)); - output.set(1, 1, (byte) (f_c01*s_c10 + f_c11*s_c11)); - output.set(2, 0, (byte) (f_c00*s_c20 + f_c10*s_c21)); - output.set(2, 1, (byte) (f_c01*s_c20 + f_c11*s_c21)); - output.set(3, 0, (byte) (f_c00*s_c30 + f_c10*s_c31)); - output.set(3, 1, (byte) (f_c01*s_c30 + f_c11*s_c31)); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + final byte s30 = matrix2.get(3, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s21 = matrix2.get(2, 1); + final byte s31 = matrix2.get(3, 1); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11)); + output.set(2, 0, (byte) (f00 * s20 + f10 * s21)); + output.set(3, 0, (byte) (f00 * s30 + f10 * s31)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01)); + output.set(1, 1, (byte) (f01 * s10 + f11 * s11)); + output.set(2, 1, (byte) (f01 * s20 + f11 * s21)); + output.set(3, 1, (byte) (f01 * s30 + f11 * s31)); return output; } private static IMatrixSetterByte multiplyMatrix2x2x5(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final byte f_c00 = matrix1.get(0, 0); - final byte f_c10 = matrix1.get(1, 0); - final byte f_c01 = matrix1.get(0, 1); - final byte f_c11 = matrix1.get(1, 1); - final byte s_c00 = matrix2.get(0, 0); - final byte s_c10 = matrix2.get(1, 0); - final byte s_c20 = matrix2.get(2, 0); - final byte s_c30 = matrix2.get(3, 0); - final byte s_c40 = matrix2.get(4, 0); - final byte s_c01 = matrix2.get(0, 1); - final byte s_c11 = matrix2.get(1, 1); - final byte s_c21 = matrix2.get(2, 1); - final byte s_c31 = matrix2.get(3, 1); - final byte s_c41 = matrix2.get(4, 1); - output.set(0, 0, (byte) (f_c00*s_c00 + f_c10*s_c01)); - output.set(0, 1, (byte) (f_c01*s_c00 + f_c11*s_c01)); - output.set(1, 0, (byte) (f_c00*s_c10 + f_c10*s_c11)); - output.set(1, 1, (byte) (f_c01*s_c10 + f_c11*s_c11)); - output.set(2, 0, (byte) (f_c00*s_c20 + f_c10*s_c21)); - output.set(2, 1, (byte) (f_c01*s_c20 + f_c11*s_c21)); - output.set(3, 0, (byte) (f_c00*s_c30 + f_c10*s_c31)); - output.set(3, 1, (byte) (f_c01*s_c30 + f_c11*s_c31)); - output.set(4, 0, (byte) (f_c00*s_c40 + f_c10*s_c41)); - output.set(4, 1, (byte) (f_c01*s_c40 + f_c11*s_c41)); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + final byte s30 = matrix2.get(3, 0); + final byte s40 = matrix2.get(4, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s21 = matrix2.get(2, 1); + final byte s31 = matrix2.get(3, 1); + final byte s41 = matrix2.get(4, 1); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11)); + output.set(2, 0, (byte) (f00 * s20 + f10 * s21)); + output.set(3, 0, (byte) (f00 * s30 + f10 * s31)); + output.set(4, 0, (byte) (f00 * s40 + f10 * s41)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01)); + output.set(1, 1, (byte) (f01 * s10 + f11 * s11)); + output.set(2, 1, (byte) (f01 * s20 + f11 * s21)); + output.set(3, 1, (byte) (f01 * s30 + f11 * s31)); + output.set(4, 1, (byte) (f01 * s40 + f11 * s41)); + return output; + } + + private static IMatrixSetterByte multiplyMatrix3x2x1(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f02 = matrix1.get(0, 2); + final byte f12 = matrix1.get(1, 2); + final byte s00 = matrix2.get(0, 0); + final byte s01 = matrix2.get(0, 1); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01)); + output.set(0, 2, (byte) (f02 * s00 + f12 * s01)); return output; } private static IMatrixSetterByte multiplyMatrix3x2x2(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final byte f_c00 = matrix1.get(0, 0); - final byte f_c10 = matrix1.get(1, 0); - final byte f_c01 = matrix1.get(0, 1); - final byte f_c11 = matrix1.get(1, 1); - final byte f_c02 = matrix1.get(0, 2); - final byte f_c12 = matrix1.get(1, 2); - final byte s_c00 = matrix2.get(0, 0); - final byte s_c10 = matrix2.get(1, 0); - final byte s_c01 = matrix2.get(0, 1); - final byte s_c11 = matrix2.get(1, 1); - output.set(0, 0, (byte) (f_c00*s_c00 + f_c10*s_c01)); - output.set(0, 1, (byte) (f_c01*s_c00 + f_c11*s_c01)); - output.set(0, 2, (byte) (f_c02*s_c00 + f_c12*s_c01)); - output.set(1, 0, (byte) (f_c00*s_c10 + f_c10*s_c11)); - output.set(1, 1, (byte) (f_c01*s_c10 + f_c11*s_c11)); - output.set(1, 2, (byte) (f_c02*s_c10 + f_c12*s_c11)); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f02 = matrix1.get(0, 2); + final byte f12 = matrix1.get(1, 2); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01)); + output.set(1, 1, (byte) (f01 * s10 + f11 * s11)); + output.set(0, 2, (byte) (f02 * s00 + f12 * s01)); + output.set(1, 2, (byte) (f02 * s10 + f12 * s11)); return output; } private static IMatrixSetterByte multiplyMatrix3x2x3(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final byte f_c00 = matrix1.get(0, 0); - final byte f_c10 = matrix1.get(1, 0); - final byte f_c01 = matrix1.get(0, 1); - final byte f_c11 = matrix1.get(1, 1); - final byte f_c02 = matrix1.get(0, 2); - final byte f_c12 = matrix1.get(1, 2); - final byte s_c00 = matrix2.get(0, 0); - final byte s_c10 = matrix2.get(1, 0); - final byte s_c20 = matrix2.get(2, 0); - final byte s_c01 = matrix2.get(0, 1); - final byte s_c11 = matrix2.get(1, 1); - final byte s_c21 = matrix2.get(2, 1); - output.set(0, 0, (byte) (f_c00*s_c00 + f_c10*s_c01)); - output.set(0, 1, (byte) (f_c01*s_c00 + f_c11*s_c01)); - output.set(0, 2, (byte) (f_c02*s_c00 + f_c12*s_c01)); - output.set(1, 0, (byte) (f_c00*s_c10 + f_c10*s_c11)); - output.set(1, 1, (byte) (f_c01*s_c10 + f_c11*s_c11)); - output.set(1, 2, (byte) (f_c02*s_c10 + f_c12*s_c11)); - output.set(2, 0, (byte) (f_c00*s_c20 + f_c10*s_c21)); - output.set(2, 1, (byte) (f_c01*s_c20 + f_c11*s_c21)); - output.set(2, 2, (byte) (f_c02*s_c20 + f_c12*s_c21)); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f02 = matrix1.get(0, 2); + final byte f12 = matrix1.get(1, 2); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s21 = matrix2.get(2, 1); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11)); + output.set(2, 0, (byte) (f00 * s20 + f10 * s21)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01)); + output.set(1, 1, (byte) (f01 * s10 + f11 * s11)); + output.set(2, 1, (byte) (f01 * s20 + f11 * s21)); + output.set(0, 2, (byte) (f02 * s00 + f12 * s01)); + output.set(1, 2, (byte) (f02 * s10 + f12 * s11)); + output.set(2, 2, (byte) (f02 * s20 + f12 * s21)); return output; } private static IMatrixSetterByte multiplyMatrix3x2x4(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final byte f_c00 = matrix1.get(0, 0); - final byte f_c10 = matrix1.get(1, 0); - final byte f_c01 = matrix1.get(0, 1); - final byte f_c11 = matrix1.get(1, 1); - final byte f_c02 = matrix1.get(0, 2); - final byte f_c12 = matrix1.get(1, 2); - final byte s_c00 = matrix2.get(0, 0); - final byte s_c10 = matrix2.get(1, 0); - final byte s_c20 = matrix2.get(2, 0); - final byte s_c30 = matrix2.get(3, 0); - final byte s_c01 = matrix2.get(0, 1); - final byte s_c11 = matrix2.get(1, 1); - final byte s_c21 = matrix2.get(2, 1); - final byte s_c31 = matrix2.get(3, 1); - output.set(0, 0, (byte) (f_c00*s_c00 + f_c10*s_c01)); - output.set(0, 1, (byte) (f_c01*s_c00 + f_c11*s_c01)); - output.set(0, 2, (byte) (f_c02*s_c00 + f_c12*s_c01)); - output.set(1, 0, (byte) (f_c00*s_c10 + f_c10*s_c11)); - output.set(1, 1, (byte) (f_c01*s_c10 + f_c11*s_c11)); - output.set(1, 2, (byte) (f_c02*s_c10 + f_c12*s_c11)); - output.set(2, 0, (byte) (f_c00*s_c20 + f_c10*s_c21)); - output.set(2, 1, (byte) (f_c01*s_c20 + f_c11*s_c21)); - output.set(2, 2, (byte) (f_c02*s_c20 + f_c12*s_c21)); - output.set(3, 0, (byte) (f_c00*s_c30 + f_c10*s_c31)); - output.set(3, 1, (byte) (f_c01*s_c30 + f_c11*s_c31)); - output.set(3, 2, (byte) (f_c02*s_c30 + f_c12*s_c31)); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f02 = matrix1.get(0, 2); + final byte f12 = matrix1.get(1, 2); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + final byte s30 = matrix2.get(3, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s21 = matrix2.get(2, 1); + final byte s31 = matrix2.get(3, 1); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11)); + output.set(2, 0, (byte) (f00 * s20 + f10 * s21)); + output.set(3, 0, (byte) (f00 * s30 + f10 * s31)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01)); + output.set(1, 1, (byte) (f01 * s10 + f11 * s11)); + output.set(2, 1, (byte) (f01 * s20 + f11 * s21)); + output.set(3, 1, (byte) (f01 * s30 + f11 * s31)); + output.set(0, 2, (byte) (f02 * s00 + f12 * s01)); + output.set(1, 2, (byte) (f02 * s10 + f12 * s11)); + output.set(2, 2, (byte) (f02 * s20 + f12 * s21)); + output.set(3, 2, (byte) (f02 * s30 + f12 * s31)); return output; } private static IMatrixSetterByte multiplyMatrix3x2x5(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final byte f_c00 = matrix1.get(0, 0); - final byte f_c10 = matrix1.get(1, 0); - final byte f_c01 = matrix1.get(0, 1); - final byte f_c11 = matrix1.get(1, 1); - final byte f_c02 = matrix1.get(0, 2); - final byte f_c12 = matrix1.get(1, 2); - final byte s_c00 = matrix2.get(0, 0); - final byte s_c10 = matrix2.get(1, 0); - final byte s_c20 = matrix2.get(2, 0); - final byte s_c30 = matrix2.get(3, 0); - final byte s_c40 = matrix2.get(4, 0); - final byte s_c01 = matrix2.get(0, 1); - final byte s_c11 = matrix2.get(1, 1); - final byte s_c21 = matrix2.get(2, 1); - final byte s_c31 = matrix2.get(3, 1); - final byte s_c41 = matrix2.get(4, 1); - output.set(0, 0, (byte) (f_c00*s_c00 + f_c10*s_c01)); - output.set(0, 1, (byte) (f_c01*s_c00 + f_c11*s_c01)); - output.set(0, 2, (byte) (f_c02*s_c00 + f_c12*s_c01)); - output.set(1, 0, (byte) (f_c00*s_c10 + f_c10*s_c11)); - output.set(1, 1, (byte) (f_c01*s_c10 + f_c11*s_c11)); - output.set(1, 2, (byte) (f_c02*s_c10 + f_c12*s_c11)); - output.set(2, 0, (byte) (f_c00*s_c20 + f_c10*s_c21)); - output.set(2, 1, (byte) (f_c01*s_c20 + f_c11*s_c21)); - output.set(2, 2, (byte) (f_c02*s_c20 + f_c12*s_c21)); - output.set(3, 0, (byte) (f_c00*s_c30 + f_c10*s_c31)); - output.set(3, 1, (byte) (f_c01*s_c30 + f_c11*s_c31)); - output.set(3, 2, (byte) (f_c02*s_c30 + f_c12*s_c31)); - output.set(4, 0, (byte) (f_c00*s_c40 + f_c10*s_c41)); - output.set(4, 1, (byte) (f_c01*s_c40 + f_c11*s_c41)); - output.set(4, 2, (byte) (f_c02*s_c40 + f_c12*s_c41)); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f02 = matrix1.get(0, 2); + final byte f12 = matrix1.get(1, 2); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + final byte s30 = matrix2.get(3, 0); + final byte s40 = matrix2.get(4, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s21 = matrix2.get(2, 1); + final byte s31 = matrix2.get(3, 1); + final byte s41 = matrix2.get(4, 1); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11)); + output.set(2, 0, (byte) (f00 * s20 + f10 * s21)); + output.set(3, 0, (byte) (f00 * s30 + f10 * s31)); + output.set(4, 0, (byte) (f00 * s40 + f10 * s41)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01)); + output.set(1, 1, (byte) (f01 * s10 + f11 * s11)); + output.set(2, 1, (byte) (f01 * s20 + f11 * s21)); + output.set(3, 1, (byte) (f01 * s30 + f11 * s31)); + output.set(4, 1, (byte) (f01 * s40 + f11 * s41)); + output.set(0, 2, (byte) (f02 * s00 + f12 * s01)); + output.set(1, 2, (byte) (f02 * s10 + f12 * s11)); + output.set(2, 2, (byte) (f02 * s20 + f12 * s21)); + output.set(3, 2, (byte) (f02 * s30 + f12 * s31)); + output.set(4, 2, (byte) (f02 * s40 + f12 * s41)); + return output; + } + + private static IMatrixSetterByte multiplyMatrix4x2x1(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f02 = matrix1.get(0, 2); + final byte f12 = matrix1.get(1, 2); + final byte f03 = matrix1.get(0, 3); + final byte f13 = matrix1.get(1, 3); + final byte s00 = matrix2.get(0, 0); + final byte s01 = matrix2.get(0, 1); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01)); + output.set(0, 2, (byte) (f02 * s00 + f12 * s01)); + output.set(0, 3, (byte) (f03 * s00 + f13 * s01)); return output; } private static IMatrixSetterByte multiplyMatrix4x2x2(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final byte f_c00 = matrix1.get(0, 0); - final byte f_c10 = matrix1.get(1, 0); - final byte f_c01 = matrix1.get(0, 1); - final byte f_c11 = matrix1.get(1, 1); - final byte f_c02 = matrix1.get(0, 2); - final byte f_c12 = matrix1.get(1, 2); - final byte f_c03 = matrix1.get(0, 3); - final byte f_c13 = matrix1.get(1, 3); - final byte s_c00 = matrix2.get(0, 0); - final byte s_c10 = matrix2.get(1, 0); - final byte s_c01 = matrix2.get(0, 1); - final byte s_c11 = matrix2.get(1, 1); - output.set(0, 0, (byte) (f_c00*s_c00 + f_c10*s_c01)); - output.set(0, 1, (byte) (f_c01*s_c00 + f_c11*s_c01)); - output.set(0, 2, (byte) (f_c02*s_c00 + f_c12*s_c01)); - output.set(0, 3, (byte) (f_c03*s_c00 + f_c13*s_c01)); - output.set(1, 0, (byte) (f_c00*s_c10 + f_c10*s_c11)); - output.set(1, 1, (byte) (f_c01*s_c10 + f_c11*s_c11)); - output.set(1, 2, (byte) (f_c02*s_c10 + f_c12*s_c11)); - output.set(1, 3, (byte) (f_c03*s_c10 + f_c13*s_c11)); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f02 = matrix1.get(0, 2); + final byte f12 = matrix1.get(1, 2); + final byte f03 = matrix1.get(0, 3); + final byte f13 = matrix1.get(1, 3); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01)); + output.set(1, 1, (byte) (f01 * s10 + f11 * s11)); + output.set(0, 2, (byte) (f02 * s00 + f12 * s01)); + output.set(1, 2, (byte) (f02 * s10 + f12 * s11)); + output.set(0, 3, (byte) (f03 * s00 + f13 * s01)); + output.set(1, 3, (byte) (f03 * s10 + f13 * s11)); return output; } private static IMatrixSetterByte multiplyMatrix4x2x3(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final byte f_c00 = matrix1.get(0, 0); - final byte f_c10 = matrix1.get(1, 0); - final byte f_c01 = matrix1.get(0, 1); - final byte f_c11 = matrix1.get(1, 1); - final byte f_c02 = matrix1.get(0, 2); - final byte f_c12 = matrix1.get(1, 2); - final byte f_c03 = matrix1.get(0, 3); - final byte f_c13 = matrix1.get(1, 3); - final byte s_c00 = matrix2.get(0, 0); - final byte s_c10 = matrix2.get(1, 0); - final byte s_c20 = matrix2.get(2, 0); - final byte s_c01 = matrix2.get(0, 1); - final byte s_c11 = matrix2.get(1, 1); - final byte s_c21 = matrix2.get(2, 1); - output.set(0, 0, (byte) (f_c00*s_c00 + f_c10*s_c01)); - output.set(0, 1, (byte) (f_c01*s_c00 + f_c11*s_c01)); - output.set(0, 2, (byte) (f_c02*s_c00 + f_c12*s_c01)); - output.set(0, 3, (byte) (f_c03*s_c00 + f_c13*s_c01)); - output.set(1, 0, (byte) (f_c00*s_c10 + f_c10*s_c11)); - output.set(1, 1, (byte) (f_c01*s_c10 + f_c11*s_c11)); - output.set(1, 2, (byte) (f_c02*s_c10 + f_c12*s_c11)); - output.set(1, 3, (byte) (f_c03*s_c10 + f_c13*s_c11)); - output.set(2, 0, (byte) (f_c00*s_c20 + f_c10*s_c21)); - output.set(2, 1, (byte) (f_c01*s_c20 + f_c11*s_c21)); - output.set(2, 2, (byte) (f_c02*s_c20 + f_c12*s_c21)); - output.set(2, 3, (byte) (f_c03*s_c20 + f_c13*s_c21)); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f02 = matrix1.get(0, 2); + final byte f12 = matrix1.get(1, 2); + final byte f03 = matrix1.get(0, 3); + final byte f13 = matrix1.get(1, 3); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s21 = matrix2.get(2, 1); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11)); + output.set(2, 0, (byte) (f00 * s20 + f10 * s21)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01)); + output.set(1, 1, (byte) (f01 * s10 + f11 * s11)); + output.set(2, 1, (byte) (f01 * s20 + f11 * s21)); + output.set(0, 2, (byte) (f02 * s00 + f12 * s01)); + output.set(1, 2, (byte) (f02 * s10 + f12 * s11)); + output.set(2, 2, (byte) (f02 * s20 + f12 * s21)); + output.set(0, 3, (byte) (f03 * s00 + f13 * s01)); + output.set(1, 3, (byte) (f03 * s10 + f13 * s11)); + output.set(2, 3, (byte) (f03 * s20 + f13 * s21)); return output; } private static IMatrixSetterByte multiplyMatrix4x2x4(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final byte f_c00 = matrix1.get(0, 0); - final byte f_c10 = matrix1.get(1, 0); - final byte f_c01 = matrix1.get(0, 1); - final byte f_c11 = matrix1.get(1, 1); - final byte f_c02 = matrix1.get(0, 2); - final byte f_c12 = matrix1.get(1, 2); - final byte f_c03 = matrix1.get(0, 3); - final byte f_c13 = matrix1.get(1, 3); - final byte s_c00 = matrix2.get(0, 0); - final byte s_c10 = matrix2.get(1, 0); - final byte s_c20 = matrix2.get(2, 0); - final byte s_c30 = matrix2.get(3, 0); - final byte s_c01 = matrix2.get(0, 1); - final byte s_c11 = matrix2.get(1, 1); - final byte s_c21 = matrix2.get(2, 1); - final byte s_c31 = matrix2.get(3, 1); - output.set(0, 0, (byte) (f_c00*s_c00 + f_c10*s_c01)); - output.set(0, 1, (byte) (f_c01*s_c00 + f_c11*s_c01)); - output.set(0, 2, (byte) (f_c02*s_c00 + f_c12*s_c01)); - output.set(0, 3, (byte) (f_c03*s_c00 + f_c13*s_c01)); - output.set(1, 0, (byte) (f_c00*s_c10 + f_c10*s_c11)); - output.set(1, 1, (byte) (f_c01*s_c10 + f_c11*s_c11)); - output.set(1, 2, (byte) (f_c02*s_c10 + f_c12*s_c11)); - output.set(1, 3, (byte) (f_c03*s_c10 + f_c13*s_c11)); - output.set(2, 0, (byte) (f_c00*s_c20 + f_c10*s_c21)); - output.set(2, 1, (byte) (f_c01*s_c20 + f_c11*s_c21)); - output.set(2, 2, (byte) (f_c02*s_c20 + f_c12*s_c21)); - output.set(2, 3, (byte) (f_c03*s_c20 + f_c13*s_c21)); - output.set(3, 0, (byte) (f_c00*s_c30 + f_c10*s_c31)); - output.set(3, 1, (byte) (f_c01*s_c30 + f_c11*s_c31)); - output.set(3, 2, (byte) (f_c02*s_c30 + f_c12*s_c31)); - output.set(3, 3, (byte) (f_c03*s_c30 + f_c13*s_c31)); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f02 = matrix1.get(0, 2); + final byte f12 = matrix1.get(1, 2); + final byte f03 = matrix1.get(0, 3); + final byte f13 = matrix1.get(1, 3); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + final byte s30 = matrix2.get(3, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s21 = matrix2.get(2, 1); + final byte s31 = matrix2.get(3, 1); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11)); + output.set(2, 0, (byte) (f00 * s20 + f10 * s21)); + output.set(3, 0, (byte) (f00 * s30 + f10 * s31)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01)); + output.set(1, 1, (byte) (f01 * s10 + f11 * s11)); + output.set(2, 1, (byte) (f01 * s20 + f11 * s21)); + output.set(3, 1, (byte) (f01 * s30 + f11 * s31)); + output.set(0, 2, (byte) (f02 * s00 + f12 * s01)); + output.set(1, 2, (byte) (f02 * s10 + f12 * s11)); + output.set(2, 2, (byte) (f02 * s20 + f12 * s21)); + output.set(3, 2, (byte) (f02 * s30 + f12 * s31)); + output.set(0, 3, (byte) (f03 * s00 + f13 * s01)); + output.set(1, 3, (byte) (f03 * s10 + f13 * s11)); + output.set(2, 3, (byte) (f03 * s20 + f13 * s21)); + output.set(3, 3, (byte) (f03 * s30 + f13 * s31)); return output; } private static IMatrixSetterByte multiplyMatrix4x2x5(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final byte f_c00 = matrix1.get(0, 0); - final byte f_c10 = matrix1.get(1, 0); - final byte f_c01 = matrix1.get(0, 1); - final byte f_c11 = matrix1.get(1, 1); - final byte f_c02 = matrix1.get(0, 2); - final byte f_c12 = matrix1.get(1, 2); - final byte f_c03 = matrix1.get(0, 3); - final byte f_c13 = matrix1.get(1, 3); - final byte s_c00 = matrix2.get(0, 0); - final byte s_c10 = matrix2.get(1, 0); - final byte s_c20 = matrix2.get(2, 0); - final byte s_c30 = matrix2.get(3, 0); - final byte s_c40 = matrix2.get(4, 0); - final byte s_c01 = matrix2.get(0, 1); - final byte s_c11 = matrix2.get(1, 1); - final byte s_c21 = matrix2.get(2, 1); - final byte s_c31 = matrix2.get(3, 1); - final byte s_c41 = matrix2.get(4, 1); - output.set(0, 0, (byte) (f_c00*s_c00 + f_c10*s_c01)); - output.set(0, 1, (byte) (f_c01*s_c00 + f_c11*s_c01)); - output.set(0, 2, (byte) (f_c02*s_c00 + f_c12*s_c01)); - output.set(0, 3, (byte) (f_c03*s_c00 + f_c13*s_c01)); - output.set(1, 0, (byte) (f_c00*s_c10 + f_c10*s_c11)); - output.set(1, 1, (byte) (f_c01*s_c10 + f_c11*s_c11)); - output.set(1, 2, (byte) (f_c02*s_c10 + f_c12*s_c11)); - output.set(1, 3, (byte) (f_c03*s_c10 + f_c13*s_c11)); - output.set(2, 0, (byte) (f_c00*s_c20 + f_c10*s_c21)); - output.set(2, 1, (byte) (f_c01*s_c20 + f_c11*s_c21)); - output.set(2, 2, (byte) (f_c02*s_c20 + f_c12*s_c21)); - output.set(2, 3, (byte) (f_c03*s_c20 + f_c13*s_c21)); - output.set(3, 0, (byte) (f_c00*s_c30 + f_c10*s_c31)); - output.set(3, 1, (byte) (f_c01*s_c30 + f_c11*s_c31)); - output.set(3, 2, (byte) (f_c02*s_c30 + f_c12*s_c31)); - output.set(3, 3, (byte) (f_c03*s_c30 + f_c13*s_c31)); - output.set(4, 0, (byte) (f_c00*s_c40 + f_c10*s_c41)); - output.set(4, 1, (byte) (f_c01*s_c40 + f_c11*s_c41)); - output.set(4, 2, (byte) (f_c02*s_c40 + f_c12*s_c41)); - output.set(4, 3, (byte) (f_c03*s_c40 + f_c13*s_c41)); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f02 = matrix1.get(0, 2); + final byte f12 = matrix1.get(1, 2); + final byte f03 = matrix1.get(0, 3); + final byte f13 = matrix1.get(1, 3); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + final byte s30 = matrix2.get(3, 0); + final byte s40 = matrix2.get(4, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s21 = matrix2.get(2, 1); + final byte s31 = matrix2.get(3, 1); + final byte s41 = matrix2.get(4, 1); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11)); + output.set(2, 0, (byte) (f00 * s20 + f10 * s21)); + output.set(3, 0, (byte) (f00 * s30 + f10 * s31)); + output.set(4, 0, (byte) (f00 * s40 + f10 * s41)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01)); + output.set(1, 1, (byte) (f01 * s10 + f11 * s11)); + output.set(2, 1, (byte) (f01 * s20 + f11 * s21)); + output.set(3, 1, (byte) (f01 * s30 + f11 * s31)); + output.set(4, 1, (byte) (f01 * s40 + f11 * s41)); + output.set(0, 2, (byte) (f02 * s00 + f12 * s01)); + output.set(1, 2, (byte) (f02 * s10 + f12 * s11)); + output.set(2, 2, (byte) (f02 * s20 + f12 * s21)); + output.set(3, 2, (byte) (f02 * s30 + f12 * s31)); + output.set(4, 2, (byte) (f02 * s40 + f12 * s41)); + output.set(0, 3, (byte) (f03 * s00 + f13 * s01)); + output.set(1, 3, (byte) (f03 * s10 + f13 * s11)); + output.set(2, 3, (byte) (f03 * s20 + f13 * s21)); + output.set(3, 3, (byte) (f03 * s30 + f13 * s31)); + output.set(4, 3, (byte) (f03 * s40 + f13 * s41)); + return output; + } + + private static IMatrixSetterByte multiplyMatrix5x2x1(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f02 = matrix1.get(0, 2); + final byte f12 = matrix1.get(1, 2); + final byte f03 = matrix1.get(0, 3); + final byte f13 = matrix1.get(1, 3); + final byte f04 = matrix1.get(0, 4); + final byte f14 = matrix1.get(1, 4); + final byte s00 = matrix2.get(0, 0); + final byte s01 = matrix2.get(0, 1); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01)); + output.set(0, 2, (byte) (f02 * s00 + f12 * s01)); + output.set(0, 3, (byte) (f03 * s00 + f13 * s01)); + output.set(0, 4, (byte) (f04 * s00 + f14 * s01)); return output; } private static IMatrixSetterByte multiplyMatrix5x2x2(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final byte f_c00 = matrix1.get(0, 0); - final byte f_c10 = matrix1.get(1, 0); - final byte f_c01 = matrix1.get(0, 1); - final byte f_c11 = matrix1.get(1, 1); - final byte f_c02 = matrix1.get(0, 2); - final byte f_c12 = matrix1.get(1, 2); - final byte f_c03 = matrix1.get(0, 3); - final byte f_c13 = matrix1.get(1, 3); - final byte f_c04 = matrix1.get(0, 4); - final byte f_c14 = matrix1.get(1, 4); - final byte s_c00 = matrix2.get(0, 0); - final byte s_c10 = matrix2.get(1, 0); - final byte s_c01 = matrix2.get(0, 1); - final byte s_c11 = matrix2.get(1, 1); - output.set(0, 0, (byte) (f_c00*s_c00 + f_c10*s_c01)); - output.set(0, 1, (byte) (f_c01*s_c00 + f_c11*s_c01)); - output.set(0, 2, (byte) (f_c02*s_c00 + f_c12*s_c01)); - output.set(0, 3, (byte) (f_c03*s_c00 + f_c13*s_c01)); - output.set(0, 4, (byte) (f_c04*s_c00 + f_c14*s_c01)); - output.set(1, 0, (byte) (f_c00*s_c10 + f_c10*s_c11)); - output.set(1, 1, (byte) (f_c01*s_c10 + f_c11*s_c11)); - output.set(1, 2, (byte) (f_c02*s_c10 + f_c12*s_c11)); - output.set(1, 3, (byte) (f_c03*s_c10 + f_c13*s_c11)); - output.set(1, 4, (byte) (f_c04*s_c10 + f_c14*s_c11)); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f02 = matrix1.get(0, 2); + final byte f12 = matrix1.get(1, 2); + final byte f03 = matrix1.get(0, 3); + final byte f13 = matrix1.get(1, 3); + final byte f04 = matrix1.get(0, 4); + final byte f14 = matrix1.get(1, 4); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01)); + output.set(1, 1, (byte) (f01 * s10 + f11 * s11)); + output.set(0, 2, (byte) (f02 * s00 + f12 * s01)); + output.set(1, 2, (byte) (f02 * s10 + f12 * s11)); + output.set(0, 3, (byte) (f03 * s00 + f13 * s01)); + output.set(1, 3, (byte) (f03 * s10 + f13 * s11)); + output.set(0, 4, (byte) (f04 * s00 + f14 * s01)); + output.set(1, 4, (byte) (f04 * s10 + f14 * s11)); return output; } private static IMatrixSetterByte multiplyMatrix5x2x3(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final byte f_c00 = matrix1.get(0, 0); - final byte f_c10 = matrix1.get(1, 0); - final byte f_c01 = matrix1.get(0, 1); - final byte f_c11 = matrix1.get(1, 1); - final byte f_c02 = matrix1.get(0, 2); - final byte f_c12 = matrix1.get(1, 2); - final byte f_c03 = matrix1.get(0, 3); - final byte f_c13 = matrix1.get(1, 3); - final byte f_c04 = matrix1.get(0, 4); - final byte f_c14 = matrix1.get(1, 4); - final byte s_c00 = matrix2.get(0, 0); - final byte s_c10 = matrix2.get(1, 0); - final byte s_c20 = matrix2.get(2, 0); - final byte s_c01 = matrix2.get(0, 1); - final byte s_c11 = matrix2.get(1, 1); - final byte s_c21 = matrix2.get(2, 1); - output.set(0, 0, (byte) (f_c00*s_c00 + f_c10*s_c01)); - output.set(0, 1, (byte) (f_c01*s_c00 + f_c11*s_c01)); - output.set(0, 2, (byte) (f_c02*s_c00 + f_c12*s_c01)); - output.set(0, 3, (byte) (f_c03*s_c00 + f_c13*s_c01)); - output.set(0, 4, (byte) (f_c04*s_c00 + f_c14*s_c01)); - output.set(1, 0, (byte) (f_c00*s_c10 + f_c10*s_c11)); - output.set(1, 1, (byte) (f_c01*s_c10 + f_c11*s_c11)); - output.set(1, 2, (byte) (f_c02*s_c10 + f_c12*s_c11)); - output.set(1, 3, (byte) (f_c03*s_c10 + f_c13*s_c11)); - output.set(1, 4, (byte) (f_c04*s_c10 + f_c14*s_c11)); - output.set(2, 0, (byte) (f_c00*s_c20 + f_c10*s_c21)); - output.set(2, 1, (byte) (f_c01*s_c20 + f_c11*s_c21)); - output.set(2, 2, (byte) (f_c02*s_c20 + f_c12*s_c21)); - output.set(2, 3, (byte) (f_c03*s_c20 + f_c13*s_c21)); - output.set(2, 4, (byte) (f_c04*s_c20 + f_c14*s_c21)); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f02 = matrix1.get(0, 2); + final byte f12 = matrix1.get(1, 2); + final byte f03 = matrix1.get(0, 3); + final byte f13 = matrix1.get(1, 3); + final byte f04 = matrix1.get(0, 4); + final byte f14 = matrix1.get(1, 4); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s21 = matrix2.get(2, 1); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11)); + output.set(2, 0, (byte) (f00 * s20 + f10 * s21)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01)); + output.set(1, 1, (byte) (f01 * s10 + f11 * s11)); + output.set(2, 1, (byte) (f01 * s20 + f11 * s21)); + output.set(0, 2, (byte) (f02 * s00 + f12 * s01)); + output.set(1, 2, (byte) (f02 * s10 + f12 * s11)); + output.set(2, 2, (byte) (f02 * s20 + f12 * s21)); + output.set(0, 3, (byte) (f03 * s00 + f13 * s01)); + output.set(1, 3, (byte) (f03 * s10 + f13 * s11)); + output.set(2, 3, (byte) (f03 * s20 + f13 * s21)); + output.set(0, 4, (byte) (f04 * s00 + f14 * s01)); + output.set(1, 4, (byte) (f04 * s10 + f14 * s11)); + output.set(2, 4, (byte) (f04 * s20 + f14 * s21)); return output; } private static IMatrixSetterByte multiplyMatrix5x2x4(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final byte f_c00 = matrix1.get(0, 0); - final byte f_c10 = matrix1.get(1, 0); - final byte f_c01 = matrix1.get(0, 1); - final byte f_c11 = matrix1.get(1, 1); - final byte f_c02 = matrix1.get(0, 2); - final byte f_c12 = matrix1.get(1, 2); - final byte f_c03 = matrix1.get(0, 3); - final byte f_c13 = matrix1.get(1, 3); - final byte f_c04 = matrix1.get(0, 4); - final byte f_c14 = matrix1.get(1, 4); - final byte s_c00 = matrix2.get(0, 0); - final byte s_c10 = matrix2.get(1, 0); - final byte s_c20 = matrix2.get(2, 0); - final byte s_c30 = matrix2.get(3, 0); - final byte s_c01 = matrix2.get(0, 1); - final byte s_c11 = matrix2.get(1, 1); - final byte s_c21 = matrix2.get(2, 1); - final byte s_c31 = matrix2.get(3, 1); - output.set(0, 0, (byte) (f_c00*s_c00 + f_c10*s_c01)); - output.set(0, 1, (byte) (f_c01*s_c00 + f_c11*s_c01)); - output.set(0, 2, (byte) (f_c02*s_c00 + f_c12*s_c01)); - output.set(0, 3, (byte) (f_c03*s_c00 + f_c13*s_c01)); - output.set(0, 4, (byte) (f_c04*s_c00 + f_c14*s_c01)); - output.set(1, 0, (byte) (f_c00*s_c10 + f_c10*s_c11)); - output.set(1, 1, (byte) (f_c01*s_c10 + f_c11*s_c11)); - output.set(1, 2, (byte) (f_c02*s_c10 + f_c12*s_c11)); - output.set(1, 3, (byte) (f_c03*s_c10 + f_c13*s_c11)); - output.set(1, 4, (byte) (f_c04*s_c10 + f_c14*s_c11)); - output.set(2, 0, (byte) (f_c00*s_c20 + f_c10*s_c21)); - output.set(2, 1, (byte) (f_c01*s_c20 + f_c11*s_c21)); - output.set(2, 2, (byte) (f_c02*s_c20 + f_c12*s_c21)); - output.set(2, 3, (byte) (f_c03*s_c20 + f_c13*s_c21)); - output.set(2, 4, (byte) (f_c04*s_c20 + f_c14*s_c21)); - output.set(3, 0, (byte) (f_c00*s_c30 + f_c10*s_c31)); - output.set(3, 1, (byte) (f_c01*s_c30 + f_c11*s_c31)); - output.set(3, 2, (byte) (f_c02*s_c30 + f_c12*s_c31)); - output.set(3, 3, (byte) (f_c03*s_c30 + f_c13*s_c31)); - output.set(3, 4, (byte) (f_c04*s_c30 + f_c14*s_c31)); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f02 = matrix1.get(0, 2); + final byte f12 = matrix1.get(1, 2); + final byte f03 = matrix1.get(0, 3); + final byte f13 = matrix1.get(1, 3); + final byte f04 = matrix1.get(0, 4); + final byte f14 = matrix1.get(1, 4); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + final byte s30 = matrix2.get(3, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s21 = matrix2.get(2, 1); + final byte s31 = matrix2.get(3, 1); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11)); + output.set(2, 0, (byte) (f00 * s20 + f10 * s21)); + output.set(3, 0, (byte) (f00 * s30 + f10 * s31)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01)); + output.set(1, 1, (byte) (f01 * s10 + f11 * s11)); + output.set(2, 1, (byte) (f01 * s20 + f11 * s21)); + output.set(3, 1, (byte) (f01 * s30 + f11 * s31)); + output.set(0, 2, (byte) (f02 * s00 + f12 * s01)); + output.set(1, 2, (byte) (f02 * s10 + f12 * s11)); + output.set(2, 2, (byte) (f02 * s20 + f12 * s21)); + output.set(3, 2, (byte) (f02 * s30 + f12 * s31)); + output.set(0, 3, (byte) (f03 * s00 + f13 * s01)); + output.set(1, 3, (byte) (f03 * s10 + f13 * s11)); + output.set(2, 3, (byte) (f03 * s20 + f13 * s21)); + output.set(3, 3, (byte) (f03 * s30 + f13 * s31)); + output.set(0, 4, (byte) (f04 * s00 + f14 * s01)); + output.set(1, 4, (byte) (f04 * s10 + f14 * s11)); + output.set(2, 4, (byte) (f04 * s20 + f14 * s21)); + output.set(3, 4, (byte) (f04 * s30 + f14 * s31)); return output; } private static IMatrixSetterByte multiplyMatrix5x2x5(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final byte f_c00 = matrix1.get(0, 0); - final byte f_c10 = matrix1.get(1, 0); - final byte f_c01 = matrix1.get(0, 1); - final byte f_c11 = matrix1.get(1, 1); - final byte f_c02 = matrix1.get(0, 2); - final byte f_c12 = matrix1.get(1, 2); - final byte f_c03 = matrix1.get(0, 3); - final byte f_c13 = matrix1.get(1, 3); - final byte f_c04 = matrix1.get(0, 4); - final byte f_c14 = matrix1.get(1, 4); - final byte s_c00 = matrix2.get(0, 0); - final byte s_c10 = matrix2.get(1, 0); - final byte s_c20 = matrix2.get(2, 0); - final byte s_c30 = matrix2.get(3, 0); - final byte s_c40 = matrix2.get(4, 0); - final byte s_c01 = matrix2.get(0, 1); - final byte s_c11 = matrix2.get(1, 1); - final byte s_c21 = matrix2.get(2, 1); - final byte s_c31 = matrix2.get(3, 1); - final byte s_c41 = matrix2.get(4, 1); - output.set(0, 0, (byte) (f_c00*s_c00 + f_c10*s_c01)); - output.set(0, 1, (byte) (f_c01*s_c00 + f_c11*s_c01)); - output.set(0, 2, (byte) (f_c02*s_c00 + f_c12*s_c01)); - output.set(0, 3, (byte) (f_c03*s_c00 + f_c13*s_c01)); - output.set(0, 4, (byte) (f_c04*s_c00 + f_c14*s_c01)); - output.set(1, 0, (byte) (f_c00*s_c10 + f_c10*s_c11)); - output.set(1, 1, (byte) (f_c01*s_c10 + f_c11*s_c11)); - output.set(1, 2, (byte) (f_c02*s_c10 + f_c12*s_c11)); - output.set(1, 3, (byte) (f_c03*s_c10 + f_c13*s_c11)); - output.set(1, 4, (byte) (f_c04*s_c10 + f_c14*s_c11)); - output.set(2, 0, (byte) (f_c00*s_c20 + f_c10*s_c21)); - output.set(2, 1, (byte) (f_c01*s_c20 + f_c11*s_c21)); - output.set(2, 2, (byte) (f_c02*s_c20 + f_c12*s_c21)); - output.set(2, 3, (byte) (f_c03*s_c20 + f_c13*s_c21)); - output.set(2, 4, (byte) (f_c04*s_c20 + f_c14*s_c21)); - output.set(3, 0, (byte) (f_c00*s_c30 + f_c10*s_c31)); - output.set(3, 1, (byte) (f_c01*s_c30 + f_c11*s_c31)); - output.set(3, 2, (byte) (f_c02*s_c30 + f_c12*s_c31)); - output.set(3, 3, (byte) (f_c03*s_c30 + f_c13*s_c31)); - output.set(3, 4, (byte) (f_c04*s_c30 + f_c14*s_c31)); - output.set(4, 0, (byte) (f_c00*s_c40 + f_c10*s_c41)); - output.set(4, 1, (byte) (f_c01*s_c40 + f_c11*s_c41)); - output.set(4, 2, (byte) (f_c02*s_c40 + f_c12*s_c41)); - output.set(4, 3, (byte) (f_c03*s_c40 + f_c13*s_c41)); - output.set(4, 4, (byte) (f_c04*s_c40 + f_c14*s_c41)); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f02 = matrix1.get(0, 2); + final byte f12 = matrix1.get(1, 2); + final byte f03 = matrix1.get(0, 3); + final byte f13 = matrix1.get(1, 3); + final byte f04 = matrix1.get(0, 4); + final byte f14 = matrix1.get(1, 4); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + final byte s30 = matrix2.get(3, 0); + final byte s40 = matrix2.get(4, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s21 = matrix2.get(2, 1); + final byte s31 = matrix2.get(3, 1); + final byte s41 = matrix2.get(4, 1); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11)); + output.set(2, 0, (byte) (f00 * s20 + f10 * s21)); + output.set(3, 0, (byte) (f00 * s30 + f10 * s31)); + output.set(4, 0, (byte) (f00 * s40 + f10 * s41)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01)); + output.set(1, 1, (byte) (f01 * s10 + f11 * s11)); + output.set(2, 1, (byte) (f01 * s20 + f11 * s21)); + output.set(3, 1, (byte) (f01 * s30 + f11 * s31)); + output.set(4, 1, (byte) (f01 * s40 + f11 * s41)); + output.set(0, 2, (byte) (f02 * s00 + f12 * s01)); + output.set(1, 2, (byte) (f02 * s10 + f12 * s11)); + output.set(2, 2, (byte) (f02 * s20 + f12 * s21)); + output.set(3, 2, (byte) (f02 * s30 + f12 * s31)); + output.set(4, 2, (byte) (f02 * s40 + f12 * s41)); + output.set(0, 3, (byte) (f03 * s00 + f13 * s01)); + output.set(1, 3, (byte) (f03 * s10 + f13 * s11)); + output.set(2, 3, (byte) (f03 * s20 + f13 * s21)); + output.set(3, 3, (byte) (f03 * s30 + f13 * s31)); + output.set(4, 3, (byte) (f03 * s40 + f13 * s41)); + output.set(0, 4, (byte) (f04 * s00 + f14 * s01)); + output.set(1, 4, (byte) (f04 * s10 + f14 * s11)); + output.set(2, 4, (byte) (f04 * s20 + f14 * s21)); + output.set(3, 4, (byte) (f04 * s30 + f14 * s31)); + output.set(4, 4, (byte) (f04 * s40 + f14 * s41)); + return output; + } + + private static IMatrixSetterByte multiplyMatrix1x3x1(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte s00 = matrix2.get(0, 0); + final byte s01 = matrix2.get(0, 1); + final byte s02 = matrix2.get(0, 2); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02)); + return output; + } + + private static IMatrixSetterByte multiplyMatrix1x3x2(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s02 = matrix2.get(0, 2); + final byte s12 = matrix2.get(1, 2); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11 + f20 * s12)); + return output; + } + + private static IMatrixSetterByte multiplyMatrix1x3x3(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s21 = matrix2.get(2, 1); + final byte s02 = matrix2.get(0, 2); + final byte s12 = matrix2.get(1, 2); + final byte s22 = matrix2.get(2, 2); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11 + f20 * s12)); + output.set(2, 0, (byte) (f00 * s20 + f10 * s21 + f20 * s22)); + return output; + } + + private static IMatrixSetterByte multiplyMatrix1x3x4(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + final byte s30 = matrix2.get(3, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s21 = matrix2.get(2, 1); + final byte s31 = matrix2.get(3, 1); + final byte s02 = matrix2.get(0, 2); + final byte s12 = matrix2.get(1, 2); + final byte s22 = matrix2.get(2, 2); + final byte s32 = matrix2.get(3, 2); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11 + f20 * s12)); + output.set(2, 0, (byte) (f00 * s20 + f10 * s21 + f20 * s22)); + output.set(3, 0, (byte) (f00 * s30 + f10 * s31 + f20 * s32)); + return output; + } + + private static IMatrixSetterByte multiplyMatrix1x3x5(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + final byte s30 = matrix2.get(3, 0); + final byte s40 = matrix2.get(4, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s21 = matrix2.get(2, 1); + final byte s31 = matrix2.get(3, 1); + final byte s41 = matrix2.get(4, 1); + final byte s02 = matrix2.get(0, 2); + final byte s12 = matrix2.get(1, 2); + final byte s22 = matrix2.get(2, 2); + final byte s32 = matrix2.get(3, 2); + final byte s42 = matrix2.get(4, 2); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11 + f20 * s12)); + output.set(2, 0, (byte) (f00 * s20 + f10 * s21 + f20 * s22)); + output.set(3, 0, (byte) (f00 * s30 + f10 * s31 + f20 * s32)); + output.set(4, 0, (byte) (f00 * s40 + f10 * s41 + f20 * s42)); + return output; + } + + private static IMatrixSetterByte multiplyMatrix2x3x1(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f21 = matrix1.get(2, 1); + final byte s00 = matrix2.get(0, 0); + final byte s01 = matrix2.get(0, 1); + final byte s02 = matrix2.get(0, 2); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01 + f21 * s02)); return output; } private static IMatrixSetterByte multiplyMatrix2x3x2(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final byte f_c00 = matrix1.get(0, 0); - final byte f_c10 = matrix1.get(1, 0); - final byte f_c20 = matrix1.get(2, 0); - final byte f_c01 = matrix1.get(0, 1); - final byte f_c11 = matrix1.get(1, 1); - final byte f_c21 = matrix1.get(2, 1); - final byte s_c00 = matrix2.get(0, 0); - final byte s_c10 = matrix2.get(1, 0); - final byte s_c01 = matrix2.get(0, 1); - final byte s_c11 = matrix2.get(1, 1); - final byte s_c02 = matrix2.get(0, 2); - final byte s_c12 = matrix2.get(1, 2); - output.set(0, 0, (byte) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02)); - output.set(0, 1, (byte) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02)); - output.set(1, 0, (byte) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12)); - output.set(1, 1, (byte) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12)); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f21 = matrix1.get(2, 1); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s02 = matrix2.get(0, 2); + final byte s12 = matrix2.get(1, 2); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11 + f20 * s12)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01 + f21 * s02)); + output.set(1, 1, (byte) (f01 * s10 + f11 * s11 + f21 * s12)); return output; } private static IMatrixSetterByte multiplyMatrix2x3x3(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final byte f_c00 = matrix1.get(0, 0); - final byte f_c10 = matrix1.get(1, 0); - final byte f_c20 = matrix1.get(2, 0); - final byte f_c01 = matrix1.get(0, 1); - final byte f_c11 = matrix1.get(1, 1); - final byte f_c21 = matrix1.get(2, 1); - final byte s_c00 = matrix2.get(0, 0); - final byte s_c10 = matrix2.get(1, 0); - final byte s_c20 = matrix2.get(2, 0); - final byte s_c01 = matrix2.get(0, 1); - final byte s_c11 = matrix2.get(1, 1); - final byte s_c21 = matrix2.get(2, 1); - final byte s_c02 = matrix2.get(0, 2); - final byte s_c12 = matrix2.get(1, 2); - final byte s_c22 = matrix2.get(2, 2); - output.set(0, 0, (byte) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02)); - output.set(0, 1, (byte) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02)); - output.set(1, 0, (byte) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12)); - output.set(1, 1, (byte) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12)); - output.set(2, 0, (byte) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22)); - output.set(2, 1, (byte) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22)); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f21 = matrix1.get(2, 1); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s21 = matrix2.get(2, 1); + final byte s02 = matrix2.get(0, 2); + final byte s12 = matrix2.get(1, 2); + final byte s22 = matrix2.get(2, 2); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11 + f20 * s12)); + output.set(2, 0, (byte) (f00 * s20 + f10 * s21 + f20 * s22)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01 + f21 * s02)); + output.set(1, 1, (byte) (f01 * s10 + f11 * s11 + f21 * s12)); + output.set(2, 1, (byte) (f01 * s20 + f11 * s21 + f21 * s22)); return output; } private static IMatrixSetterByte multiplyMatrix2x3x4(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final byte f_c00 = matrix1.get(0, 0); - final byte f_c10 = matrix1.get(1, 0); - final byte f_c20 = matrix1.get(2, 0); - final byte f_c01 = matrix1.get(0, 1); - final byte f_c11 = matrix1.get(1, 1); - final byte f_c21 = matrix1.get(2, 1); - final byte s_c00 = matrix2.get(0, 0); - final byte s_c10 = matrix2.get(1, 0); - final byte s_c20 = matrix2.get(2, 0); - final byte s_c30 = matrix2.get(3, 0); - final byte s_c01 = matrix2.get(0, 1); - final byte s_c11 = matrix2.get(1, 1); - final byte s_c21 = matrix2.get(2, 1); - final byte s_c31 = matrix2.get(3, 1); - final byte s_c02 = matrix2.get(0, 2); - final byte s_c12 = matrix2.get(1, 2); - final byte s_c22 = matrix2.get(2, 2); - final byte s_c32 = matrix2.get(3, 2); - output.set(0, 0, (byte) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02)); - output.set(0, 1, (byte) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02)); - output.set(1, 0, (byte) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12)); - output.set(1, 1, (byte) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12)); - output.set(2, 0, (byte) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22)); - output.set(2, 1, (byte) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22)); - output.set(3, 0, (byte) (f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32)); - output.set(3, 1, (byte) (f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32)); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f21 = matrix1.get(2, 1); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + final byte s30 = matrix2.get(3, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s21 = matrix2.get(2, 1); + final byte s31 = matrix2.get(3, 1); + final byte s02 = matrix2.get(0, 2); + final byte s12 = matrix2.get(1, 2); + final byte s22 = matrix2.get(2, 2); + final byte s32 = matrix2.get(3, 2); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11 + f20 * s12)); + output.set(2, 0, (byte) (f00 * s20 + f10 * s21 + f20 * s22)); + output.set(3, 0, (byte) (f00 * s30 + f10 * s31 + f20 * s32)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01 + f21 * s02)); + output.set(1, 1, (byte) (f01 * s10 + f11 * s11 + f21 * s12)); + output.set(2, 1, (byte) (f01 * s20 + f11 * s21 + f21 * s22)); + output.set(3, 1, (byte) (f01 * s30 + f11 * s31 + f21 * s32)); return output; } private static IMatrixSetterByte multiplyMatrix2x3x5(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final byte f_c00 = matrix1.get(0, 0); - final byte f_c10 = matrix1.get(1, 0); - final byte f_c20 = matrix1.get(2, 0); - final byte f_c01 = matrix1.get(0, 1); - final byte f_c11 = matrix1.get(1, 1); - final byte f_c21 = matrix1.get(2, 1); - final byte s_c00 = matrix2.get(0, 0); - final byte s_c10 = matrix2.get(1, 0); - final byte s_c20 = matrix2.get(2, 0); - final byte s_c30 = matrix2.get(3, 0); - final byte s_c40 = matrix2.get(4, 0); - final byte s_c01 = matrix2.get(0, 1); - final byte s_c11 = matrix2.get(1, 1); - final byte s_c21 = matrix2.get(2, 1); - final byte s_c31 = matrix2.get(3, 1); - final byte s_c41 = matrix2.get(4, 1); - final byte s_c02 = matrix2.get(0, 2); - final byte s_c12 = matrix2.get(1, 2); - final byte s_c22 = matrix2.get(2, 2); - final byte s_c32 = matrix2.get(3, 2); - final byte s_c42 = matrix2.get(4, 2); - output.set(0, 0, (byte) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02)); - output.set(0, 1, (byte) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02)); - output.set(1, 0, (byte) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12)); - output.set(1, 1, (byte) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12)); - output.set(2, 0, (byte) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22)); - output.set(2, 1, (byte) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22)); - output.set(3, 0, (byte) (f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32)); - output.set(3, 1, (byte) (f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32)); - output.set(4, 0, (byte) (f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42)); - output.set(4, 1, (byte) (f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42)); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f21 = matrix1.get(2, 1); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + final byte s30 = matrix2.get(3, 0); + final byte s40 = matrix2.get(4, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s21 = matrix2.get(2, 1); + final byte s31 = matrix2.get(3, 1); + final byte s41 = matrix2.get(4, 1); + final byte s02 = matrix2.get(0, 2); + final byte s12 = matrix2.get(1, 2); + final byte s22 = matrix2.get(2, 2); + final byte s32 = matrix2.get(3, 2); + final byte s42 = matrix2.get(4, 2); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11 + f20 * s12)); + output.set(2, 0, (byte) (f00 * s20 + f10 * s21 + f20 * s22)); + output.set(3, 0, (byte) (f00 * s30 + f10 * s31 + f20 * s32)); + output.set(4, 0, (byte) (f00 * s40 + f10 * s41 + f20 * s42)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01 + f21 * s02)); + output.set(1, 1, (byte) (f01 * s10 + f11 * s11 + f21 * s12)); + output.set(2, 1, (byte) (f01 * s20 + f11 * s21 + f21 * s22)); + output.set(3, 1, (byte) (f01 * s30 + f11 * s31 + f21 * s32)); + output.set(4, 1, (byte) (f01 * s40 + f11 * s41 + f21 * s42)); + return output; + } + + private static IMatrixSetterByte multiplyMatrix3x3x1(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f21 = matrix1.get(2, 1); + final byte f02 = matrix1.get(0, 2); + final byte f12 = matrix1.get(1, 2); + final byte f22 = matrix1.get(2, 2); + final byte s00 = matrix2.get(0, 0); + final byte s01 = matrix2.get(0, 1); + final byte s02 = matrix2.get(0, 2); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01 + f21 * s02)); + output.set(0, 2, (byte) (f02 * s00 + f12 * s01 + f22 * s02)); return output; } private static IMatrixSetterByte multiplyMatrix3x3x2(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final byte f_c00 = matrix1.get(0, 0); - final byte f_c10 = matrix1.get(1, 0); - final byte f_c20 = matrix1.get(2, 0); - final byte f_c01 = matrix1.get(0, 1); - final byte f_c11 = matrix1.get(1, 1); - final byte f_c21 = matrix1.get(2, 1); - final byte f_c02 = matrix1.get(0, 2); - final byte f_c12 = matrix1.get(1, 2); - final byte f_c22 = matrix1.get(2, 2); - final byte s_c00 = matrix2.get(0, 0); - final byte s_c10 = matrix2.get(1, 0); - final byte s_c01 = matrix2.get(0, 1); - final byte s_c11 = matrix2.get(1, 1); - final byte s_c02 = matrix2.get(0, 2); - final byte s_c12 = matrix2.get(1, 2); - output.set(0, 0, (byte) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02)); - output.set(0, 1, (byte) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02)); - output.set(0, 2, (byte) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02)); - output.set(1, 0, (byte) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12)); - output.set(1, 1, (byte) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12)); - output.set(1, 2, (byte) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12)); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f21 = matrix1.get(2, 1); + final byte f02 = matrix1.get(0, 2); + final byte f12 = matrix1.get(1, 2); + final byte f22 = matrix1.get(2, 2); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s02 = matrix2.get(0, 2); + final byte s12 = matrix2.get(1, 2); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11 + f20 * s12)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01 + f21 * s02)); + output.set(1, 1, (byte) (f01 * s10 + f11 * s11 + f21 * s12)); + output.set(0, 2, (byte) (f02 * s00 + f12 * s01 + f22 * s02)); + output.set(1, 2, (byte) (f02 * s10 + f12 * s11 + f22 * s12)); return output; } private static IMatrixSetterByte multiplyMatrix3x3x3(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final byte f_c00 = matrix1.get(0, 0); - final byte f_c10 = matrix1.get(1, 0); - final byte f_c20 = matrix1.get(2, 0); - final byte f_c01 = matrix1.get(0, 1); - final byte f_c11 = matrix1.get(1, 1); - final byte f_c21 = matrix1.get(2, 1); - final byte f_c02 = matrix1.get(0, 2); - final byte f_c12 = matrix1.get(1, 2); - final byte f_c22 = matrix1.get(2, 2); - final byte s_c00 = matrix2.get(0, 0); - final byte s_c10 = matrix2.get(1, 0); - final byte s_c20 = matrix2.get(2, 0); - final byte s_c01 = matrix2.get(0, 1); - final byte s_c11 = matrix2.get(1, 1); - final byte s_c21 = matrix2.get(2, 1); - final byte s_c02 = matrix2.get(0, 2); - final byte s_c12 = matrix2.get(1, 2); - final byte s_c22 = matrix2.get(2, 2); - output.set(0, 0, (byte) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02)); - output.set(0, 1, (byte) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02)); - output.set(0, 2, (byte) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02)); - output.set(1, 0, (byte) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12)); - output.set(1, 1, (byte) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12)); - output.set(1, 2, (byte) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12)); - output.set(2, 0, (byte) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22)); - output.set(2, 1, (byte) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22)); - output.set(2, 2, (byte) (f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22)); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f21 = matrix1.get(2, 1); + final byte f02 = matrix1.get(0, 2); + final byte f12 = matrix1.get(1, 2); + final byte f22 = matrix1.get(2, 2); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s21 = matrix2.get(2, 1); + final byte s02 = matrix2.get(0, 2); + final byte s12 = matrix2.get(1, 2); + final byte s22 = matrix2.get(2, 2); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11 + f20 * s12)); + output.set(2, 0, (byte) (f00 * s20 + f10 * s21 + f20 * s22)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01 + f21 * s02)); + output.set(1, 1, (byte) (f01 * s10 + f11 * s11 + f21 * s12)); + output.set(2, 1, (byte) (f01 * s20 + f11 * s21 + f21 * s22)); + output.set(0, 2, (byte) (f02 * s00 + f12 * s01 + f22 * s02)); + output.set(1, 2, (byte) (f02 * s10 + f12 * s11 + f22 * s12)); + output.set(2, 2, (byte) (f02 * s20 + f12 * s21 + f22 * s22)); return output; } private static IMatrixSetterByte multiplyMatrix3x3x4(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final byte f_c00 = matrix1.get(0, 0); - final byte f_c10 = matrix1.get(1, 0); - final byte f_c20 = matrix1.get(2, 0); - final byte f_c01 = matrix1.get(0, 1); - final byte f_c11 = matrix1.get(1, 1); - final byte f_c21 = matrix1.get(2, 1); - final byte f_c02 = matrix1.get(0, 2); - final byte f_c12 = matrix1.get(1, 2); - final byte f_c22 = matrix1.get(2, 2); - final byte s_c00 = matrix2.get(0, 0); - final byte s_c10 = matrix2.get(1, 0); - final byte s_c20 = matrix2.get(2, 0); - final byte s_c30 = matrix2.get(3, 0); - final byte s_c01 = matrix2.get(0, 1); - final byte s_c11 = matrix2.get(1, 1); - final byte s_c21 = matrix2.get(2, 1); - final byte s_c31 = matrix2.get(3, 1); - final byte s_c02 = matrix2.get(0, 2); - final byte s_c12 = matrix2.get(1, 2); - final byte s_c22 = matrix2.get(2, 2); - final byte s_c32 = matrix2.get(3, 2); - output.set(0, 0, (byte) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02)); - output.set(0, 1, (byte) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02)); - output.set(0, 2, (byte) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02)); - output.set(1, 0, (byte) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12)); - output.set(1, 1, (byte) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12)); - output.set(1, 2, (byte) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12)); - output.set(2, 0, (byte) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22)); - output.set(2, 1, (byte) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22)); - output.set(2, 2, (byte) (f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22)); - output.set(3, 0, (byte) (f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32)); - output.set(3, 1, (byte) (f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32)); - output.set(3, 2, (byte) (f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32)); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f21 = matrix1.get(2, 1); + final byte f02 = matrix1.get(0, 2); + final byte f12 = matrix1.get(1, 2); + final byte f22 = matrix1.get(2, 2); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + final byte s30 = matrix2.get(3, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s21 = matrix2.get(2, 1); + final byte s31 = matrix2.get(3, 1); + final byte s02 = matrix2.get(0, 2); + final byte s12 = matrix2.get(1, 2); + final byte s22 = matrix2.get(2, 2); + final byte s32 = matrix2.get(3, 2); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11 + f20 * s12)); + output.set(2, 0, (byte) (f00 * s20 + f10 * s21 + f20 * s22)); + output.set(3, 0, (byte) (f00 * s30 + f10 * s31 + f20 * s32)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01 + f21 * s02)); + output.set(1, 1, (byte) (f01 * s10 + f11 * s11 + f21 * s12)); + output.set(2, 1, (byte) (f01 * s20 + f11 * s21 + f21 * s22)); + output.set(3, 1, (byte) (f01 * s30 + f11 * s31 + f21 * s32)); + output.set(0, 2, (byte) (f02 * s00 + f12 * s01 + f22 * s02)); + output.set(1, 2, (byte) (f02 * s10 + f12 * s11 + f22 * s12)); + output.set(2, 2, (byte) (f02 * s20 + f12 * s21 + f22 * s22)); + output.set(3, 2, (byte) (f02 * s30 + f12 * s31 + f22 * s32)); return output; } private static IMatrixSetterByte multiplyMatrix3x3x5(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final byte f_c00 = matrix1.get(0, 0); - final byte f_c10 = matrix1.get(1, 0); - final byte f_c20 = matrix1.get(2, 0); - final byte f_c01 = matrix1.get(0, 1); - final byte f_c11 = matrix1.get(1, 1); - final byte f_c21 = matrix1.get(2, 1); - final byte f_c02 = matrix1.get(0, 2); - final byte f_c12 = matrix1.get(1, 2); - final byte f_c22 = matrix1.get(2, 2); - final byte s_c00 = matrix2.get(0, 0); - final byte s_c10 = matrix2.get(1, 0); - final byte s_c20 = matrix2.get(2, 0); - final byte s_c30 = matrix2.get(3, 0); - final byte s_c40 = matrix2.get(4, 0); - final byte s_c01 = matrix2.get(0, 1); - final byte s_c11 = matrix2.get(1, 1); - final byte s_c21 = matrix2.get(2, 1); - final byte s_c31 = matrix2.get(3, 1); - final byte s_c41 = matrix2.get(4, 1); - final byte s_c02 = matrix2.get(0, 2); - final byte s_c12 = matrix2.get(1, 2); - final byte s_c22 = matrix2.get(2, 2); - final byte s_c32 = matrix2.get(3, 2); - final byte s_c42 = matrix2.get(4, 2); - output.set(0, 0, (byte) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02)); - output.set(0, 1, (byte) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02)); - output.set(0, 2, (byte) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02)); - output.set(1, 0, (byte) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12)); - output.set(1, 1, (byte) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12)); - output.set(1, 2, (byte) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12)); - output.set(2, 0, (byte) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22)); - output.set(2, 1, (byte) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22)); - output.set(2, 2, (byte) (f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22)); - output.set(3, 0, (byte) (f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32)); - output.set(3, 1, (byte) (f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32)); - output.set(3, 2, (byte) (f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32)); - output.set(4, 0, (byte) (f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42)); - output.set(4, 1, (byte) (f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42)); - output.set(4, 2, (byte) (f_c02*s_c40 + f_c12*s_c41 + f_c22*s_c42)); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f21 = matrix1.get(2, 1); + final byte f02 = matrix1.get(0, 2); + final byte f12 = matrix1.get(1, 2); + final byte f22 = matrix1.get(2, 2); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + final byte s30 = matrix2.get(3, 0); + final byte s40 = matrix2.get(4, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s21 = matrix2.get(2, 1); + final byte s31 = matrix2.get(3, 1); + final byte s41 = matrix2.get(4, 1); + final byte s02 = matrix2.get(0, 2); + final byte s12 = matrix2.get(1, 2); + final byte s22 = matrix2.get(2, 2); + final byte s32 = matrix2.get(3, 2); + final byte s42 = matrix2.get(4, 2); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11 + f20 * s12)); + output.set(2, 0, (byte) (f00 * s20 + f10 * s21 + f20 * s22)); + output.set(3, 0, (byte) (f00 * s30 + f10 * s31 + f20 * s32)); + output.set(4, 0, (byte) (f00 * s40 + f10 * s41 + f20 * s42)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01 + f21 * s02)); + output.set(1, 1, (byte) (f01 * s10 + f11 * s11 + f21 * s12)); + output.set(2, 1, (byte) (f01 * s20 + f11 * s21 + f21 * s22)); + output.set(3, 1, (byte) (f01 * s30 + f11 * s31 + f21 * s32)); + output.set(4, 1, (byte) (f01 * s40 + f11 * s41 + f21 * s42)); + output.set(0, 2, (byte) (f02 * s00 + f12 * s01 + f22 * s02)); + output.set(1, 2, (byte) (f02 * s10 + f12 * s11 + f22 * s12)); + output.set(2, 2, (byte) (f02 * s20 + f12 * s21 + f22 * s22)); + output.set(3, 2, (byte) (f02 * s30 + f12 * s31 + f22 * s32)); + output.set(4, 2, (byte) (f02 * s40 + f12 * s41 + f22 * s42)); + return output; + } + + private static IMatrixSetterByte multiplyMatrix4x3x1(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f21 = matrix1.get(2, 1); + final byte f02 = matrix1.get(0, 2); + final byte f12 = matrix1.get(1, 2); + final byte f22 = matrix1.get(2, 2); + final byte f03 = matrix1.get(0, 3); + final byte f13 = matrix1.get(1, 3); + final byte f23 = matrix1.get(2, 3); + final byte s00 = matrix2.get(0, 0); + final byte s01 = matrix2.get(0, 1); + final byte s02 = matrix2.get(0, 2); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01 + f21 * s02)); + output.set(0, 2, (byte) (f02 * s00 + f12 * s01 + f22 * s02)); + output.set(0, 3, (byte) (f03 * s00 + f13 * s01 + f23 * s02)); return output; } private static IMatrixSetterByte multiplyMatrix4x3x2(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final byte f_c00 = matrix1.get(0, 0); - final byte f_c10 = matrix1.get(1, 0); - final byte f_c20 = matrix1.get(2, 0); - final byte f_c01 = matrix1.get(0, 1); - final byte f_c11 = matrix1.get(1, 1); - final byte f_c21 = matrix1.get(2, 1); - final byte f_c02 = matrix1.get(0, 2); - final byte f_c12 = matrix1.get(1, 2); - final byte f_c22 = matrix1.get(2, 2); - final byte f_c03 = matrix1.get(0, 3); - final byte f_c13 = matrix1.get(1, 3); - final byte f_c23 = matrix1.get(2, 3); - final byte s_c00 = matrix2.get(0, 0); - final byte s_c10 = matrix2.get(1, 0); - final byte s_c01 = matrix2.get(0, 1); - final byte s_c11 = matrix2.get(1, 1); - final byte s_c02 = matrix2.get(0, 2); - final byte s_c12 = matrix2.get(1, 2); - output.set(0, 0, (byte) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02)); - output.set(0, 1, (byte) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02)); - output.set(0, 2, (byte) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02)); - output.set(0, 3, (byte) (f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02)); - output.set(1, 0, (byte) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12)); - output.set(1, 1, (byte) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12)); - output.set(1, 2, (byte) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12)); - output.set(1, 3, (byte) (f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12)); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f21 = matrix1.get(2, 1); + final byte f02 = matrix1.get(0, 2); + final byte f12 = matrix1.get(1, 2); + final byte f22 = matrix1.get(2, 2); + final byte f03 = matrix1.get(0, 3); + final byte f13 = matrix1.get(1, 3); + final byte f23 = matrix1.get(2, 3); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s02 = matrix2.get(0, 2); + final byte s12 = matrix2.get(1, 2); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11 + f20 * s12)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01 + f21 * s02)); + output.set(1, 1, (byte) (f01 * s10 + f11 * s11 + f21 * s12)); + output.set(0, 2, (byte) (f02 * s00 + f12 * s01 + f22 * s02)); + output.set(1, 2, (byte) (f02 * s10 + f12 * s11 + f22 * s12)); + output.set(0, 3, (byte) (f03 * s00 + f13 * s01 + f23 * s02)); + output.set(1, 3, (byte) (f03 * s10 + f13 * s11 + f23 * s12)); return output; } private static IMatrixSetterByte multiplyMatrix4x3x3(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final byte f_c00 = matrix1.get(0, 0); - final byte f_c10 = matrix1.get(1, 0); - final byte f_c20 = matrix1.get(2, 0); - final byte f_c01 = matrix1.get(0, 1); - final byte f_c11 = matrix1.get(1, 1); - final byte f_c21 = matrix1.get(2, 1); - final byte f_c02 = matrix1.get(0, 2); - final byte f_c12 = matrix1.get(1, 2); - final byte f_c22 = matrix1.get(2, 2); - final byte f_c03 = matrix1.get(0, 3); - final byte f_c13 = matrix1.get(1, 3); - final byte f_c23 = matrix1.get(2, 3); - final byte s_c00 = matrix2.get(0, 0); - final byte s_c10 = matrix2.get(1, 0); - final byte s_c20 = matrix2.get(2, 0); - final byte s_c01 = matrix2.get(0, 1); - final byte s_c11 = matrix2.get(1, 1); - final byte s_c21 = matrix2.get(2, 1); - final byte s_c02 = matrix2.get(0, 2); - final byte s_c12 = matrix2.get(1, 2); - final byte s_c22 = matrix2.get(2, 2); - output.set(0, 0, (byte) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02)); - output.set(0, 1, (byte) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02)); - output.set(0, 2, (byte) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02)); - output.set(0, 3, (byte) (f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02)); - output.set(1, 0, (byte) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12)); - output.set(1, 1, (byte) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12)); - output.set(1, 2, (byte) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12)); - output.set(1, 3, (byte) (f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12)); - output.set(2, 0, (byte) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22)); - output.set(2, 1, (byte) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22)); - output.set(2, 2, (byte) (f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22)); - output.set(2, 3, (byte) (f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22)); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f21 = matrix1.get(2, 1); + final byte f02 = matrix1.get(0, 2); + final byte f12 = matrix1.get(1, 2); + final byte f22 = matrix1.get(2, 2); + final byte f03 = matrix1.get(0, 3); + final byte f13 = matrix1.get(1, 3); + final byte f23 = matrix1.get(2, 3); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s21 = matrix2.get(2, 1); + final byte s02 = matrix2.get(0, 2); + final byte s12 = matrix2.get(1, 2); + final byte s22 = matrix2.get(2, 2); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11 + f20 * s12)); + output.set(2, 0, (byte) (f00 * s20 + f10 * s21 + f20 * s22)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01 + f21 * s02)); + output.set(1, 1, (byte) (f01 * s10 + f11 * s11 + f21 * s12)); + output.set(2, 1, (byte) (f01 * s20 + f11 * s21 + f21 * s22)); + output.set(0, 2, (byte) (f02 * s00 + f12 * s01 + f22 * s02)); + output.set(1, 2, (byte) (f02 * s10 + f12 * s11 + f22 * s12)); + output.set(2, 2, (byte) (f02 * s20 + f12 * s21 + f22 * s22)); + output.set(0, 3, (byte) (f03 * s00 + f13 * s01 + f23 * s02)); + output.set(1, 3, (byte) (f03 * s10 + f13 * s11 + f23 * s12)); + output.set(2, 3, (byte) (f03 * s20 + f13 * s21 + f23 * s22)); return output; } private static IMatrixSetterByte multiplyMatrix4x3x4(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final byte f_c00 = matrix1.get(0, 0); - final byte f_c10 = matrix1.get(1, 0); - final byte f_c20 = matrix1.get(2, 0); - final byte f_c01 = matrix1.get(0, 1); - final byte f_c11 = matrix1.get(1, 1); - final byte f_c21 = matrix1.get(2, 1); - final byte f_c02 = matrix1.get(0, 2); - final byte f_c12 = matrix1.get(1, 2); - final byte f_c22 = matrix1.get(2, 2); - final byte f_c03 = matrix1.get(0, 3); - final byte f_c13 = matrix1.get(1, 3); - final byte f_c23 = matrix1.get(2, 3); - final byte s_c00 = matrix2.get(0, 0); - final byte s_c10 = matrix2.get(1, 0); - final byte s_c20 = matrix2.get(2, 0); - final byte s_c30 = matrix2.get(3, 0); - final byte s_c01 = matrix2.get(0, 1); - final byte s_c11 = matrix2.get(1, 1); - final byte s_c21 = matrix2.get(2, 1); - final byte s_c31 = matrix2.get(3, 1); - final byte s_c02 = matrix2.get(0, 2); - final byte s_c12 = matrix2.get(1, 2); - final byte s_c22 = matrix2.get(2, 2); - final byte s_c32 = matrix2.get(3, 2); - output.set(0, 0, (byte) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02)); - output.set(0, 1, (byte) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02)); - output.set(0, 2, (byte) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02)); - output.set(0, 3, (byte) (f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02)); - output.set(1, 0, (byte) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12)); - output.set(1, 1, (byte) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12)); - output.set(1, 2, (byte) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12)); - output.set(1, 3, (byte) (f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12)); - output.set(2, 0, (byte) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22)); - output.set(2, 1, (byte) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22)); - output.set(2, 2, (byte) (f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22)); - output.set(2, 3, (byte) (f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22)); - output.set(3, 0, (byte) (f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32)); - output.set(3, 1, (byte) (f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32)); - output.set(3, 2, (byte) (f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32)); - output.set(3, 3, (byte) (f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32)); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f21 = matrix1.get(2, 1); + final byte f02 = matrix1.get(0, 2); + final byte f12 = matrix1.get(1, 2); + final byte f22 = matrix1.get(2, 2); + final byte f03 = matrix1.get(0, 3); + final byte f13 = matrix1.get(1, 3); + final byte f23 = matrix1.get(2, 3); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + final byte s30 = matrix2.get(3, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s21 = matrix2.get(2, 1); + final byte s31 = matrix2.get(3, 1); + final byte s02 = matrix2.get(0, 2); + final byte s12 = matrix2.get(1, 2); + final byte s22 = matrix2.get(2, 2); + final byte s32 = matrix2.get(3, 2); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11 + f20 * s12)); + output.set(2, 0, (byte) (f00 * s20 + f10 * s21 + f20 * s22)); + output.set(3, 0, (byte) (f00 * s30 + f10 * s31 + f20 * s32)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01 + f21 * s02)); + output.set(1, 1, (byte) (f01 * s10 + f11 * s11 + f21 * s12)); + output.set(2, 1, (byte) (f01 * s20 + f11 * s21 + f21 * s22)); + output.set(3, 1, (byte) (f01 * s30 + f11 * s31 + f21 * s32)); + output.set(0, 2, (byte) (f02 * s00 + f12 * s01 + f22 * s02)); + output.set(1, 2, (byte) (f02 * s10 + f12 * s11 + f22 * s12)); + output.set(2, 2, (byte) (f02 * s20 + f12 * s21 + f22 * s22)); + output.set(3, 2, (byte) (f02 * s30 + f12 * s31 + f22 * s32)); + output.set(0, 3, (byte) (f03 * s00 + f13 * s01 + f23 * s02)); + output.set(1, 3, (byte) (f03 * s10 + f13 * s11 + f23 * s12)); + output.set(2, 3, (byte) (f03 * s20 + f13 * s21 + f23 * s22)); + output.set(3, 3, (byte) (f03 * s30 + f13 * s31 + f23 * s32)); return output; } private static IMatrixSetterByte multiplyMatrix4x3x5(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final byte f_c00 = matrix1.get(0, 0); - final byte f_c10 = matrix1.get(1, 0); - final byte f_c20 = matrix1.get(2, 0); - final byte f_c01 = matrix1.get(0, 1); - final byte f_c11 = matrix1.get(1, 1); - final byte f_c21 = matrix1.get(2, 1); - final byte f_c02 = matrix1.get(0, 2); - final byte f_c12 = matrix1.get(1, 2); - final byte f_c22 = matrix1.get(2, 2); - final byte f_c03 = matrix1.get(0, 3); - final byte f_c13 = matrix1.get(1, 3); - final byte f_c23 = matrix1.get(2, 3); - final byte s_c00 = matrix2.get(0, 0); - final byte s_c10 = matrix2.get(1, 0); - final byte s_c20 = matrix2.get(2, 0); - final byte s_c30 = matrix2.get(3, 0); - final byte s_c40 = matrix2.get(4, 0); - final byte s_c01 = matrix2.get(0, 1); - final byte s_c11 = matrix2.get(1, 1); - final byte s_c21 = matrix2.get(2, 1); - final byte s_c31 = matrix2.get(3, 1); - final byte s_c41 = matrix2.get(4, 1); - final byte s_c02 = matrix2.get(0, 2); - final byte s_c12 = matrix2.get(1, 2); - final byte s_c22 = matrix2.get(2, 2); - final byte s_c32 = matrix2.get(3, 2); - final byte s_c42 = matrix2.get(4, 2); - output.set(0, 0, (byte) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02)); - output.set(0, 1, (byte) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02)); - output.set(0, 2, (byte) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02)); - output.set(0, 3, (byte) (f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02)); - output.set(1, 0, (byte) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12)); - output.set(1, 1, (byte) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12)); - output.set(1, 2, (byte) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12)); - output.set(1, 3, (byte) (f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12)); - output.set(2, 0, (byte) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22)); - output.set(2, 1, (byte) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22)); - output.set(2, 2, (byte) (f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22)); - output.set(2, 3, (byte) (f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22)); - output.set(3, 0, (byte) (f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32)); - output.set(3, 1, (byte) (f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32)); - output.set(3, 2, (byte) (f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32)); - output.set(3, 3, (byte) (f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32)); - output.set(4, 0, (byte) (f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42)); - output.set(4, 1, (byte) (f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42)); - output.set(4, 2, (byte) (f_c02*s_c40 + f_c12*s_c41 + f_c22*s_c42)); - output.set(4, 3, (byte) (f_c03*s_c40 + f_c13*s_c41 + f_c23*s_c42)); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f21 = matrix1.get(2, 1); + final byte f02 = matrix1.get(0, 2); + final byte f12 = matrix1.get(1, 2); + final byte f22 = matrix1.get(2, 2); + final byte f03 = matrix1.get(0, 3); + final byte f13 = matrix1.get(1, 3); + final byte f23 = matrix1.get(2, 3); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + final byte s30 = matrix2.get(3, 0); + final byte s40 = matrix2.get(4, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s21 = matrix2.get(2, 1); + final byte s31 = matrix2.get(3, 1); + final byte s41 = matrix2.get(4, 1); + final byte s02 = matrix2.get(0, 2); + final byte s12 = matrix2.get(1, 2); + final byte s22 = matrix2.get(2, 2); + final byte s32 = matrix2.get(3, 2); + final byte s42 = matrix2.get(4, 2); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11 + f20 * s12)); + output.set(2, 0, (byte) (f00 * s20 + f10 * s21 + f20 * s22)); + output.set(3, 0, (byte) (f00 * s30 + f10 * s31 + f20 * s32)); + output.set(4, 0, (byte) (f00 * s40 + f10 * s41 + f20 * s42)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01 + f21 * s02)); + output.set(1, 1, (byte) (f01 * s10 + f11 * s11 + f21 * s12)); + output.set(2, 1, (byte) (f01 * s20 + f11 * s21 + f21 * s22)); + output.set(3, 1, (byte) (f01 * s30 + f11 * s31 + f21 * s32)); + output.set(4, 1, (byte) (f01 * s40 + f11 * s41 + f21 * s42)); + output.set(0, 2, (byte) (f02 * s00 + f12 * s01 + f22 * s02)); + output.set(1, 2, (byte) (f02 * s10 + f12 * s11 + f22 * s12)); + output.set(2, 2, (byte) (f02 * s20 + f12 * s21 + f22 * s22)); + output.set(3, 2, (byte) (f02 * s30 + f12 * s31 + f22 * s32)); + output.set(4, 2, (byte) (f02 * s40 + f12 * s41 + f22 * s42)); + output.set(0, 3, (byte) (f03 * s00 + f13 * s01 + f23 * s02)); + output.set(1, 3, (byte) (f03 * s10 + f13 * s11 + f23 * s12)); + output.set(2, 3, (byte) (f03 * s20 + f13 * s21 + f23 * s22)); + output.set(3, 3, (byte) (f03 * s30 + f13 * s31 + f23 * s32)); + output.set(4, 3, (byte) (f03 * s40 + f13 * s41 + f23 * s42)); + return output; + } + + private static IMatrixSetterByte multiplyMatrix5x3x1(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f21 = matrix1.get(2, 1); + final byte f02 = matrix1.get(0, 2); + final byte f12 = matrix1.get(1, 2); + final byte f22 = matrix1.get(2, 2); + final byte f03 = matrix1.get(0, 3); + final byte f13 = matrix1.get(1, 3); + final byte f23 = matrix1.get(2, 3); + final byte f04 = matrix1.get(0, 4); + final byte f14 = matrix1.get(1, 4); + final byte f24 = matrix1.get(2, 4); + final byte s00 = matrix2.get(0, 0); + final byte s01 = matrix2.get(0, 1); + final byte s02 = matrix2.get(0, 2); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01 + f21 * s02)); + output.set(0, 2, (byte) (f02 * s00 + f12 * s01 + f22 * s02)); + output.set(0, 3, (byte) (f03 * s00 + f13 * s01 + f23 * s02)); + output.set(0, 4, (byte) (f04 * s00 + f14 * s01 + f24 * s02)); return output; } private static IMatrixSetterByte multiplyMatrix5x3x2(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final byte f_c00 = matrix1.get(0, 0); - final byte f_c10 = matrix1.get(1, 0); - final byte f_c20 = matrix1.get(2, 0); - final byte f_c01 = matrix1.get(0, 1); - final byte f_c11 = matrix1.get(1, 1); - final byte f_c21 = matrix1.get(2, 1); - final byte f_c02 = matrix1.get(0, 2); - final byte f_c12 = matrix1.get(1, 2); - final byte f_c22 = matrix1.get(2, 2); - final byte f_c03 = matrix1.get(0, 3); - final byte f_c13 = matrix1.get(1, 3); - final byte f_c23 = matrix1.get(2, 3); - final byte f_c04 = matrix1.get(0, 4); - final byte f_c14 = matrix1.get(1, 4); - final byte f_c24 = matrix1.get(2, 4); - final byte s_c00 = matrix2.get(0, 0); - final byte s_c10 = matrix2.get(1, 0); - final byte s_c01 = matrix2.get(0, 1); - final byte s_c11 = matrix2.get(1, 1); - final byte s_c02 = matrix2.get(0, 2); - final byte s_c12 = matrix2.get(1, 2); - output.set(0, 0, (byte) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02)); - output.set(0, 1, (byte) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02)); - output.set(0, 2, (byte) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02)); - output.set(0, 3, (byte) (f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02)); - output.set(0, 4, (byte) (f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02)); - output.set(1, 0, (byte) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12)); - output.set(1, 1, (byte) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12)); - output.set(1, 2, (byte) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12)); - output.set(1, 3, (byte) (f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12)); - output.set(1, 4, (byte) (f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12)); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f21 = matrix1.get(2, 1); + final byte f02 = matrix1.get(0, 2); + final byte f12 = matrix1.get(1, 2); + final byte f22 = matrix1.get(2, 2); + final byte f03 = matrix1.get(0, 3); + final byte f13 = matrix1.get(1, 3); + final byte f23 = matrix1.get(2, 3); + final byte f04 = matrix1.get(0, 4); + final byte f14 = matrix1.get(1, 4); + final byte f24 = matrix1.get(2, 4); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s02 = matrix2.get(0, 2); + final byte s12 = matrix2.get(1, 2); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11 + f20 * s12)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01 + f21 * s02)); + output.set(1, 1, (byte) (f01 * s10 + f11 * s11 + f21 * s12)); + output.set(0, 2, (byte) (f02 * s00 + f12 * s01 + f22 * s02)); + output.set(1, 2, (byte) (f02 * s10 + f12 * s11 + f22 * s12)); + output.set(0, 3, (byte) (f03 * s00 + f13 * s01 + f23 * s02)); + output.set(1, 3, (byte) (f03 * s10 + f13 * s11 + f23 * s12)); + output.set(0, 4, (byte) (f04 * s00 + f14 * s01 + f24 * s02)); + output.set(1, 4, (byte) (f04 * s10 + f14 * s11 + f24 * s12)); return output; } private static IMatrixSetterByte multiplyMatrix5x3x3(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final byte f_c00 = matrix1.get(0, 0); - final byte f_c10 = matrix1.get(1, 0); - final byte f_c20 = matrix1.get(2, 0); - final byte f_c01 = matrix1.get(0, 1); - final byte f_c11 = matrix1.get(1, 1); - final byte f_c21 = matrix1.get(2, 1); - final byte f_c02 = matrix1.get(0, 2); - final byte f_c12 = matrix1.get(1, 2); - final byte f_c22 = matrix1.get(2, 2); - final byte f_c03 = matrix1.get(0, 3); - final byte f_c13 = matrix1.get(1, 3); - final byte f_c23 = matrix1.get(2, 3); - final byte f_c04 = matrix1.get(0, 4); - final byte f_c14 = matrix1.get(1, 4); - final byte f_c24 = matrix1.get(2, 4); - final byte s_c00 = matrix2.get(0, 0); - final byte s_c10 = matrix2.get(1, 0); - final byte s_c20 = matrix2.get(2, 0); - final byte s_c01 = matrix2.get(0, 1); - final byte s_c11 = matrix2.get(1, 1); - final byte s_c21 = matrix2.get(2, 1); - final byte s_c02 = matrix2.get(0, 2); - final byte s_c12 = matrix2.get(1, 2); - final byte s_c22 = matrix2.get(2, 2); - output.set(0, 0, (byte) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02)); - output.set(0, 1, (byte) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02)); - output.set(0, 2, (byte) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02)); - output.set(0, 3, (byte) (f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02)); - output.set(0, 4, (byte) (f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02)); - output.set(1, 0, (byte) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12)); - output.set(1, 1, (byte) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12)); - output.set(1, 2, (byte) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12)); - output.set(1, 3, (byte) (f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12)); - output.set(1, 4, (byte) (f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12)); - output.set(2, 0, (byte) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22)); - output.set(2, 1, (byte) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22)); - output.set(2, 2, (byte) (f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22)); - output.set(2, 3, (byte) (f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22)); - output.set(2, 4, (byte) (f_c04*s_c20 + f_c14*s_c21 + f_c24*s_c22)); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f21 = matrix1.get(2, 1); + final byte f02 = matrix1.get(0, 2); + final byte f12 = matrix1.get(1, 2); + final byte f22 = matrix1.get(2, 2); + final byte f03 = matrix1.get(0, 3); + final byte f13 = matrix1.get(1, 3); + final byte f23 = matrix1.get(2, 3); + final byte f04 = matrix1.get(0, 4); + final byte f14 = matrix1.get(1, 4); + final byte f24 = matrix1.get(2, 4); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s21 = matrix2.get(2, 1); + final byte s02 = matrix2.get(0, 2); + final byte s12 = matrix2.get(1, 2); + final byte s22 = matrix2.get(2, 2); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11 + f20 * s12)); + output.set(2, 0, (byte) (f00 * s20 + f10 * s21 + f20 * s22)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01 + f21 * s02)); + output.set(1, 1, (byte) (f01 * s10 + f11 * s11 + f21 * s12)); + output.set(2, 1, (byte) (f01 * s20 + f11 * s21 + f21 * s22)); + output.set(0, 2, (byte) (f02 * s00 + f12 * s01 + f22 * s02)); + output.set(1, 2, (byte) (f02 * s10 + f12 * s11 + f22 * s12)); + output.set(2, 2, (byte) (f02 * s20 + f12 * s21 + f22 * s22)); + output.set(0, 3, (byte) (f03 * s00 + f13 * s01 + f23 * s02)); + output.set(1, 3, (byte) (f03 * s10 + f13 * s11 + f23 * s12)); + output.set(2, 3, (byte) (f03 * s20 + f13 * s21 + f23 * s22)); + output.set(0, 4, (byte) (f04 * s00 + f14 * s01 + f24 * s02)); + output.set(1, 4, (byte) (f04 * s10 + f14 * s11 + f24 * s12)); + output.set(2, 4, (byte) (f04 * s20 + f14 * s21 + f24 * s22)); return output; } private static IMatrixSetterByte multiplyMatrix5x3x4(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final byte f_c00 = matrix1.get(0, 0); - final byte f_c10 = matrix1.get(1, 0); - final byte f_c20 = matrix1.get(2, 0); - final byte f_c01 = matrix1.get(0, 1); - final byte f_c11 = matrix1.get(1, 1); - final byte f_c21 = matrix1.get(2, 1); - final byte f_c02 = matrix1.get(0, 2); - final byte f_c12 = matrix1.get(1, 2); - final byte f_c22 = matrix1.get(2, 2); - final byte f_c03 = matrix1.get(0, 3); - final byte f_c13 = matrix1.get(1, 3); - final byte f_c23 = matrix1.get(2, 3); - final byte f_c04 = matrix1.get(0, 4); - final byte f_c14 = matrix1.get(1, 4); - final byte f_c24 = matrix1.get(2, 4); - final byte s_c00 = matrix2.get(0, 0); - final byte s_c10 = matrix2.get(1, 0); - final byte s_c20 = matrix2.get(2, 0); - final byte s_c30 = matrix2.get(3, 0); - final byte s_c01 = matrix2.get(0, 1); - final byte s_c11 = matrix2.get(1, 1); - final byte s_c21 = matrix2.get(2, 1); - final byte s_c31 = matrix2.get(3, 1); - final byte s_c02 = matrix2.get(0, 2); - final byte s_c12 = matrix2.get(1, 2); - final byte s_c22 = matrix2.get(2, 2); - final byte s_c32 = matrix2.get(3, 2); - output.set(0, 0, (byte) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02)); - output.set(0, 1, (byte) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02)); - output.set(0, 2, (byte) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02)); - output.set(0, 3, (byte) (f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02)); - output.set(0, 4, (byte) (f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02)); - output.set(1, 0, (byte) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12)); - output.set(1, 1, (byte) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12)); - output.set(1, 2, (byte) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12)); - output.set(1, 3, (byte) (f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12)); - output.set(1, 4, (byte) (f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12)); - output.set(2, 0, (byte) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22)); - output.set(2, 1, (byte) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22)); - output.set(2, 2, (byte) (f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22)); - output.set(2, 3, (byte) (f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22)); - output.set(2, 4, (byte) (f_c04*s_c20 + f_c14*s_c21 + f_c24*s_c22)); - output.set(3, 0, (byte) (f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32)); - output.set(3, 1, (byte) (f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32)); - output.set(3, 2, (byte) (f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32)); - output.set(3, 3, (byte) (f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32)); - output.set(3, 4, (byte) (f_c04*s_c30 + f_c14*s_c31 + f_c24*s_c32)); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f21 = matrix1.get(2, 1); + final byte f02 = matrix1.get(0, 2); + final byte f12 = matrix1.get(1, 2); + final byte f22 = matrix1.get(2, 2); + final byte f03 = matrix1.get(0, 3); + final byte f13 = matrix1.get(1, 3); + final byte f23 = matrix1.get(2, 3); + final byte f04 = matrix1.get(0, 4); + final byte f14 = matrix1.get(1, 4); + final byte f24 = matrix1.get(2, 4); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + final byte s30 = matrix2.get(3, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s21 = matrix2.get(2, 1); + final byte s31 = matrix2.get(3, 1); + final byte s02 = matrix2.get(0, 2); + final byte s12 = matrix2.get(1, 2); + final byte s22 = matrix2.get(2, 2); + final byte s32 = matrix2.get(3, 2); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11 + f20 * s12)); + output.set(2, 0, (byte) (f00 * s20 + f10 * s21 + f20 * s22)); + output.set(3, 0, (byte) (f00 * s30 + f10 * s31 + f20 * s32)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01 + f21 * s02)); + output.set(1, 1, (byte) (f01 * s10 + f11 * s11 + f21 * s12)); + output.set(2, 1, (byte) (f01 * s20 + f11 * s21 + f21 * s22)); + output.set(3, 1, (byte) (f01 * s30 + f11 * s31 + f21 * s32)); + output.set(0, 2, (byte) (f02 * s00 + f12 * s01 + f22 * s02)); + output.set(1, 2, (byte) (f02 * s10 + f12 * s11 + f22 * s12)); + output.set(2, 2, (byte) (f02 * s20 + f12 * s21 + f22 * s22)); + output.set(3, 2, (byte) (f02 * s30 + f12 * s31 + f22 * s32)); + output.set(0, 3, (byte) (f03 * s00 + f13 * s01 + f23 * s02)); + output.set(1, 3, (byte) (f03 * s10 + f13 * s11 + f23 * s12)); + output.set(2, 3, (byte) (f03 * s20 + f13 * s21 + f23 * s22)); + output.set(3, 3, (byte) (f03 * s30 + f13 * s31 + f23 * s32)); + output.set(0, 4, (byte) (f04 * s00 + f14 * s01 + f24 * s02)); + output.set(1, 4, (byte) (f04 * s10 + f14 * s11 + f24 * s12)); + output.set(2, 4, (byte) (f04 * s20 + f14 * s21 + f24 * s22)); + output.set(3, 4, (byte) (f04 * s30 + f14 * s31 + f24 * s32)); return output; } private static IMatrixSetterByte multiplyMatrix5x3x5(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final byte f_c00 = matrix1.get(0, 0); - final byte f_c10 = matrix1.get(1, 0); - final byte f_c20 = matrix1.get(2, 0); - final byte f_c01 = matrix1.get(0, 1); - final byte f_c11 = matrix1.get(1, 1); - final byte f_c21 = matrix1.get(2, 1); - final byte f_c02 = matrix1.get(0, 2); - final byte f_c12 = matrix1.get(1, 2); - final byte f_c22 = matrix1.get(2, 2); - final byte f_c03 = matrix1.get(0, 3); - final byte f_c13 = matrix1.get(1, 3); - final byte f_c23 = matrix1.get(2, 3); - final byte f_c04 = matrix1.get(0, 4); - final byte f_c14 = matrix1.get(1, 4); - final byte f_c24 = matrix1.get(2, 4); - final byte s_c00 = matrix2.get(0, 0); - final byte s_c10 = matrix2.get(1, 0); - final byte s_c20 = matrix2.get(2, 0); - final byte s_c30 = matrix2.get(3, 0); - final byte s_c40 = matrix2.get(4, 0); - final byte s_c01 = matrix2.get(0, 1); - final byte s_c11 = matrix2.get(1, 1); - final byte s_c21 = matrix2.get(2, 1); - final byte s_c31 = matrix2.get(3, 1); - final byte s_c41 = matrix2.get(4, 1); - final byte s_c02 = matrix2.get(0, 2); - final byte s_c12 = matrix2.get(1, 2); - final byte s_c22 = matrix2.get(2, 2); - final byte s_c32 = matrix2.get(3, 2); - final byte s_c42 = matrix2.get(4, 2); - output.set(0, 0, (byte) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02)); - output.set(0, 1, (byte) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02)); - output.set(0, 2, (byte) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02)); - output.set(0, 3, (byte) (f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02)); - output.set(0, 4, (byte) (f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02)); - output.set(1, 0, (byte) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12)); - output.set(1, 1, (byte) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12)); - output.set(1, 2, (byte) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12)); - output.set(1, 3, (byte) (f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12)); - output.set(1, 4, (byte) (f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12)); - output.set(2, 0, (byte) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22)); - output.set(2, 1, (byte) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22)); - output.set(2, 2, (byte) (f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22)); - output.set(2, 3, (byte) (f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22)); - output.set(2, 4, (byte) (f_c04*s_c20 + f_c14*s_c21 + f_c24*s_c22)); - output.set(3, 0, (byte) (f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32)); - output.set(3, 1, (byte) (f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32)); - output.set(3, 2, (byte) (f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32)); - output.set(3, 3, (byte) (f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32)); - output.set(3, 4, (byte) (f_c04*s_c30 + f_c14*s_c31 + f_c24*s_c32)); - output.set(4, 0, (byte) (f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42)); - output.set(4, 1, (byte) (f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42)); - output.set(4, 2, (byte) (f_c02*s_c40 + f_c12*s_c41 + f_c22*s_c42)); - output.set(4, 3, (byte) (f_c03*s_c40 + f_c13*s_c41 + f_c23*s_c42)); - output.set(4, 4, (byte) (f_c04*s_c40 + f_c14*s_c41 + f_c24*s_c42)); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f21 = matrix1.get(2, 1); + final byte f02 = matrix1.get(0, 2); + final byte f12 = matrix1.get(1, 2); + final byte f22 = matrix1.get(2, 2); + final byte f03 = matrix1.get(0, 3); + final byte f13 = matrix1.get(1, 3); + final byte f23 = matrix1.get(2, 3); + final byte f04 = matrix1.get(0, 4); + final byte f14 = matrix1.get(1, 4); + final byte f24 = matrix1.get(2, 4); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + final byte s30 = matrix2.get(3, 0); + final byte s40 = matrix2.get(4, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s21 = matrix2.get(2, 1); + final byte s31 = matrix2.get(3, 1); + final byte s41 = matrix2.get(4, 1); + final byte s02 = matrix2.get(0, 2); + final byte s12 = matrix2.get(1, 2); + final byte s22 = matrix2.get(2, 2); + final byte s32 = matrix2.get(3, 2); + final byte s42 = matrix2.get(4, 2); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11 + f20 * s12)); + output.set(2, 0, (byte) (f00 * s20 + f10 * s21 + f20 * s22)); + output.set(3, 0, (byte) (f00 * s30 + f10 * s31 + f20 * s32)); + output.set(4, 0, (byte) (f00 * s40 + f10 * s41 + f20 * s42)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01 + f21 * s02)); + output.set(1, 1, (byte) (f01 * s10 + f11 * s11 + f21 * s12)); + output.set(2, 1, (byte) (f01 * s20 + f11 * s21 + f21 * s22)); + output.set(3, 1, (byte) (f01 * s30 + f11 * s31 + f21 * s32)); + output.set(4, 1, (byte) (f01 * s40 + f11 * s41 + f21 * s42)); + output.set(0, 2, (byte) (f02 * s00 + f12 * s01 + f22 * s02)); + output.set(1, 2, (byte) (f02 * s10 + f12 * s11 + f22 * s12)); + output.set(2, 2, (byte) (f02 * s20 + f12 * s21 + f22 * s22)); + output.set(3, 2, (byte) (f02 * s30 + f12 * s31 + f22 * s32)); + output.set(4, 2, (byte) (f02 * s40 + f12 * s41 + f22 * s42)); + output.set(0, 3, (byte) (f03 * s00 + f13 * s01 + f23 * s02)); + output.set(1, 3, (byte) (f03 * s10 + f13 * s11 + f23 * s12)); + output.set(2, 3, (byte) (f03 * s20 + f13 * s21 + f23 * s22)); + output.set(3, 3, (byte) (f03 * s30 + f13 * s31 + f23 * s32)); + output.set(4, 3, (byte) (f03 * s40 + f13 * s41 + f23 * s42)); + output.set(0, 4, (byte) (f04 * s00 + f14 * s01 + f24 * s02)); + output.set(1, 4, (byte) (f04 * s10 + f14 * s11 + f24 * s12)); + output.set(2, 4, (byte) (f04 * s20 + f14 * s21 + f24 * s22)); + output.set(3, 4, (byte) (f04 * s30 + f14 * s31 + f24 * s32)); + output.set(4, 4, (byte) (f04 * s40 + f14 * s41 + f24 * s42)); + return output; + } + + private static IMatrixSetterByte multiplyMatrix1x4x1(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte f30 = matrix1.get(3, 0); + final byte s00 = matrix2.get(0, 0); + final byte s01 = matrix2.get(0, 1); + final byte s02 = matrix2.get(0, 2); + final byte s03 = matrix2.get(0, 3); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03)); + return output; + } + + private static IMatrixSetterByte multiplyMatrix1x4x2(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte f30 = matrix1.get(3, 0); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s02 = matrix2.get(0, 2); + final byte s12 = matrix2.get(1, 2); + final byte s03 = matrix2.get(0, 3); + final byte s13 = matrix2.get(1, 3); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13)); + return output; + } + + private static IMatrixSetterByte multiplyMatrix1x4x3(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte f30 = matrix1.get(3, 0); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s21 = matrix2.get(2, 1); + final byte s02 = matrix2.get(0, 2); + final byte s12 = matrix2.get(1, 2); + final byte s22 = matrix2.get(2, 2); + final byte s03 = matrix2.get(0, 3); + final byte s13 = matrix2.get(1, 3); + final byte s23 = matrix2.get(2, 3); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13)); + output.set(2, 0, (byte) (f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23)); + return output; + } + + private static IMatrixSetterByte multiplyMatrix1x4x4(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte f30 = matrix1.get(3, 0); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + final byte s30 = matrix2.get(3, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s21 = matrix2.get(2, 1); + final byte s31 = matrix2.get(3, 1); + final byte s02 = matrix2.get(0, 2); + final byte s12 = matrix2.get(1, 2); + final byte s22 = matrix2.get(2, 2); + final byte s32 = matrix2.get(3, 2); + final byte s03 = matrix2.get(0, 3); + final byte s13 = matrix2.get(1, 3); + final byte s23 = matrix2.get(2, 3); + final byte s33 = matrix2.get(3, 3); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13)); + output.set(2, 0, (byte) (f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23)); + output.set(3, 0, (byte) (f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33)); + return output; + } + + private static IMatrixSetterByte multiplyMatrix1x4x5(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte f30 = matrix1.get(3, 0); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + final byte s30 = matrix2.get(3, 0); + final byte s40 = matrix2.get(4, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s21 = matrix2.get(2, 1); + final byte s31 = matrix2.get(3, 1); + final byte s41 = matrix2.get(4, 1); + final byte s02 = matrix2.get(0, 2); + final byte s12 = matrix2.get(1, 2); + final byte s22 = matrix2.get(2, 2); + final byte s32 = matrix2.get(3, 2); + final byte s42 = matrix2.get(4, 2); + final byte s03 = matrix2.get(0, 3); + final byte s13 = matrix2.get(1, 3); + final byte s23 = matrix2.get(2, 3); + final byte s33 = matrix2.get(3, 3); + final byte s43 = matrix2.get(4, 3); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13)); + output.set(2, 0, (byte) (f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23)); + output.set(3, 0, (byte) (f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33)); + output.set(4, 0, (byte) (f00 * s40 + f10 * s41 + f20 * s42 + f30 * s43)); + return output; + } + + private static IMatrixSetterByte multiplyMatrix2x4x1(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte f30 = matrix1.get(3, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f21 = matrix1.get(2, 1); + final byte f31 = matrix1.get(3, 1); + final byte s00 = matrix2.get(0, 0); + final byte s01 = matrix2.get(0, 1); + final byte s02 = matrix2.get(0, 2); + final byte s03 = matrix2.get(0, 3); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03)); return output; } private static IMatrixSetterByte multiplyMatrix2x4x2(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final byte f_c00 = matrix1.get(0, 0); - final byte f_c10 = matrix1.get(1, 0); - final byte f_c20 = matrix1.get(2, 0); - final byte f_c30 = matrix1.get(3, 0); - final byte f_c01 = matrix1.get(0, 1); - final byte f_c11 = matrix1.get(1, 1); - final byte f_c21 = matrix1.get(2, 1); - final byte f_c31 = matrix1.get(3, 1); - final byte s_c00 = matrix2.get(0, 0); - final byte s_c10 = matrix2.get(1, 0); - final byte s_c01 = matrix2.get(0, 1); - final byte s_c11 = matrix2.get(1, 1); - final byte s_c02 = matrix2.get(0, 2); - final byte s_c12 = matrix2.get(1, 2); - final byte s_c03 = matrix2.get(0, 3); - final byte s_c13 = matrix2.get(1, 3); - output.set(0, 0, (byte) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03)); - output.set(0, 1, (byte) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03)); - output.set(1, 0, (byte) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13)); - output.set(1, 1, (byte) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13)); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte f30 = matrix1.get(3, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f21 = matrix1.get(2, 1); + final byte f31 = matrix1.get(3, 1); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s02 = matrix2.get(0, 2); + final byte s12 = matrix2.get(1, 2); + final byte s03 = matrix2.get(0, 3); + final byte s13 = matrix2.get(1, 3); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03)); + output.set(1, 1, (byte) (f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13)); return output; } private static IMatrixSetterByte multiplyMatrix2x4x3(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final byte f_c00 = matrix1.get(0, 0); - final byte f_c10 = matrix1.get(1, 0); - final byte f_c20 = matrix1.get(2, 0); - final byte f_c30 = matrix1.get(3, 0); - final byte f_c01 = matrix1.get(0, 1); - final byte f_c11 = matrix1.get(1, 1); - final byte f_c21 = matrix1.get(2, 1); - final byte f_c31 = matrix1.get(3, 1); - final byte s_c00 = matrix2.get(0, 0); - final byte s_c10 = matrix2.get(1, 0); - final byte s_c20 = matrix2.get(2, 0); - final byte s_c01 = matrix2.get(0, 1); - final byte s_c11 = matrix2.get(1, 1); - final byte s_c21 = matrix2.get(2, 1); - final byte s_c02 = matrix2.get(0, 2); - final byte s_c12 = matrix2.get(1, 2); - final byte s_c22 = matrix2.get(2, 2); - final byte s_c03 = matrix2.get(0, 3); - final byte s_c13 = matrix2.get(1, 3); - final byte s_c23 = matrix2.get(2, 3); - output.set(0, 0, (byte) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03)); - output.set(0, 1, (byte) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03)); - output.set(1, 0, (byte) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13)); - output.set(1, 1, (byte) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13)); - output.set(2, 0, (byte) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23)); - output.set(2, 1, (byte) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23)); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte f30 = matrix1.get(3, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f21 = matrix1.get(2, 1); + final byte f31 = matrix1.get(3, 1); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s21 = matrix2.get(2, 1); + final byte s02 = matrix2.get(0, 2); + final byte s12 = matrix2.get(1, 2); + final byte s22 = matrix2.get(2, 2); + final byte s03 = matrix2.get(0, 3); + final byte s13 = matrix2.get(1, 3); + final byte s23 = matrix2.get(2, 3); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13)); + output.set(2, 0, (byte) (f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03)); + output.set(1, 1, (byte) (f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13)); + output.set(2, 1, (byte) (f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23)); return output; } private static IMatrixSetterByte multiplyMatrix2x4x4(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final byte f_c00 = matrix1.get(0, 0); - final byte f_c10 = matrix1.get(1, 0); - final byte f_c20 = matrix1.get(2, 0); - final byte f_c30 = matrix1.get(3, 0); - final byte f_c01 = matrix1.get(0, 1); - final byte f_c11 = matrix1.get(1, 1); - final byte f_c21 = matrix1.get(2, 1); - final byte f_c31 = matrix1.get(3, 1); - final byte s_c00 = matrix2.get(0, 0); - final byte s_c10 = matrix2.get(1, 0); - final byte s_c20 = matrix2.get(2, 0); - final byte s_c30 = matrix2.get(3, 0); - final byte s_c01 = matrix2.get(0, 1); - final byte s_c11 = matrix2.get(1, 1); - final byte s_c21 = matrix2.get(2, 1); - final byte s_c31 = matrix2.get(3, 1); - final byte s_c02 = matrix2.get(0, 2); - final byte s_c12 = matrix2.get(1, 2); - final byte s_c22 = matrix2.get(2, 2); - final byte s_c32 = matrix2.get(3, 2); - final byte s_c03 = matrix2.get(0, 3); - final byte s_c13 = matrix2.get(1, 3); - final byte s_c23 = matrix2.get(2, 3); - final byte s_c33 = matrix2.get(3, 3); - output.set(0, 0, (byte) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03)); - output.set(0, 1, (byte) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03)); - output.set(1, 0, (byte) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13)); - output.set(1, 1, (byte) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13)); - output.set(2, 0, (byte) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23)); - output.set(2, 1, (byte) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23)); - output.set(3, 0, (byte) (f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33)); - output.set(3, 1, (byte) (f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33)); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte f30 = matrix1.get(3, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f21 = matrix1.get(2, 1); + final byte f31 = matrix1.get(3, 1); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + final byte s30 = matrix2.get(3, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s21 = matrix2.get(2, 1); + final byte s31 = matrix2.get(3, 1); + final byte s02 = matrix2.get(0, 2); + final byte s12 = matrix2.get(1, 2); + final byte s22 = matrix2.get(2, 2); + final byte s32 = matrix2.get(3, 2); + final byte s03 = matrix2.get(0, 3); + final byte s13 = matrix2.get(1, 3); + final byte s23 = matrix2.get(2, 3); + final byte s33 = matrix2.get(3, 3); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13)); + output.set(2, 0, (byte) (f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23)); + output.set(3, 0, (byte) (f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03)); + output.set(1, 1, (byte) (f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13)); + output.set(2, 1, (byte) (f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23)); + output.set(3, 1, (byte) (f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33)); return output; } private static IMatrixSetterByte multiplyMatrix2x4x5(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final byte f_c00 = matrix1.get(0, 0); - final byte f_c10 = matrix1.get(1, 0); - final byte f_c20 = matrix1.get(2, 0); - final byte f_c30 = matrix1.get(3, 0); - final byte f_c01 = matrix1.get(0, 1); - final byte f_c11 = matrix1.get(1, 1); - final byte f_c21 = matrix1.get(2, 1); - final byte f_c31 = matrix1.get(3, 1); - final byte s_c00 = matrix2.get(0, 0); - final byte s_c10 = matrix2.get(1, 0); - final byte s_c20 = matrix2.get(2, 0); - final byte s_c30 = matrix2.get(3, 0); - final byte s_c40 = matrix2.get(4, 0); - final byte s_c01 = matrix2.get(0, 1); - final byte s_c11 = matrix2.get(1, 1); - final byte s_c21 = matrix2.get(2, 1); - final byte s_c31 = matrix2.get(3, 1); - final byte s_c41 = matrix2.get(4, 1); - final byte s_c02 = matrix2.get(0, 2); - final byte s_c12 = matrix2.get(1, 2); - final byte s_c22 = matrix2.get(2, 2); - final byte s_c32 = matrix2.get(3, 2); - final byte s_c42 = matrix2.get(4, 2); - final byte s_c03 = matrix2.get(0, 3); - final byte s_c13 = matrix2.get(1, 3); - final byte s_c23 = matrix2.get(2, 3); - final byte s_c33 = matrix2.get(3, 3); - final byte s_c43 = matrix2.get(4, 3); - output.set(0, 0, (byte) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03)); - output.set(0, 1, (byte) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03)); - output.set(1, 0, (byte) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13)); - output.set(1, 1, (byte) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13)); - output.set(2, 0, (byte) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23)); - output.set(2, 1, (byte) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23)); - output.set(3, 0, (byte) (f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33)); - output.set(3, 1, (byte) (f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33)); - output.set(4, 0, (byte) (f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42 + f_c30*s_c43)); - output.set(4, 1, (byte) (f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42 + f_c31*s_c43)); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte f30 = matrix1.get(3, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f21 = matrix1.get(2, 1); + final byte f31 = matrix1.get(3, 1); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + final byte s30 = matrix2.get(3, 0); + final byte s40 = matrix2.get(4, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s21 = matrix2.get(2, 1); + final byte s31 = matrix2.get(3, 1); + final byte s41 = matrix2.get(4, 1); + final byte s02 = matrix2.get(0, 2); + final byte s12 = matrix2.get(1, 2); + final byte s22 = matrix2.get(2, 2); + final byte s32 = matrix2.get(3, 2); + final byte s42 = matrix2.get(4, 2); + final byte s03 = matrix2.get(0, 3); + final byte s13 = matrix2.get(1, 3); + final byte s23 = matrix2.get(2, 3); + final byte s33 = matrix2.get(3, 3); + final byte s43 = matrix2.get(4, 3); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13)); + output.set(2, 0, (byte) (f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23)); + output.set(3, 0, (byte) (f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33)); + output.set(4, 0, (byte) (f00 * s40 + f10 * s41 + f20 * s42 + f30 * s43)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03)); + output.set(1, 1, (byte) (f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13)); + output.set(2, 1, (byte) (f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23)); + output.set(3, 1, (byte) (f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33)); + output.set(4, 1, (byte) (f01 * s40 + f11 * s41 + f21 * s42 + f31 * s43)); + return output; + } + + private static IMatrixSetterByte multiplyMatrix3x4x1(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte f30 = matrix1.get(3, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f21 = matrix1.get(2, 1); + final byte f31 = matrix1.get(3, 1); + final byte f02 = matrix1.get(0, 2); + final byte f12 = matrix1.get(1, 2); + final byte f22 = matrix1.get(2, 2); + final byte f32 = matrix1.get(3, 2); + final byte s00 = matrix2.get(0, 0); + final byte s01 = matrix2.get(0, 1); + final byte s02 = matrix2.get(0, 2); + final byte s03 = matrix2.get(0, 3); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03)); + output.set(0, 2, (byte) (f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03)); return output; } private static IMatrixSetterByte multiplyMatrix3x4x2(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final byte f_c00 = matrix1.get(0, 0); - final byte f_c10 = matrix1.get(1, 0); - final byte f_c20 = matrix1.get(2, 0); - final byte f_c30 = matrix1.get(3, 0); - final byte f_c01 = matrix1.get(0, 1); - final byte f_c11 = matrix1.get(1, 1); - final byte f_c21 = matrix1.get(2, 1); - final byte f_c31 = matrix1.get(3, 1); - final byte f_c02 = matrix1.get(0, 2); - final byte f_c12 = matrix1.get(1, 2); - final byte f_c22 = matrix1.get(2, 2); - final byte f_c32 = matrix1.get(3, 2); - final byte s_c00 = matrix2.get(0, 0); - final byte s_c10 = matrix2.get(1, 0); - final byte s_c01 = matrix2.get(0, 1); - final byte s_c11 = matrix2.get(1, 1); - final byte s_c02 = matrix2.get(0, 2); - final byte s_c12 = matrix2.get(1, 2); - final byte s_c03 = matrix2.get(0, 3); - final byte s_c13 = matrix2.get(1, 3); - output.set(0, 0, (byte) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03)); - output.set(0, 1, (byte) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03)); - output.set(0, 2, (byte) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03)); - output.set(1, 0, (byte) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13)); - output.set(1, 1, (byte) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13)); - output.set(1, 2, (byte) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13)); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte f30 = matrix1.get(3, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f21 = matrix1.get(2, 1); + final byte f31 = matrix1.get(3, 1); + final byte f02 = matrix1.get(0, 2); + final byte f12 = matrix1.get(1, 2); + final byte f22 = matrix1.get(2, 2); + final byte f32 = matrix1.get(3, 2); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s02 = matrix2.get(0, 2); + final byte s12 = matrix2.get(1, 2); + final byte s03 = matrix2.get(0, 3); + final byte s13 = matrix2.get(1, 3); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03)); + output.set(1, 1, (byte) (f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13)); + output.set(0, 2, (byte) (f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03)); + output.set(1, 2, (byte) (f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13)); return output; } private static IMatrixSetterByte multiplyMatrix3x4x3(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final byte f_c00 = matrix1.get(0, 0); - final byte f_c10 = matrix1.get(1, 0); - final byte f_c20 = matrix1.get(2, 0); - final byte f_c30 = matrix1.get(3, 0); - final byte f_c01 = matrix1.get(0, 1); - final byte f_c11 = matrix1.get(1, 1); - final byte f_c21 = matrix1.get(2, 1); - final byte f_c31 = matrix1.get(3, 1); - final byte f_c02 = matrix1.get(0, 2); - final byte f_c12 = matrix1.get(1, 2); - final byte f_c22 = matrix1.get(2, 2); - final byte f_c32 = matrix1.get(3, 2); - final byte s_c00 = matrix2.get(0, 0); - final byte s_c10 = matrix2.get(1, 0); - final byte s_c20 = matrix2.get(2, 0); - final byte s_c01 = matrix2.get(0, 1); - final byte s_c11 = matrix2.get(1, 1); - final byte s_c21 = matrix2.get(2, 1); - final byte s_c02 = matrix2.get(0, 2); - final byte s_c12 = matrix2.get(1, 2); - final byte s_c22 = matrix2.get(2, 2); - final byte s_c03 = matrix2.get(0, 3); - final byte s_c13 = matrix2.get(1, 3); - final byte s_c23 = matrix2.get(2, 3); - output.set(0, 0, (byte) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03)); - output.set(0, 1, (byte) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03)); - output.set(0, 2, (byte) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03)); - output.set(1, 0, (byte) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13)); - output.set(1, 1, (byte) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13)); - output.set(1, 2, (byte) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13)); - output.set(2, 0, (byte) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23)); - output.set(2, 1, (byte) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23)); - output.set(2, 2, (byte) (f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23)); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte f30 = matrix1.get(3, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f21 = matrix1.get(2, 1); + final byte f31 = matrix1.get(3, 1); + final byte f02 = matrix1.get(0, 2); + final byte f12 = matrix1.get(1, 2); + final byte f22 = matrix1.get(2, 2); + final byte f32 = matrix1.get(3, 2); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s21 = matrix2.get(2, 1); + final byte s02 = matrix2.get(0, 2); + final byte s12 = matrix2.get(1, 2); + final byte s22 = matrix2.get(2, 2); + final byte s03 = matrix2.get(0, 3); + final byte s13 = matrix2.get(1, 3); + final byte s23 = matrix2.get(2, 3); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13)); + output.set(2, 0, (byte) (f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03)); + output.set(1, 1, (byte) (f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13)); + output.set(2, 1, (byte) (f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23)); + output.set(0, 2, (byte) (f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03)); + output.set(1, 2, (byte) (f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13)); + output.set(2, 2, (byte) (f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23)); return output; } private static IMatrixSetterByte multiplyMatrix3x4x4(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final byte f_c00 = matrix1.get(0, 0); - final byte f_c10 = matrix1.get(1, 0); - final byte f_c20 = matrix1.get(2, 0); - final byte f_c30 = matrix1.get(3, 0); - final byte f_c01 = matrix1.get(0, 1); - final byte f_c11 = matrix1.get(1, 1); - final byte f_c21 = matrix1.get(2, 1); - final byte f_c31 = matrix1.get(3, 1); - final byte f_c02 = matrix1.get(0, 2); - final byte f_c12 = matrix1.get(1, 2); - final byte f_c22 = matrix1.get(2, 2); - final byte f_c32 = matrix1.get(3, 2); - final byte s_c00 = matrix2.get(0, 0); - final byte s_c10 = matrix2.get(1, 0); - final byte s_c20 = matrix2.get(2, 0); - final byte s_c30 = matrix2.get(3, 0); - final byte s_c01 = matrix2.get(0, 1); - final byte s_c11 = matrix2.get(1, 1); - final byte s_c21 = matrix2.get(2, 1); - final byte s_c31 = matrix2.get(3, 1); - final byte s_c02 = matrix2.get(0, 2); - final byte s_c12 = matrix2.get(1, 2); - final byte s_c22 = matrix2.get(2, 2); - final byte s_c32 = matrix2.get(3, 2); - final byte s_c03 = matrix2.get(0, 3); - final byte s_c13 = matrix2.get(1, 3); - final byte s_c23 = matrix2.get(2, 3); - final byte s_c33 = matrix2.get(3, 3); - output.set(0, 0, (byte) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03)); - output.set(0, 1, (byte) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03)); - output.set(0, 2, (byte) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03)); - output.set(1, 0, (byte) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13)); - output.set(1, 1, (byte) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13)); - output.set(1, 2, (byte) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13)); - output.set(2, 0, (byte) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23)); - output.set(2, 1, (byte) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23)); - output.set(2, 2, (byte) (f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23)); - output.set(3, 0, (byte) (f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33)); - output.set(3, 1, (byte) (f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33)); - output.set(3, 2, (byte) (f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33)); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte f30 = matrix1.get(3, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f21 = matrix1.get(2, 1); + final byte f31 = matrix1.get(3, 1); + final byte f02 = matrix1.get(0, 2); + final byte f12 = matrix1.get(1, 2); + final byte f22 = matrix1.get(2, 2); + final byte f32 = matrix1.get(3, 2); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + final byte s30 = matrix2.get(3, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s21 = matrix2.get(2, 1); + final byte s31 = matrix2.get(3, 1); + final byte s02 = matrix2.get(0, 2); + final byte s12 = matrix2.get(1, 2); + final byte s22 = matrix2.get(2, 2); + final byte s32 = matrix2.get(3, 2); + final byte s03 = matrix2.get(0, 3); + final byte s13 = matrix2.get(1, 3); + final byte s23 = matrix2.get(2, 3); + final byte s33 = matrix2.get(3, 3); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13)); + output.set(2, 0, (byte) (f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23)); + output.set(3, 0, (byte) (f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03)); + output.set(1, 1, (byte) (f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13)); + output.set(2, 1, (byte) (f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23)); + output.set(3, 1, (byte) (f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33)); + output.set(0, 2, (byte) (f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03)); + output.set(1, 2, (byte) (f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13)); + output.set(2, 2, (byte) (f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23)); + output.set(3, 2, (byte) (f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33)); return output; } private static IMatrixSetterByte multiplyMatrix3x4x5(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final byte f_c00 = matrix1.get(0, 0); - final byte f_c10 = matrix1.get(1, 0); - final byte f_c20 = matrix1.get(2, 0); - final byte f_c30 = matrix1.get(3, 0); - final byte f_c01 = matrix1.get(0, 1); - final byte f_c11 = matrix1.get(1, 1); - final byte f_c21 = matrix1.get(2, 1); - final byte f_c31 = matrix1.get(3, 1); - final byte f_c02 = matrix1.get(0, 2); - final byte f_c12 = matrix1.get(1, 2); - final byte f_c22 = matrix1.get(2, 2); - final byte f_c32 = matrix1.get(3, 2); - final byte s_c00 = matrix2.get(0, 0); - final byte s_c10 = matrix2.get(1, 0); - final byte s_c20 = matrix2.get(2, 0); - final byte s_c30 = matrix2.get(3, 0); - final byte s_c40 = matrix2.get(4, 0); - final byte s_c01 = matrix2.get(0, 1); - final byte s_c11 = matrix2.get(1, 1); - final byte s_c21 = matrix2.get(2, 1); - final byte s_c31 = matrix2.get(3, 1); - final byte s_c41 = matrix2.get(4, 1); - final byte s_c02 = matrix2.get(0, 2); - final byte s_c12 = matrix2.get(1, 2); - final byte s_c22 = matrix2.get(2, 2); - final byte s_c32 = matrix2.get(3, 2); - final byte s_c42 = matrix2.get(4, 2); - final byte s_c03 = matrix2.get(0, 3); - final byte s_c13 = matrix2.get(1, 3); - final byte s_c23 = matrix2.get(2, 3); - final byte s_c33 = matrix2.get(3, 3); - final byte s_c43 = matrix2.get(4, 3); - output.set(0, 0, (byte) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03)); - output.set(0, 1, (byte) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03)); - output.set(0, 2, (byte) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03)); - output.set(1, 0, (byte) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13)); - output.set(1, 1, (byte) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13)); - output.set(1, 2, (byte) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13)); - output.set(2, 0, (byte) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23)); - output.set(2, 1, (byte) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23)); - output.set(2, 2, (byte) (f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23)); - output.set(3, 0, (byte) (f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33)); - output.set(3, 1, (byte) (f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33)); - output.set(3, 2, (byte) (f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33)); - output.set(4, 0, (byte) (f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42 + f_c30*s_c43)); - output.set(4, 1, (byte) (f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42 + f_c31*s_c43)); - output.set(4, 2, (byte) (f_c02*s_c40 + f_c12*s_c41 + f_c22*s_c42 + f_c32*s_c43)); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte f30 = matrix1.get(3, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f21 = matrix1.get(2, 1); + final byte f31 = matrix1.get(3, 1); + final byte f02 = matrix1.get(0, 2); + final byte f12 = matrix1.get(1, 2); + final byte f22 = matrix1.get(2, 2); + final byte f32 = matrix1.get(3, 2); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + final byte s30 = matrix2.get(3, 0); + final byte s40 = matrix2.get(4, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s21 = matrix2.get(2, 1); + final byte s31 = matrix2.get(3, 1); + final byte s41 = matrix2.get(4, 1); + final byte s02 = matrix2.get(0, 2); + final byte s12 = matrix2.get(1, 2); + final byte s22 = matrix2.get(2, 2); + final byte s32 = matrix2.get(3, 2); + final byte s42 = matrix2.get(4, 2); + final byte s03 = matrix2.get(0, 3); + final byte s13 = matrix2.get(1, 3); + final byte s23 = matrix2.get(2, 3); + final byte s33 = matrix2.get(3, 3); + final byte s43 = matrix2.get(4, 3); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13)); + output.set(2, 0, (byte) (f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23)); + output.set(3, 0, (byte) (f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33)); + output.set(4, 0, (byte) (f00 * s40 + f10 * s41 + f20 * s42 + f30 * s43)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03)); + output.set(1, 1, (byte) (f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13)); + output.set(2, 1, (byte) (f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23)); + output.set(3, 1, (byte) (f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33)); + output.set(4, 1, (byte) (f01 * s40 + f11 * s41 + f21 * s42 + f31 * s43)); + output.set(0, 2, (byte) (f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03)); + output.set(1, 2, (byte) (f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13)); + output.set(2, 2, (byte) (f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23)); + output.set(3, 2, (byte) (f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33)); + output.set(4, 2, (byte) (f02 * s40 + f12 * s41 + f22 * s42 + f32 * s43)); + return output; + } + + private static IMatrixSetterByte multiplyMatrix4x4x1(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte f30 = matrix1.get(3, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f21 = matrix1.get(2, 1); + final byte f31 = matrix1.get(3, 1); + final byte f02 = matrix1.get(0, 2); + final byte f12 = matrix1.get(1, 2); + final byte f22 = matrix1.get(2, 2); + final byte f32 = matrix1.get(3, 2); + final byte f03 = matrix1.get(0, 3); + final byte f13 = matrix1.get(1, 3); + final byte f23 = matrix1.get(2, 3); + final byte f33 = matrix1.get(3, 3); + final byte s00 = matrix2.get(0, 0); + final byte s01 = matrix2.get(0, 1); + final byte s02 = matrix2.get(0, 2); + final byte s03 = matrix2.get(0, 3); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03)); + output.set(0, 2, (byte) (f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03)); + output.set(0, 3, (byte) (f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03)); return output; } private static IMatrixSetterByte multiplyMatrix4x4x2(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final byte f_c00 = matrix1.get(0, 0); - final byte f_c10 = matrix1.get(1, 0); - final byte f_c20 = matrix1.get(2, 0); - final byte f_c30 = matrix1.get(3, 0); - final byte f_c01 = matrix1.get(0, 1); - final byte f_c11 = matrix1.get(1, 1); - final byte f_c21 = matrix1.get(2, 1); - final byte f_c31 = matrix1.get(3, 1); - final byte f_c02 = matrix1.get(0, 2); - final byte f_c12 = matrix1.get(1, 2); - final byte f_c22 = matrix1.get(2, 2); - final byte f_c32 = matrix1.get(3, 2); - final byte f_c03 = matrix1.get(0, 3); - final byte f_c13 = matrix1.get(1, 3); - final byte f_c23 = matrix1.get(2, 3); - final byte f_c33 = matrix1.get(3, 3); - final byte s_c00 = matrix2.get(0, 0); - final byte s_c10 = matrix2.get(1, 0); - final byte s_c01 = matrix2.get(0, 1); - final byte s_c11 = matrix2.get(1, 1); - final byte s_c02 = matrix2.get(0, 2); - final byte s_c12 = matrix2.get(1, 2); - final byte s_c03 = matrix2.get(0, 3); - final byte s_c13 = matrix2.get(1, 3); - output.set(0, 0, (byte) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03)); - output.set(0, 1, (byte) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03)); - output.set(0, 2, (byte) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03)); - output.set(0, 3, (byte) (f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03)); - output.set(1, 0, (byte) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13)); - output.set(1, 1, (byte) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13)); - output.set(1, 2, (byte) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13)); - output.set(1, 3, (byte) (f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13)); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte f30 = matrix1.get(3, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f21 = matrix1.get(2, 1); + final byte f31 = matrix1.get(3, 1); + final byte f02 = matrix1.get(0, 2); + final byte f12 = matrix1.get(1, 2); + final byte f22 = matrix1.get(2, 2); + final byte f32 = matrix1.get(3, 2); + final byte f03 = matrix1.get(0, 3); + final byte f13 = matrix1.get(1, 3); + final byte f23 = matrix1.get(2, 3); + final byte f33 = matrix1.get(3, 3); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s02 = matrix2.get(0, 2); + final byte s12 = matrix2.get(1, 2); + final byte s03 = matrix2.get(0, 3); + final byte s13 = matrix2.get(1, 3); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03)); + output.set(1, 1, (byte) (f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13)); + output.set(0, 2, (byte) (f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03)); + output.set(1, 2, (byte) (f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13)); + output.set(0, 3, (byte) (f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03)); + output.set(1, 3, (byte) (f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13)); return output; } private static IMatrixSetterByte multiplyMatrix4x4x3(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final byte f_c00 = matrix1.get(0, 0); - final byte f_c10 = matrix1.get(1, 0); - final byte f_c20 = matrix1.get(2, 0); - final byte f_c30 = matrix1.get(3, 0); - final byte f_c01 = matrix1.get(0, 1); - final byte f_c11 = matrix1.get(1, 1); - final byte f_c21 = matrix1.get(2, 1); - final byte f_c31 = matrix1.get(3, 1); - final byte f_c02 = matrix1.get(0, 2); - final byte f_c12 = matrix1.get(1, 2); - final byte f_c22 = matrix1.get(2, 2); - final byte f_c32 = matrix1.get(3, 2); - final byte f_c03 = matrix1.get(0, 3); - final byte f_c13 = matrix1.get(1, 3); - final byte f_c23 = matrix1.get(2, 3); - final byte f_c33 = matrix1.get(3, 3); - final byte s_c00 = matrix2.get(0, 0); - final byte s_c10 = matrix2.get(1, 0); - final byte s_c20 = matrix2.get(2, 0); - final byte s_c01 = matrix2.get(0, 1); - final byte s_c11 = matrix2.get(1, 1); - final byte s_c21 = matrix2.get(2, 1); - final byte s_c02 = matrix2.get(0, 2); - final byte s_c12 = matrix2.get(1, 2); - final byte s_c22 = matrix2.get(2, 2); - final byte s_c03 = matrix2.get(0, 3); - final byte s_c13 = matrix2.get(1, 3); - final byte s_c23 = matrix2.get(2, 3); - output.set(0, 0, (byte) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03)); - output.set(0, 1, (byte) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03)); - output.set(0, 2, (byte) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03)); - output.set(0, 3, (byte) (f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03)); - output.set(1, 0, (byte) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13)); - output.set(1, 1, (byte) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13)); - output.set(1, 2, (byte) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13)); - output.set(1, 3, (byte) (f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13)); - output.set(2, 0, (byte) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23)); - output.set(2, 1, (byte) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23)); - output.set(2, 2, (byte) (f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23)); - output.set(2, 3, (byte) (f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23)); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte f30 = matrix1.get(3, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f21 = matrix1.get(2, 1); + final byte f31 = matrix1.get(3, 1); + final byte f02 = matrix1.get(0, 2); + final byte f12 = matrix1.get(1, 2); + final byte f22 = matrix1.get(2, 2); + final byte f32 = matrix1.get(3, 2); + final byte f03 = matrix1.get(0, 3); + final byte f13 = matrix1.get(1, 3); + final byte f23 = matrix1.get(2, 3); + final byte f33 = matrix1.get(3, 3); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s21 = matrix2.get(2, 1); + final byte s02 = matrix2.get(0, 2); + final byte s12 = matrix2.get(1, 2); + final byte s22 = matrix2.get(2, 2); + final byte s03 = matrix2.get(0, 3); + final byte s13 = matrix2.get(1, 3); + final byte s23 = matrix2.get(2, 3); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13)); + output.set(2, 0, (byte) (f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03)); + output.set(1, 1, (byte) (f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13)); + output.set(2, 1, (byte) (f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23)); + output.set(0, 2, (byte) (f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03)); + output.set(1, 2, (byte) (f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13)); + output.set(2, 2, (byte) (f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23)); + output.set(0, 3, (byte) (f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03)); + output.set(1, 3, (byte) (f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13)); + output.set(2, 3, (byte) (f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23)); return output; } private static IMatrixSetterByte multiplyMatrix4x4x4(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final byte f_c00 = matrix1.get(0, 0); - final byte f_c10 = matrix1.get(1, 0); - final byte f_c20 = matrix1.get(2, 0); - final byte f_c30 = matrix1.get(3, 0); - final byte f_c01 = matrix1.get(0, 1); - final byte f_c11 = matrix1.get(1, 1); - final byte f_c21 = matrix1.get(2, 1); - final byte f_c31 = matrix1.get(3, 1); - final byte f_c02 = matrix1.get(0, 2); - final byte f_c12 = matrix1.get(1, 2); - final byte f_c22 = matrix1.get(2, 2); - final byte f_c32 = matrix1.get(3, 2); - final byte f_c03 = matrix1.get(0, 3); - final byte f_c13 = matrix1.get(1, 3); - final byte f_c23 = matrix1.get(2, 3); - final byte f_c33 = matrix1.get(3, 3); - final byte s_c00 = matrix2.get(0, 0); - final byte s_c10 = matrix2.get(1, 0); - final byte s_c20 = matrix2.get(2, 0); - final byte s_c30 = matrix2.get(3, 0); - final byte s_c01 = matrix2.get(0, 1); - final byte s_c11 = matrix2.get(1, 1); - final byte s_c21 = matrix2.get(2, 1); - final byte s_c31 = matrix2.get(3, 1); - final byte s_c02 = matrix2.get(0, 2); - final byte s_c12 = matrix2.get(1, 2); - final byte s_c22 = matrix2.get(2, 2); - final byte s_c32 = matrix2.get(3, 2); - final byte s_c03 = matrix2.get(0, 3); - final byte s_c13 = matrix2.get(1, 3); - final byte s_c23 = matrix2.get(2, 3); - final byte s_c33 = matrix2.get(3, 3); - output.set(0, 0, (byte) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03)); - output.set(0, 1, (byte) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03)); - output.set(0, 2, (byte) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03)); - output.set(0, 3, (byte) (f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03)); - output.set(1, 0, (byte) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13)); - output.set(1, 1, (byte) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13)); - output.set(1, 2, (byte) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13)); - output.set(1, 3, (byte) (f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13)); - output.set(2, 0, (byte) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23)); - output.set(2, 1, (byte) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23)); - output.set(2, 2, (byte) (f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23)); - output.set(2, 3, (byte) (f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23)); - output.set(3, 0, (byte) (f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33)); - output.set(3, 1, (byte) (f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33)); - output.set(3, 2, (byte) (f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33)); - output.set(3, 3, (byte) (f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32 + f_c33*s_c33)); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte f30 = matrix1.get(3, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f21 = matrix1.get(2, 1); + final byte f31 = matrix1.get(3, 1); + final byte f02 = matrix1.get(0, 2); + final byte f12 = matrix1.get(1, 2); + final byte f22 = matrix1.get(2, 2); + final byte f32 = matrix1.get(3, 2); + final byte f03 = matrix1.get(0, 3); + final byte f13 = matrix1.get(1, 3); + final byte f23 = matrix1.get(2, 3); + final byte f33 = matrix1.get(3, 3); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + final byte s30 = matrix2.get(3, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s21 = matrix2.get(2, 1); + final byte s31 = matrix2.get(3, 1); + final byte s02 = matrix2.get(0, 2); + final byte s12 = matrix2.get(1, 2); + final byte s22 = matrix2.get(2, 2); + final byte s32 = matrix2.get(3, 2); + final byte s03 = matrix2.get(0, 3); + final byte s13 = matrix2.get(1, 3); + final byte s23 = matrix2.get(2, 3); + final byte s33 = matrix2.get(3, 3); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13)); + output.set(2, 0, (byte) (f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23)); + output.set(3, 0, (byte) (f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03)); + output.set(1, 1, (byte) (f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13)); + output.set(2, 1, (byte) (f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23)); + output.set(3, 1, (byte) (f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33)); + output.set(0, 2, (byte) (f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03)); + output.set(1, 2, (byte) (f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13)); + output.set(2, 2, (byte) (f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23)); + output.set(3, 2, (byte) (f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33)); + output.set(0, 3, (byte) (f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03)); + output.set(1, 3, (byte) (f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13)); + output.set(2, 3, (byte) (f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23)); + output.set(3, 3, (byte) (f03 * s30 + f13 * s31 + f23 * s32 + f33 * s33)); return output; } private static IMatrixSetterByte multiplyMatrix4x4x5(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final byte f_c00 = matrix1.get(0, 0); - final byte f_c10 = matrix1.get(1, 0); - final byte f_c20 = matrix1.get(2, 0); - final byte f_c30 = matrix1.get(3, 0); - final byte f_c01 = matrix1.get(0, 1); - final byte f_c11 = matrix1.get(1, 1); - final byte f_c21 = matrix1.get(2, 1); - final byte f_c31 = matrix1.get(3, 1); - final byte f_c02 = matrix1.get(0, 2); - final byte f_c12 = matrix1.get(1, 2); - final byte f_c22 = matrix1.get(2, 2); - final byte f_c32 = matrix1.get(3, 2); - final byte f_c03 = matrix1.get(0, 3); - final byte f_c13 = matrix1.get(1, 3); - final byte f_c23 = matrix1.get(2, 3); - final byte f_c33 = matrix1.get(3, 3); - final byte s_c00 = matrix2.get(0, 0); - final byte s_c10 = matrix2.get(1, 0); - final byte s_c20 = matrix2.get(2, 0); - final byte s_c30 = matrix2.get(3, 0); - final byte s_c40 = matrix2.get(4, 0); - final byte s_c01 = matrix2.get(0, 1); - final byte s_c11 = matrix2.get(1, 1); - final byte s_c21 = matrix2.get(2, 1); - final byte s_c31 = matrix2.get(3, 1); - final byte s_c41 = matrix2.get(4, 1); - final byte s_c02 = matrix2.get(0, 2); - final byte s_c12 = matrix2.get(1, 2); - final byte s_c22 = matrix2.get(2, 2); - final byte s_c32 = matrix2.get(3, 2); - final byte s_c42 = matrix2.get(4, 2); - final byte s_c03 = matrix2.get(0, 3); - final byte s_c13 = matrix2.get(1, 3); - final byte s_c23 = matrix2.get(2, 3); - final byte s_c33 = matrix2.get(3, 3); - final byte s_c43 = matrix2.get(4, 3); - output.set(0, 0, (byte) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03)); - output.set(0, 1, (byte) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03)); - output.set(0, 2, (byte) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03)); - output.set(0, 3, (byte) (f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03)); - output.set(1, 0, (byte) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13)); - output.set(1, 1, (byte) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13)); - output.set(1, 2, (byte) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13)); - output.set(1, 3, (byte) (f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13)); - output.set(2, 0, (byte) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23)); - output.set(2, 1, (byte) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23)); - output.set(2, 2, (byte) (f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23)); - output.set(2, 3, (byte) (f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23)); - output.set(3, 0, (byte) (f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33)); - output.set(3, 1, (byte) (f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33)); - output.set(3, 2, (byte) (f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33)); - output.set(3, 3, (byte) (f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32 + f_c33*s_c33)); - output.set(4, 0, (byte) (f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42 + f_c30*s_c43)); - output.set(4, 1, (byte) (f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42 + f_c31*s_c43)); - output.set(4, 2, (byte) (f_c02*s_c40 + f_c12*s_c41 + f_c22*s_c42 + f_c32*s_c43)); - output.set(4, 3, (byte) (f_c03*s_c40 + f_c13*s_c41 + f_c23*s_c42 + f_c33*s_c43)); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte f30 = matrix1.get(3, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f21 = matrix1.get(2, 1); + final byte f31 = matrix1.get(3, 1); + final byte f02 = matrix1.get(0, 2); + final byte f12 = matrix1.get(1, 2); + final byte f22 = matrix1.get(2, 2); + final byte f32 = matrix1.get(3, 2); + final byte f03 = matrix1.get(0, 3); + final byte f13 = matrix1.get(1, 3); + final byte f23 = matrix1.get(2, 3); + final byte f33 = matrix1.get(3, 3); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + final byte s30 = matrix2.get(3, 0); + final byte s40 = matrix2.get(4, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s21 = matrix2.get(2, 1); + final byte s31 = matrix2.get(3, 1); + final byte s41 = matrix2.get(4, 1); + final byte s02 = matrix2.get(0, 2); + final byte s12 = matrix2.get(1, 2); + final byte s22 = matrix2.get(2, 2); + final byte s32 = matrix2.get(3, 2); + final byte s42 = matrix2.get(4, 2); + final byte s03 = matrix2.get(0, 3); + final byte s13 = matrix2.get(1, 3); + final byte s23 = matrix2.get(2, 3); + final byte s33 = matrix2.get(3, 3); + final byte s43 = matrix2.get(4, 3); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13)); + output.set(2, 0, (byte) (f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23)); + output.set(3, 0, (byte) (f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33)); + output.set(4, 0, (byte) (f00 * s40 + f10 * s41 + f20 * s42 + f30 * s43)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03)); + output.set(1, 1, (byte) (f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13)); + output.set(2, 1, (byte) (f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23)); + output.set(3, 1, (byte) (f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33)); + output.set(4, 1, (byte) (f01 * s40 + f11 * s41 + f21 * s42 + f31 * s43)); + output.set(0, 2, (byte) (f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03)); + output.set(1, 2, (byte) (f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13)); + output.set(2, 2, (byte) (f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23)); + output.set(3, 2, (byte) (f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33)); + output.set(4, 2, (byte) (f02 * s40 + f12 * s41 + f22 * s42 + f32 * s43)); + output.set(0, 3, (byte) (f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03)); + output.set(1, 3, (byte) (f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13)); + output.set(2, 3, (byte) (f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23)); + output.set(3, 3, (byte) (f03 * s30 + f13 * s31 + f23 * s32 + f33 * s33)); + output.set(4, 3, (byte) (f03 * s40 + f13 * s41 + f23 * s42 + f33 * s43)); + return output; + } + + private static IMatrixSetterByte multiplyMatrix5x4x1(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte f30 = matrix1.get(3, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f21 = matrix1.get(2, 1); + final byte f31 = matrix1.get(3, 1); + final byte f02 = matrix1.get(0, 2); + final byte f12 = matrix1.get(1, 2); + final byte f22 = matrix1.get(2, 2); + final byte f32 = matrix1.get(3, 2); + final byte f03 = matrix1.get(0, 3); + final byte f13 = matrix1.get(1, 3); + final byte f23 = matrix1.get(2, 3); + final byte f33 = matrix1.get(3, 3); + final byte f04 = matrix1.get(0, 4); + final byte f14 = matrix1.get(1, 4); + final byte f24 = matrix1.get(2, 4); + final byte f34 = matrix1.get(3, 4); + final byte s00 = matrix2.get(0, 0); + final byte s01 = matrix2.get(0, 1); + final byte s02 = matrix2.get(0, 2); + final byte s03 = matrix2.get(0, 3); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03)); + output.set(0, 2, (byte) (f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03)); + output.set(0, 3, (byte) (f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03)); + output.set(0, 4, (byte) (f04 * s00 + f14 * s01 + f24 * s02 + f34 * s03)); return output; } private static IMatrixSetterByte multiplyMatrix5x4x2(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final byte f_c00 = matrix1.get(0, 0); - final byte f_c10 = matrix1.get(1, 0); - final byte f_c20 = matrix1.get(2, 0); - final byte f_c30 = matrix1.get(3, 0); - final byte f_c01 = matrix1.get(0, 1); - final byte f_c11 = matrix1.get(1, 1); - final byte f_c21 = matrix1.get(2, 1); - final byte f_c31 = matrix1.get(3, 1); - final byte f_c02 = matrix1.get(0, 2); - final byte f_c12 = matrix1.get(1, 2); - final byte f_c22 = matrix1.get(2, 2); - final byte f_c32 = matrix1.get(3, 2); - final byte f_c03 = matrix1.get(0, 3); - final byte f_c13 = matrix1.get(1, 3); - final byte f_c23 = matrix1.get(2, 3); - final byte f_c33 = matrix1.get(3, 3); - final byte f_c04 = matrix1.get(0, 4); - final byte f_c14 = matrix1.get(1, 4); - final byte f_c24 = matrix1.get(2, 4); - final byte f_c34 = matrix1.get(3, 4); - final byte s_c00 = matrix2.get(0, 0); - final byte s_c10 = matrix2.get(1, 0); - final byte s_c01 = matrix2.get(0, 1); - final byte s_c11 = matrix2.get(1, 1); - final byte s_c02 = matrix2.get(0, 2); - final byte s_c12 = matrix2.get(1, 2); - final byte s_c03 = matrix2.get(0, 3); - final byte s_c13 = matrix2.get(1, 3); - output.set(0, 0, (byte) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03)); - output.set(0, 1, (byte) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03)); - output.set(0, 2, (byte) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03)); - output.set(0, 3, (byte) (f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03)); - output.set(0, 4, (byte) (f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02 + f_c34*s_c03)); - output.set(1, 0, (byte) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13)); - output.set(1, 1, (byte) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13)); - output.set(1, 2, (byte) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13)); - output.set(1, 3, (byte) (f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13)); - output.set(1, 4, (byte) (f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12 + f_c34*s_c13)); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte f30 = matrix1.get(3, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f21 = matrix1.get(2, 1); + final byte f31 = matrix1.get(3, 1); + final byte f02 = matrix1.get(0, 2); + final byte f12 = matrix1.get(1, 2); + final byte f22 = matrix1.get(2, 2); + final byte f32 = matrix1.get(3, 2); + final byte f03 = matrix1.get(0, 3); + final byte f13 = matrix1.get(1, 3); + final byte f23 = matrix1.get(2, 3); + final byte f33 = matrix1.get(3, 3); + final byte f04 = matrix1.get(0, 4); + final byte f14 = matrix1.get(1, 4); + final byte f24 = matrix1.get(2, 4); + final byte f34 = matrix1.get(3, 4); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s02 = matrix2.get(0, 2); + final byte s12 = matrix2.get(1, 2); + final byte s03 = matrix2.get(0, 3); + final byte s13 = matrix2.get(1, 3); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03)); + output.set(1, 1, (byte) (f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13)); + output.set(0, 2, (byte) (f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03)); + output.set(1, 2, (byte) (f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13)); + output.set(0, 3, (byte) (f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03)); + output.set(1, 3, (byte) (f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13)); + output.set(0, 4, (byte) (f04 * s00 + f14 * s01 + f24 * s02 + f34 * s03)); + output.set(1, 4, (byte) (f04 * s10 + f14 * s11 + f24 * s12 + f34 * s13)); return output; } private static IMatrixSetterByte multiplyMatrix5x4x3(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final byte f_c00 = matrix1.get(0, 0); - final byte f_c10 = matrix1.get(1, 0); - final byte f_c20 = matrix1.get(2, 0); - final byte f_c30 = matrix1.get(3, 0); - final byte f_c01 = matrix1.get(0, 1); - final byte f_c11 = matrix1.get(1, 1); - final byte f_c21 = matrix1.get(2, 1); - final byte f_c31 = matrix1.get(3, 1); - final byte f_c02 = matrix1.get(0, 2); - final byte f_c12 = matrix1.get(1, 2); - final byte f_c22 = matrix1.get(2, 2); - final byte f_c32 = matrix1.get(3, 2); - final byte f_c03 = matrix1.get(0, 3); - final byte f_c13 = matrix1.get(1, 3); - final byte f_c23 = matrix1.get(2, 3); - final byte f_c33 = matrix1.get(3, 3); - final byte f_c04 = matrix1.get(0, 4); - final byte f_c14 = matrix1.get(1, 4); - final byte f_c24 = matrix1.get(2, 4); - final byte f_c34 = matrix1.get(3, 4); - final byte s_c00 = matrix2.get(0, 0); - final byte s_c10 = matrix2.get(1, 0); - final byte s_c20 = matrix2.get(2, 0); - final byte s_c01 = matrix2.get(0, 1); - final byte s_c11 = matrix2.get(1, 1); - final byte s_c21 = matrix2.get(2, 1); - final byte s_c02 = matrix2.get(0, 2); - final byte s_c12 = matrix2.get(1, 2); - final byte s_c22 = matrix2.get(2, 2); - final byte s_c03 = matrix2.get(0, 3); - final byte s_c13 = matrix2.get(1, 3); - final byte s_c23 = matrix2.get(2, 3); - output.set(0, 0, (byte) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03)); - output.set(0, 1, (byte) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03)); - output.set(0, 2, (byte) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03)); - output.set(0, 3, (byte) (f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03)); - output.set(0, 4, (byte) (f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02 + f_c34*s_c03)); - output.set(1, 0, (byte) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13)); - output.set(1, 1, (byte) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13)); - output.set(1, 2, (byte) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13)); - output.set(1, 3, (byte) (f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13)); - output.set(1, 4, (byte) (f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12 + f_c34*s_c13)); - output.set(2, 0, (byte) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23)); - output.set(2, 1, (byte) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23)); - output.set(2, 2, (byte) (f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23)); - output.set(2, 3, (byte) (f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23)); - output.set(2, 4, (byte) (f_c04*s_c20 + f_c14*s_c21 + f_c24*s_c22 + f_c34*s_c23)); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte f30 = matrix1.get(3, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f21 = matrix1.get(2, 1); + final byte f31 = matrix1.get(3, 1); + final byte f02 = matrix1.get(0, 2); + final byte f12 = matrix1.get(1, 2); + final byte f22 = matrix1.get(2, 2); + final byte f32 = matrix1.get(3, 2); + final byte f03 = matrix1.get(0, 3); + final byte f13 = matrix1.get(1, 3); + final byte f23 = matrix1.get(2, 3); + final byte f33 = matrix1.get(3, 3); + final byte f04 = matrix1.get(0, 4); + final byte f14 = matrix1.get(1, 4); + final byte f24 = matrix1.get(2, 4); + final byte f34 = matrix1.get(3, 4); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s21 = matrix2.get(2, 1); + final byte s02 = matrix2.get(0, 2); + final byte s12 = matrix2.get(1, 2); + final byte s22 = matrix2.get(2, 2); + final byte s03 = matrix2.get(0, 3); + final byte s13 = matrix2.get(1, 3); + final byte s23 = matrix2.get(2, 3); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13)); + output.set(2, 0, (byte) (f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03)); + output.set(1, 1, (byte) (f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13)); + output.set(2, 1, (byte) (f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23)); + output.set(0, 2, (byte) (f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03)); + output.set(1, 2, (byte) (f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13)); + output.set(2, 2, (byte) (f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23)); + output.set(0, 3, (byte) (f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03)); + output.set(1, 3, (byte) (f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13)); + output.set(2, 3, (byte) (f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23)); + output.set(0, 4, (byte) (f04 * s00 + f14 * s01 + f24 * s02 + f34 * s03)); + output.set(1, 4, (byte) (f04 * s10 + f14 * s11 + f24 * s12 + f34 * s13)); + output.set(2, 4, (byte) (f04 * s20 + f14 * s21 + f24 * s22 + f34 * s23)); return output; } private static IMatrixSetterByte multiplyMatrix5x4x4(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final byte f_c00 = matrix1.get(0, 0); - final byte f_c10 = matrix1.get(1, 0); - final byte f_c20 = matrix1.get(2, 0); - final byte f_c30 = matrix1.get(3, 0); - final byte f_c01 = matrix1.get(0, 1); - final byte f_c11 = matrix1.get(1, 1); - final byte f_c21 = matrix1.get(2, 1); - final byte f_c31 = matrix1.get(3, 1); - final byte f_c02 = matrix1.get(0, 2); - final byte f_c12 = matrix1.get(1, 2); - final byte f_c22 = matrix1.get(2, 2); - final byte f_c32 = matrix1.get(3, 2); - final byte f_c03 = matrix1.get(0, 3); - final byte f_c13 = matrix1.get(1, 3); - final byte f_c23 = matrix1.get(2, 3); - final byte f_c33 = matrix1.get(3, 3); - final byte f_c04 = matrix1.get(0, 4); - final byte f_c14 = matrix1.get(1, 4); - final byte f_c24 = matrix1.get(2, 4); - final byte f_c34 = matrix1.get(3, 4); - final byte s_c00 = matrix2.get(0, 0); - final byte s_c10 = matrix2.get(1, 0); - final byte s_c20 = matrix2.get(2, 0); - final byte s_c30 = matrix2.get(3, 0); - final byte s_c01 = matrix2.get(0, 1); - final byte s_c11 = matrix2.get(1, 1); - final byte s_c21 = matrix2.get(2, 1); - final byte s_c31 = matrix2.get(3, 1); - final byte s_c02 = matrix2.get(0, 2); - final byte s_c12 = matrix2.get(1, 2); - final byte s_c22 = matrix2.get(2, 2); - final byte s_c32 = matrix2.get(3, 2); - final byte s_c03 = matrix2.get(0, 3); - final byte s_c13 = matrix2.get(1, 3); - final byte s_c23 = matrix2.get(2, 3); - final byte s_c33 = matrix2.get(3, 3); - output.set(0, 0, (byte) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03)); - output.set(0, 1, (byte) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03)); - output.set(0, 2, (byte) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03)); - output.set(0, 3, (byte) (f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03)); - output.set(0, 4, (byte) (f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02 + f_c34*s_c03)); - output.set(1, 0, (byte) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13)); - output.set(1, 1, (byte) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13)); - output.set(1, 2, (byte) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13)); - output.set(1, 3, (byte) (f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13)); - output.set(1, 4, (byte) (f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12 + f_c34*s_c13)); - output.set(2, 0, (byte) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23)); - output.set(2, 1, (byte) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23)); - output.set(2, 2, (byte) (f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23)); - output.set(2, 3, (byte) (f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23)); - output.set(2, 4, (byte) (f_c04*s_c20 + f_c14*s_c21 + f_c24*s_c22 + f_c34*s_c23)); - output.set(3, 0, (byte) (f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33)); - output.set(3, 1, (byte) (f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33)); - output.set(3, 2, (byte) (f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33)); - output.set(3, 3, (byte) (f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32 + f_c33*s_c33)); - output.set(3, 4, (byte) (f_c04*s_c30 + f_c14*s_c31 + f_c24*s_c32 + f_c34*s_c33)); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte f30 = matrix1.get(3, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f21 = matrix1.get(2, 1); + final byte f31 = matrix1.get(3, 1); + final byte f02 = matrix1.get(0, 2); + final byte f12 = matrix1.get(1, 2); + final byte f22 = matrix1.get(2, 2); + final byte f32 = matrix1.get(3, 2); + final byte f03 = matrix1.get(0, 3); + final byte f13 = matrix1.get(1, 3); + final byte f23 = matrix1.get(2, 3); + final byte f33 = matrix1.get(3, 3); + final byte f04 = matrix1.get(0, 4); + final byte f14 = matrix1.get(1, 4); + final byte f24 = matrix1.get(2, 4); + final byte f34 = matrix1.get(3, 4); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + final byte s30 = matrix2.get(3, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s21 = matrix2.get(2, 1); + final byte s31 = matrix2.get(3, 1); + final byte s02 = matrix2.get(0, 2); + final byte s12 = matrix2.get(1, 2); + final byte s22 = matrix2.get(2, 2); + final byte s32 = matrix2.get(3, 2); + final byte s03 = matrix2.get(0, 3); + final byte s13 = matrix2.get(1, 3); + final byte s23 = matrix2.get(2, 3); + final byte s33 = matrix2.get(3, 3); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13)); + output.set(2, 0, (byte) (f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23)); + output.set(3, 0, (byte) (f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03)); + output.set(1, 1, (byte) (f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13)); + output.set(2, 1, (byte) (f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23)); + output.set(3, 1, (byte) (f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33)); + output.set(0, 2, (byte) (f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03)); + output.set(1, 2, (byte) (f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13)); + output.set(2, 2, (byte) (f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23)); + output.set(3, 2, (byte) (f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33)); + output.set(0, 3, (byte) (f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03)); + output.set(1, 3, (byte) (f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13)); + output.set(2, 3, (byte) (f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23)); + output.set(3, 3, (byte) (f03 * s30 + f13 * s31 + f23 * s32 + f33 * s33)); + output.set(0, 4, (byte) (f04 * s00 + f14 * s01 + f24 * s02 + f34 * s03)); + output.set(1, 4, (byte) (f04 * s10 + f14 * s11 + f24 * s12 + f34 * s13)); + output.set(2, 4, (byte) (f04 * s20 + f14 * s21 + f24 * s22 + f34 * s23)); + output.set(3, 4, (byte) (f04 * s30 + f14 * s31 + f24 * s32 + f34 * s33)); return output; } private static IMatrixSetterByte multiplyMatrix5x4x5(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final byte f_c00 = matrix1.get(0, 0); - final byte f_c10 = matrix1.get(1, 0); - final byte f_c20 = matrix1.get(2, 0); - final byte f_c30 = matrix1.get(3, 0); - final byte f_c01 = matrix1.get(0, 1); - final byte f_c11 = matrix1.get(1, 1); - final byte f_c21 = matrix1.get(2, 1); - final byte f_c31 = matrix1.get(3, 1); - final byte f_c02 = matrix1.get(0, 2); - final byte f_c12 = matrix1.get(1, 2); - final byte f_c22 = matrix1.get(2, 2); - final byte f_c32 = matrix1.get(3, 2); - final byte f_c03 = matrix1.get(0, 3); - final byte f_c13 = matrix1.get(1, 3); - final byte f_c23 = matrix1.get(2, 3); - final byte f_c33 = matrix1.get(3, 3); - final byte f_c04 = matrix1.get(0, 4); - final byte f_c14 = matrix1.get(1, 4); - final byte f_c24 = matrix1.get(2, 4); - final byte f_c34 = matrix1.get(3, 4); - final byte s_c00 = matrix2.get(0, 0); - final byte s_c10 = matrix2.get(1, 0); - final byte s_c20 = matrix2.get(2, 0); - final byte s_c30 = matrix2.get(3, 0); - final byte s_c40 = matrix2.get(4, 0); - final byte s_c01 = matrix2.get(0, 1); - final byte s_c11 = matrix2.get(1, 1); - final byte s_c21 = matrix2.get(2, 1); - final byte s_c31 = matrix2.get(3, 1); - final byte s_c41 = matrix2.get(4, 1); - final byte s_c02 = matrix2.get(0, 2); - final byte s_c12 = matrix2.get(1, 2); - final byte s_c22 = matrix2.get(2, 2); - final byte s_c32 = matrix2.get(3, 2); - final byte s_c42 = matrix2.get(4, 2); - final byte s_c03 = matrix2.get(0, 3); - final byte s_c13 = matrix2.get(1, 3); - final byte s_c23 = matrix2.get(2, 3); - final byte s_c33 = matrix2.get(3, 3); - final byte s_c43 = matrix2.get(4, 3); - output.set(0, 0, (byte) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03)); - output.set(0, 1, (byte) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03)); - output.set(0, 2, (byte) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03)); - output.set(0, 3, (byte) (f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03)); - output.set(0, 4, (byte) (f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02 + f_c34*s_c03)); - output.set(1, 0, (byte) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13)); - output.set(1, 1, (byte) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13)); - output.set(1, 2, (byte) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13)); - output.set(1, 3, (byte) (f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13)); - output.set(1, 4, (byte) (f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12 + f_c34*s_c13)); - output.set(2, 0, (byte) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23)); - output.set(2, 1, (byte) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23)); - output.set(2, 2, (byte) (f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23)); - output.set(2, 3, (byte) (f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23)); - output.set(2, 4, (byte) (f_c04*s_c20 + f_c14*s_c21 + f_c24*s_c22 + f_c34*s_c23)); - output.set(3, 0, (byte) (f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33)); - output.set(3, 1, (byte) (f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33)); - output.set(3, 2, (byte) (f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33)); - output.set(3, 3, (byte) (f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32 + f_c33*s_c33)); - output.set(3, 4, (byte) (f_c04*s_c30 + f_c14*s_c31 + f_c24*s_c32 + f_c34*s_c33)); - output.set(4, 0, (byte) (f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42 + f_c30*s_c43)); - output.set(4, 1, (byte) (f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42 + f_c31*s_c43)); - output.set(4, 2, (byte) (f_c02*s_c40 + f_c12*s_c41 + f_c22*s_c42 + f_c32*s_c43)); - output.set(4, 3, (byte) (f_c03*s_c40 + f_c13*s_c41 + f_c23*s_c42 + f_c33*s_c43)); - output.set(4, 4, (byte) (f_c04*s_c40 + f_c14*s_c41 + f_c24*s_c42 + f_c34*s_c43)); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte f30 = matrix1.get(3, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f21 = matrix1.get(2, 1); + final byte f31 = matrix1.get(3, 1); + final byte f02 = matrix1.get(0, 2); + final byte f12 = matrix1.get(1, 2); + final byte f22 = matrix1.get(2, 2); + final byte f32 = matrix1.get(3, 2); + final byte f03 = matrix1.get(0, 3); + final byte f13 = matrix1.get(1, 3); + final byte f23 = matrix1.get(2, 3); + final byte f33 = matrix1.get(3, 3); + final byte f04 = matrix1.get(0, 4); + final byte f14 = matrix1.get(1, 4); + final byte f24 = matrix1.get(2, 4); + final byte f34 = matrix1.get(3, 4); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + final byte s30 = matrix2.get(3, 0); + final byte s40 = matrix2.get(4, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s21 = matrix2.get(2, 1); + final byte s31 = matrix2.get(3, 1); + final byte s41 = matrix2.get(4, 1); + final byte s02 = matrix2.get(0, 2); + final byte s12 = matrix2.get(1, 2); + final byte s22 = matrix2.get(2, 2); + final byte s32 = matrix2.get(3, 2); + final byte s42 = matrix2.get(4, 2); + final byte s03 = matrix2.get(0, 3); + final byte s13 = matrix2.get(1, 3); + final byte s23 = matrix2.get(2, 3); + final byte s33 = matrix2.get(3, 3); + final byte s43 = matrix2.get(4, 3); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13)); + output.set(2, 0, (byte) (f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23)); + output.set(3, 0, (byte) (f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33)); + output.set(4, 0, (byte) (f00 * s40 + f10 * s41 + f20 * s42 + f30 * s43)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03)); + output.set(1, 1, (byte) (f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13)); + output.set(2, 1, (byte) (f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23)); + output.set(3, 1, (byte) (f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33)); + output.set(4, 1, (byte) (f01 * s40 + f11 * s41 + f21 * s42 + f31 * s43)); + output.set(0, 2, (byte) (f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03)); + output.set(1, 2, (byte) (f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13)); + output.set(2, 2, (byte) (f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23)); + output.set(3, 2, (byte) (f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33)); + output.set(4, 2, (byte) (f02 * s40 + f12 * s41 + f22 * s42 + f32 * s43)); + output.set(0, 3, (byte) (f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03)); + output.set(1, 3, (byte) (f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13)); + output.set(2, 3, (byte) (f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23)); + output.set(3, 3, (byte) (f03 * s30 + f13 * s31 + f23 * s32 + f33 * s33)); + output.set(4, 3, (byte) (f03 * s40 + f13 * s41 + f23 * s42 + f33 * s43)); + output.set(0, 4, (byte) (f04 * s00 + f14 * s01 + f24 * s02 + f34 * s03)); + output.set(1, 4, (byte) (f04 * s10 + f14 * s11 + f24 * s12 + f34 * s13)); + output.set(2, 4, (byte) (f04 * s20 + f14 * s21 + f24 * s22 + f34 * s23)); + output.set(3, 4, (byte) (f04 * s30 + f14 * s31 + f24 * s32 + f34 * s33)); + output.set(4, 4, (byte) (f04 * s40 + f14 * s41 + f24 * s42 + f34 * s43)); + return output; + } + + private static IMatrixSetterByte multiplyMatrix1x5x1(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte f30 = matrix1.get(3, 0); + final byte f40 = matrix1.get(4, 0); + final byte s00 = matrix2.get(0, 0); + final byte s01 = matrix2.get(0, 1); + final byte s02 = matrix2.get(0, 2); + final byte s03 = matrix2.get(0, 3); + final byte s04 = matrix2.get(0, 4); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04)); + return output; + } + + private static IMatrixSetterByte multiplyMatrix1x5x2(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte f30 = matrix1.get(3, 0); + final byte f40 = matrix1.get(4, 0); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s02 = matrix2.get(0, 2); + final byte s12 = matrix2.get(1, 2); + final byte s03 = matrix2.get(0, 3); + final byte s13 = matrix2.get(1, 3); + final byte s04 = matrix2.get(0, 4); + final byte s14 = matrix2.get(1, 4); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14)); + return output; + } + + private static IMatrixSetterByte multiplyMatrix1x5x3(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte f30 = matrix1.get(3, 0); + final byte f40 = matrix1.get(4, 0); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s21 = matrix2.get(2, 1); + final byte s02 = matrix2.get(0, 2); + final byte s12 = matrix2.get(1, 2); + final byte s22 = matrix2.get(2, 2); + final byte s03 = matrix2.get(0, 3); + final byte s13 = matrix2.get(1, 3); + final byte s23 = matrix2.get(2, 3); + final byte s04 = matrix2.get(0, 4); + final byte s14 = matrix2.get(1, 4); + final byte s24 = matrix2.get(2, 4); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14)); + output.set(2, 0, (byte) (f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24)); + return output; + } + + private static IMatrixSetterByte multiplyMatrix1x5x4(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte f30 = matrix1.get(3, 0); + final byte f40 = matrix1.get(4, 0); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + final byte s30 = matrix2.get(3, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s21 = matrix2.get(2, 1); + final byte s31 = matrix2.get(3, 1); + final byte s02 = matrix2.get(0, 2); + final byte s12 = matrix2.get(1, 2); + final byte s22 = matrix2.get(2, 2); + final byte s32 = matrix2.get(3, 2); + final byte s03 = matrix2.get(0, 3); + final byte s13 = matrix2.get(1, 3); + final byte s23 = matrix2.get(2, 3); + final byte s33 = matrix2.get(3, 3); + final byte s04 = matrix2.get(0, 4); + final byte s14 = matrix2.get(1, 4); + final byte s24 = matrix2.get(2, 4); + final byte s34 = matrix2.get(3, 4); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14)); + output.set(2, 0, (byte) (f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24)); + output.set(3, 0, (byte) (f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33 + f40 * s34)); + return output; + } + + private static IMatrixSetterByte multiplyMatrix1x5x5(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte f30 = matrix1.get(3, 0); + final byte f40 = matrix1.get(4, 0); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + final byte s30 = matrix2.get(3, 0); + final byte s40 = matrix2.get(4, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s21 = matrix2.get(2, 1); + final byte s31 = matrix2.get(3, 1); + final byte s41 = matrix2.get(4, 1); + final byte s02 = matrix2.get(0, 2); + final byte s12 = matrix2.get(1, 2); + final byte s22 = matrix2.get(2, 2); + final byte s32 = matrix2.get(3, 2); + final byte s42 = matrix2.get(4, 2); + final byte s03 = matrix2.get(0, 3); + final byte s13 = matrix2.get(1, 3); + final byte s23 = matrix2.get(2, 3); + final byte s33 = matrix2.get(3, 3); + final byte s43 = matrix2.get(4, 3); + final byte s04 = matrix2.get(0, 4); + final byte s14 = matrix2.get(1, 4); + final byte s24 = matrix2.get(2, 4); + final byte s34 = matrix2.get(3, 4); + final byte s44 = matrix2.get(4, 4); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14)); + output.set(2, 0, (byte) (f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24)); + output.set(3, 0, (byte) (f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33 + f40 * s34)); + output.set(4, 0, (byte) (f00 * s40 + f10 * s41 + f20 * s42 + f30 * s43 + f40 * s44)); + return output; + } + + private static IMatrixSetterByte multiplyMatrix2x5x1(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte f30 = matrix1.get(3, 0); + final byte f40 = matrix1.get(4, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f21 = matrix1.get(2, 1); + final byte f31 = matrix1.get(3, 1); + final byte f41 = matrix1.get(4, 1); + final byte s00 = matrix2.get(0, 0); + final byte s01 = matrix2.get(0, 1); + final byte s02 = matrix2.get(0, 2); + final byte s03 = matrix2.get(0, 3); + final byte s04 = matrix2.get(0, 4); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04)); return output; } private static IMatrixSetterByte multiplyMatrix2x5x2(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final byte f_c00 = matrix1.get(0, 0); - final byte f_c10 = matrix1.get(1, 0); - final byte f_c20 = matrix1.get(2, 0); - final byte f_c30 = matrix1.get(3, 0); - final byte f_c40 = matrix1.get(4, 0); - final byte f_c01 = matrix1.get(0, 1); - final byte f_c11 = matrix1.get(1, 1); - final byte f_c21 = matrix1.get(2, 1); - final byte f_c31 = matrix1.get(3, 1); - final byte f_c41 = matrix1.get(4, 1); - final byte s_c00 = matrix2.get(0, 0); - final byte s_c10 = matrix2.get(1, 0); - final byte s_c01 = matrix2.get(0, 1); - final byte s_c11 = matrix2.get(1, 1); - final byte s_c02 = matrix2.get(0, 2); - final byte s_c12 = matrix2.get(1, 2); - final byte s_c03 = matrix2.get(0, 3); - final byte s_c13 = matrix2.get(1, 3); - final byte s_c04 = matrix2.get(0, 4); - final byte s_c14 = matrix2.get(1, 4); - output.set(0, 0, (byte) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04)); - output.set(0, 1, (byte) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04)); - output.set(1, 0, (byte) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14)); - output.set(1, 1, (byte) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14)); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte f30 = matrix1.get(3, 0); + final byte f40 = matrix1.get(4, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f21 = matrix1.get(2, 1); + final byte f31 = matrix1.get(3, 1); + final byte f41 = matrix1.get(4, 1); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s02 = matrix2.get(0, 2); + final byte s12 = matrix2.get(1, 2); + final byte s03 = matrix2.get(0, 3); + final byte s13 = matrix2.get(1, 3); + final byte s04 = matrix2.get(0, 4); + final byte s14 = matrix2.get(1, 4); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04)); + output.set(1, 1, (byte) (f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14)); return output; } private static IMatrixSetterByte multiplyMatrix2x5x3(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final byte f_c00 = matrix1.get(0, 0); - final byte f_c10 = matrix1.get(1, 0); - final byte f_c20 = matrix1.get(2, 0); - final byte f_c30 = matrix1.get(3, 0); - final byte f_c40 = matrix1.get(4, 0); - final byte f_c01 = matrix1.get(0, 1); - final byte f_c11 = matrix1.get(1, 1); - final byte f_c21 = matrix1.get(2, 1); - final byte f_c31 = matrix1.get(3, 1); - final byte f_c41 = matrix1.get(4, 1); - final byte s_c00 = matrix2.get(0, 0); - final byte s_c10 = matrix2.get(1, 0); - final byte s_c20 = matrix2.get(2, 0); - final byte s_c01 = matrix2.get(0, 1); - final byte s_c11 = matrix2.get(1, 1); - final byte s_c21 = matrix2.get(2, 1); - final byte s_c02 = matrix2.get(0, 2); - final byte s_c12 = matrix2.get(1, 2); - final byte s_c22 = matrix2.get(2, 2); - final byte s_c03 = matrix2.get(0, 3); - final byte s_c13 = matrix2.get(1, 3); - final byte s_c23 = matrix2.get(2, 3); - final byte s_c04 = matrix2.get(0, 4); - final byte s_c14 = matrix2.get(1, 4); - final byte s_c24 = matrix2.get(2, 4); - output.set(0, 0, (byte) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04)); - output.set(0, 1, (byte) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04)); - output.set(1, 0, (byte) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14)); - output.set(1, 1, (byte) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14)); - output.set(2, 0, (byte) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24)); - output.set(2, 1, (byte) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24)); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte f30 = matrix1.get(3, 0); + final byte f40 = matrix1.get(4, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f21 = matrix1.get(2, 1); + final byte f31 = matrix1.get(3, 1); + final byte f41 = matrix1.get(4, 1); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s21 = matrix2.get(2, 1); + final byte s02 = matrix2.get(0, 2); + final byte s12 = matrix2.get(1, 2); + final byte s22 = matrix2.get(2, 2); + final byte s03 = matrix2.get(0, 3); + final byte s13 = matrix2.get(1, 3); + final byte s23 = matrix2.get(2, 3); + final byte s04 = matrix2.get(0, 4); + final byte s14 = matrix2.get(1, 4); + final byte s24 = matrix2.get(2, 4); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14)); + output.set(2, 0, (byte) (f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04)); + output.set(1, 1, (byte) (f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14)); + output.set(2, 1, (byte) (f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24)); return output; } private static IMatrixSetterByte multiplyMatrix2x5x4(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final byte f_c00 = matrix1.get(0, 0); - final byte f_c10 = matrix1.get(1, 0); - final byte f_c20 = matrix1.get(2, 0); - final byte f_c30 = matrix1.get(3, 0); - final byte f_c40 = matrix1.get(4, 0); - final byte f_c01 = matrix1.get(0, 1); - final byte f_c11 = matrix1.get(1, 1); - final byte f_c21 = matrix1.get(2, 1); - final byte f_c31 = matrix1.get(3, 1); - final byte f_c41 = matrix1.get(4, 1); - final byte s_c00 = matrix2.get(0, 0); - final byte s_c10 = matrix2.get(1, 0); - final byte s_c20 = matrix2.get(2, 0); - final byte s_c30 = matrix2.get(3, 0); - final byte s_c01 = matrix2.get(0, 1); - final byte s_c11 = matrix2.get(1, 1); - final byte s_c21 = matrix2.get(2, 1); - final byte s_c31 = matrix2.get(3, 1); - final byte s_c02 = matrix2.get(0, 2); - final byte s_c12 = matrix2.get(1, 2); - final byte s_c22 = matrix2.get(2, 2); - final byte s_c32 = matrix2.get(3, 2); - final byte s_c03 = matrix2.get(0, 3); - final byte s_c13 = matrix2.get(1, 3); - final byte s_c23 = matrix2.get(2, 3); - final byte s_c33 = matrix2.get(3, 3); - final byte s_c04 = matrix2.get(0, 4); - final byte s_c14 = matrix2.get(1, 4); - final byte s_c24 = matrix2.get(2, 4); - final byte s_c34 = matrix2.get(3, 4); - output.set(0, 0, (byte) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04)); - output.set(0, 1, (byte) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04)); - output.set(1, 0, (byte) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14)); - output.set(1, 1, (byte) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14)); - output.set(2, 0, (byte) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24)); - output.set(2, 1, (byte) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24)); - output.set(3, 0, (byte) (f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33 + f_c40*s_c34)); - output.set(3, 1, (byte) (f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33 + f_c41*s_c34)); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte f30 = matrix1.get(3, 0); + final byte f40 = matrix1.get(4, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f21 = matrix1.get(2, 1); + final byte f31 = matrix1.get(3, 1); + final byte f41 = matrix1.get(4, 1); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + final byte s30 = matrix2.get(3, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s21 = matrix2.get(2, 1); + final byte s31 = matrix2.get(3, 1); + final byte s02 = matrix2.get(0, 2); + final byte s12 = matrix2.get(1, 2); + final byte s22 = matrix2.get(2, 2); + final byte s32 = matrix2.get(3, 2); + final byte s03 = matrix2.get(0, 3); + final byte s13 = matrix2.get(1, 3); + final byte s23 = matrix2.get(2, 3); + final byte s33 = matrix2.get(3, 3); + final byte s04 = matrix2.get(0, 4); + final byte s14 = matrix2.get(1, 4); + final byte s24 = matrix2.get(2, 4); + final byte s34 = matrix2.get(3, 4); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14)); + output.set(2, 0, (byte) (f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24)); + output.set(3, 0, (byte) (f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33 + f40 * s34)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04)); + output.set(1, 1, (byte) (f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14)); + output.set(2, 1, (byte) (f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24)); + output.set(3, 1, (byte) (f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33 + f41 * s34)); return output; } private static IMatrixSetterByte multiplyMatrix2x5x5(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final byte f_c00 = matrix1.get(0, 0); - final byte f_c10 = matrix1.get(1, 0); - final byte f_c20 = matrix1.get(2, 0); - final byte f_c30 = matrix1.get(3, 0); - final byte f_c40 = matrix1.get(4, 0); - final byte f_c01 = matrix1.get(0, 1); - final byte f_c11 = matrix1.get(1, 1); - final byte f_c21 = matrix1.get(2, 1); - final byte f_c31 = matrix1.get(3, 1); - final byte f_c41 = matrix1.get(4, 1); - final byte s_c00 = matrix2.get(0, 0); - final byte s_c10 = matrix2.get(1, 0); - final byte s_c20 = matrix2.get(2, 0); - final byte s_c30 = matrix2.get(3, 0); - final byte s_c40 = matrix2.get(4, 0); - final byte s_c01 = matrix2.get(0, 1); - final byte s_c11 = matrix2.get(1, 1); - final byte s_c21 = matrix2.get(2, 1); - final byte s_c31 = matrix2.get(3, 1); - final byte s_c41 = matrix2.get(4, 1); - final byte s_c02 = matrix2.get(0, 2); - final byte s_c12 = matrix2.get(1, 2); - final byte s_c22 = matrix2.get(2, 2); - final byte s_c32 = matrix2.get(3, 2); - final byte s_c42 = matrix2.get(4, 2); - final byte s_c03 = matrix2.get(0, 3); - final byte s_c13 = matrix2.get(1, 3); - final byte s_c23 = matrix2.get(2, 3); - final byte s_c33 = matrix2.get(3, 3); - final byte s_c43 = matrix2.get(4, 3); - final byte s_c04 = matrix2.get(0, 4); - final byte s_c14 = matrix2.get(1, 4); - final byte s_c24 = matrix2.get(2, 4); - final byte s_c34 = matrix2.get(3, 4); - final byte s_c44 = matrix2.get(4, 4); - output.set(0, 0, (byte) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04)); - output.set(0, 1, (byte) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04)); - output.set(1, 0, (byte) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14)); - output.set(1, 1, (byte) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14)); - output.set(2, 0, (byte) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24)); - output.set(2, 1, (byte) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24)); - output.set(3, 0, (byte) (f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33 + f_c40*s_c34)); - output.set(3, 1, (byte) (f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33 + f_c41*s_c34)); - output.set(4, 0, (byte) (f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42 + f_c30*s_c43 + f_c40*s_c44)); - output.set(4, 1, (byte) (f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42 + f_c31*s_c43 + f_c41*s_c44)); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte f30 = matrix1.get(3, 0); + final byte f40 = matrix1.get(4, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f21 = matrix1.get(2, 1); + final byte f31 = matrix1.get(3, 1); + final byte f41 = matrix1.get(4, 1); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + final byte s30 = matrix2.get(3, 0); + final byte s40 = matrix2.get(4, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s21 = matrix2.get(2, 1); + final byte s31 = matrix2.get(3, 1); + final byte s41 = matrix2.get(4, 1); + final byte s02 = matrix2.get(0, 2); + final byte s12 = matrix2.get(1, 2); + final byte s22 = matrix2.get(2, 2); + final byte s32 = matrix2.get(3, 2); + final byte s42 = matrix2.get(4, 2); + final byte s03 = matrix2.get(0, 3); + final byte s13 = matrix2.get(1, 3); + final byte s23 = matrix2.get(2, 3); + final byte s33 = matrix2.get(3, 3); + final byte s43 = matrix2.get(4, 3); + final byte s04 = matrix2.get(0, 4); + final byte s14 = matrix2.get(1, 4); + final byte s24 = matrix2.get(2, 4); + final byte s34 = matrix2.get(3, 4); + final byte s44 = matrix2.get(4, 4); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14)); + output.set(2, 0, (byte) (f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24)); + output.set(3, 0, (byte) (f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33 + f40 * s34)); + output.set(4, 0, (byte) (f00 * s40 + f10 * s41 + f20 * s42 + f30 * s43 + f40 * s44)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04)); + output.set(1, 1, (byte) (f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14)); + output.set(2, 1, (byte) (f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24)); + output.set(3, 1, (byte) (f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33 + f41 * s34)); + output.set(4, 1, (byte) (f01 * s40 + f11 * s41 + f21 * s42 + f31 * s43 + f41 * s44)); + return output; + } + + private static IMatrixSetterByte multiplyMatrix3x5x1(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte f30 = matrix1.get(3, 0); + final byte f40 = matrix1.get(4, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f21 = matrix1.get(2, 1); + final byte f31 = matrix1.get(3, 1); + final byte f41 = matrix1.get(4, 1); + final byte f02 = matrix1.get(0, 2); + final byte f12 = matrix1.get(1, 2); + final byte f22 = matrix1.get(2, 2); + final byte f32 = matrix1.get(3, 2); + final byte f42 = matrix1.get(4, 2); + final byte s00 = matrix2.get(0, 0); + final byte s01 = matrix2.get(0, 1); + final byte s02 = matrix2.get(0, 2); + final byte s03 = matrix2.get(0, 3); + final byte s04 = matrix2.get(0, 4); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04)); + output.set(0, 2, (byte) (f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04)); return output; } private static IMatrixSetterByte multiplyMatrix3x5x2(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final byte f_c00 = matrix1.get(0, 0); - final byte f_c10 = matrix1.get(1, 0); - final byte f_c20 = matrix1.get(2, 0); - final byte f_c30 = matrix1.get(3, 0); - final byte f_c40 = matrix1.get(4, 0); - final byte f_c01 = matrix1.get(0, 1); - final byte f_c11 = matrix1.get(1, 1); - final byte f_c21 = matrix1.get(2, 1); - final byte f_c31 = matrix1.get(3, 1); - final byte f_c41 = matrix1.get(4, 1); - final byte f_c02 = matrix1.get(0, 2); - final byte f_c12 = matrix1.get(1, 2); - final byte f_c22 = matrix1.get(2, 2); - final byte f_c32 = matrix1.get(3, 2); - final byte f_c42 = matrix1.get(4, 2); - final byte s_c00 = matrix2.get(0, 0); - final byte s_c10 = matrix2.get(1, 0); - final byte s_c01 = matrix2.get(0, 1); - final byte s_c11 = matrix2.get(1, 1); - final byte s_c02 = matrix2.get(0, 2); - final byte s_c12 = matrix2.get(1, 2); - final byte s_c03 = matrix2.get(0, 3); - final byte s_c13 = matrix2.get(1, 3); - final byte s_c04 = matrix2.get(0, 4); - final byte s_c14 = matrix2.get(1, 4); - output.set(0, 0, (byte) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04)); - output.set(0, 1, (byte) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04)); - output.set(0, 2, (byte) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04)); - output.set(1, 0, (byte) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14)); - output.set(1, 1, (byte) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14)); - output.set(1, 2, (byte) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14)); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte f30 = matrix1.get(3, 0); + final byte f40 = matrix1.get(4, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f21 = matrix1.get(2, 1); + final byte f31 = matrix1.get(3, 1); + final byte f41 = matrix1.get(4, 1); + final byte f02 = matrix1.get(0, 2); + final byte f12 = matrix1.get(1, 2); + final byte f22 = matrix1.get(2, 2); + final byte f32 = matrix1.get(3, 2); + final byte f42 = matrix1.get(4, 2); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s02 = matrix2.get(0, 2); + final byte s12 = matrix2.get(1, 2); + final byte s03 = matrix2.get(0, 3); + final byte s13 = matrix2.get(1, 3); + final byte s04 = matrix2.get(0, 4); + final byte s14 = matrix2.get(1, 4); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04)); + output.set(1, 1, (byte) (f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14)); + output.set(0, 2, (byte) (f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04)); + output.set(1, 2, (byte) (f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14)); return output; } private static IMatrixSetterByte multiplyMatrix3x5x3(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final byte f_c00 = matrix1.get(0, 0); - final byte f_c10 = matrix1.get(1, 0); - final byte f_c20 = matrix1.get(2, 0); - final byte f_c30 = matrix1.get(3, 0); - final byte f_c40 = matrix1.get(4, 0); - final byte f_c01 = matrix1.get(0, 1); - final byte f_c11 = matrix1.get(1, 1); - final byte f_c21 = matrix1.get(2, 1); - final byte f_c31 = matrix1.get(3, 1); - final byte f_c41 = matrix1.get(4, 1); - final byte f_c02 = matrix1.get(0, 2); - final byte f_c12 = matrix1.get(1, 2); - final byte f_c22 = matrix1.get(2, 2); - final byte f_c32 = matrix1.get(3, 2); - final byte f_c42 = matrix1.get(4, 2); - final byte s_c00 = matrix2.get(0, 0); - final byte s_c10 = matrix2.get(1, 0); - final byte s_c20 = matrix2.get(2, 0); - final byte s_c01 = matrix2.get(0, 1); - final byte s_c11 = matrix2.get(1, 1); - final byte s_c21 = matrix2.get(2, 1); - final byte s_c02 = matrix2.get(0, 2); - final byte s_c12 = matrix2.get(1, 2); - final byte s_c22 = matrix2.get(2, 2); - final byte s_c03 = matrix2.get(0, 3); - final byte s_c13 = matrix2.get(1, 3); - final byte s_c23 = matrix2.get(2, 3); - final byte s_c04 = matrix2.get(0, 4); - final byte s_c14 = matrix2.get(1, 4); - final byte s_c24 = matrix2.get(2, 4); - output.set(0, 0, (byte) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04)); - output.set(0, 1, (byte) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04)); - output.set(0, 2, (byte) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04)); - output.set(1, 0, (byte) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14)); - output.set(1, 1, (byte) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14)); - output.set(1, 2, (byte) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14)); - output.set(2, 0, (byte) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24)); - output.set(2, 1, (byte) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24)); - output.set(2, 2, (byte) (f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23 + f_c42*s_c24)); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte f30 = matrix1.get(3, 0); + final byte f40 = matrix1.get(4, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f21 = matrix1.get(2, 1); + final byte f31 = matrix1.get(3, 1); + final byte f41 = matrix1.get(4, 1); + final byte f02 = matrix1.get(0, 2); + final byte f12 = matrix1.get(1, 2); + final byte f22 = matrix1.get(2, 2); + final byte f32 = matrix1.get(3, 2); + final byte f42 = matrix1.get(4, 2); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s21 = matrix2.get(2, 1); + final byte s02 = matrix2.get(0, 2); + final byte s12 = matrix2.get(1, 2); + final byte s22 = matrix2.get(2, 2); + final byte s03 = matrix2.get(0, 3); + final byte s13 = matrix2.get(1, 3); + final byte s23 = matrix2.get(2, 3); + final byte s04 = matrix2.get(0, 4); + final byte s14 = matrix2.get(1, 4); + final byte s24 = matrix2.get(2, 4); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14)); + output.set(2, 0, (byte) (f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04)); + output.set(1, 1, (byte) (f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14)); + output.set(2, 1, (byte) (f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24)); + output.set(0, 2, (byte) (f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04)); + output.set(1, 2, (byte) (f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14)); + output.set(2, 2, (byte) (f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23 + f42 * s24)); return output; } private static IMatrixSetterByte multiplyMatrix3x5x4(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final byte f_c00 = matrix1.get(0, 0); - final byte f_c10 = matrix1.get(1, 0); - final byte f_c20 = matrix1.get(2, 0); - final byte f_c30 = matrix1.get(3, 0); - final byte f_c40 = matrix1.get(4, 0); - final byte f_c01 = matrix1.get(0, 1); - final byte f_c11 = matrix1.get(1, 1); - final byte f_c21 = matrix1.get(2, 1); - final byte f_c31 = matrix1.get(3, 1); - final byte f_c41 = matrix1.get(4, 1); - final byte f_c02 = matrix1.get(0, 2); - final byte f_c12 = matrix1.get(1, 2); - final byte f_c22 = matrix1.get(2, 2); - final byte f_c32 = matrix1.get(3, 2); - final byte f_c42 = matrix1.get(4, 2); - final byte s_c00 = matrix2.get(0, 0); - final byte s_c10 = matrix2.get(1, 0); - final byte s_c20 = matrix2.get(2, 0); - final byte s_c30 = matrix2.get(3, 0); - final byte s_c01 = matrix2.get(0, 1); - final byte s_c11 = matrix2.get(1, 1); - final byte s_c21 = matrix2.get(2, 1); - final byte s_c31 = matrix2.get(3, 1); - final byte s_c02 = matrix2.get(0, 2); - final byte s_c12 = matrix2.get(1, 2); - final byte s_c22 = matrix2.get(2, 2); - final byte s_c32 = matrix2.get(3, 2); - final byte s_c03 = matrix2.get(0, 3); - final byte s_c13 = matrix2.get(1, 3); - final byte s_c23 = matrix2.get(2, 3); - final byte s_c33 = matrix2.get(3, 3); - final byte s_c04 = matrix2.get(0, 4); - final byte s_c14 = matrix2.get(1, 4); - final byte s_c24 = matrix2.get(2, 4); - final byte s_c34 = matrix2.get(3, 4); - output.set(0, 0, (byte) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04)); - output.set(0, 1, (byte) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04)); - output.set(0, 2, (byte) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04)); - output.set(1, 0, (byte) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14)); - output.set(1, 1, (byte) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14)); - output.set(1, 2, (byte) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14)); - output.set(2, 0, (byte) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24)); - output.set(2, 1, (byte) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24)); - output.set(2, 2, (byte) (f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23 + f_c42*s_c24)); - output.set(3, 0, (byte) (f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33 + f_c40*s_c34)); - output.set(3, 1, (byte) (f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33 + f_c41*s_c34)); - output.set(3, 2, (byte) (f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33 + f_c42*s_c34)); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte f30 = matrix1.get(3, 0); + final byte f40 = matrix1.get(4, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f21 = matrix1.get(2, 1); + final byte f31 = matrix1.get(3, 1); + final byte f41 = matrix1.get(4, 1); + final byte f02 = matrix1.get(0, 2); + final byte f12 = matrix1.get(1, 2); + final byte f22 = matrix1.get(2, 2); + final byte f32 = matrix1.get(3, 2); + final byte f42 = matrix1.get(4, 2); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + final byte s30 = matrix2.get(3, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s21 = matrix2.get(2, 1); + final byte s31 = matrix2.get(3, 1); + final byte s02 = matrix2.get(0, 2); + final byte s12 = matrix2.get(1, 2); + final byte s22 = matrix2.get(2, 2); + final byte s32 = matrix2.get(3, 2); + final byte s03 = matrix2.get(0, 3); + final byte s13 = matrix2.get(1, 3); + final byte s23 = matrix2.get(2, 3); + final byte s33 = matrix2.get(3, 3); + final byte s04 = matrix2.get(0, 4); + final byte s14 = matrix2.get(1, 4); + final byte s24 = matrix2.get(2, 4); + final byte s34 = matrix2.get(3, 4); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14)); + output.set(2, 0, (byte) (f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24)); + output.set(3, 0, (byte) (f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33 + f40 * s34)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04)); + output.set(1, 1, (byte) (f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14)); + output.set(2, 1, (byte) (f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24)); + output.set(3, 1, (byte) (f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33 + f41 * s34)); + output.set(0, 2, (byte) (f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04)); + output.set(1, 2, (byte) (f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14)); + output.set(2, 2, (byte) (f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23 + f42 * s24)); + output.set(3, 2, (byte) (f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33 + f42 * s34)); return output; } private static IMatrixSetterByte multiplyMatrix3x5x5(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final byte f_c00 = matrix1.get(0, 0); - final byte f_c10 = matrix1.get(1, 0); - final byte f_c20 = matrix1.get(2, 0); - final byte f_c30 = matrix1.get(3, 0); - final byte f_c40 = matrix1.get(4, 0); - final byte f_c01 = matrix1.get(0, 1); - final byte f_c11 = matrix1.get(1, 1); - final byte f_c21 = matrix1.get(2, 1); - final byte f_c31 = matrix1.get(3, 1); - final byte f_c41 = matrix1.get(4, 1); - final byte f_c02 = matrix1.get(0, 2); - final byte f_c12 = matrix1.get(1, 2); - final byte f_c22 = matrix1.get(2, 2); - final byte f_c32 = matrix1.get(3, 2); - final byte f_c42 = matrix1.get(4, 2); - final byte s_c00 = matrix2.get(0, 0); - final byte s_c10 = matrix2.get(1, 0); - final byte s_c20 = matrix2.get(2, 0); - final byte s_c30 = matrix2.get(3, 0); - final byte s_c40 = matrix2.get(4, 0); - final byte s_c01 = matrix2.get(0, 1); - final byte s_c11 = matrix2.get(1, 1); - final byte s_c21 = matrix2.get(2, 1); - final byte s_c31 = matrix2.get(3, 1); - final byte s_c41 = matrix2.get(4, 1); - final byte s_c02 = matrix2.get(0, 2); - final byte s_c12 = matrix2.get(1, 2); - final byte s_c22 = matrix2.get(2, 2); - final byte s_c32 = matrix2.get(3, 2); - final byte s_c42 = matrix2.get(4, 2); - final byte s_c03 = matrix2.get(0, 3); - final byte s_c13 = matrix2.get(1, 3); - final byte s_c23 = matrix2.get(2, 3); - final byte s_c33 = matrix2.get(3, 3); - final byte s_c43 = matrix2.get(4, 3); - final byte s_c04 = matrix2.get(0, 4); - final byte s_c14 = matrix2.get(1, 4); - final byte s_c24 = matrix2.get(2, 4); - final byte s_c34 = matrix2.get(3, 4); - final byte s_c44 = matrix2.get(4, 4); - output.set(0, 0, (byte) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04)); - output.set(0, 1, (byte) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04)); - output.set(0, 2, (byte) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04)); - output.set(1, 0, (byte) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14)); - output.set(1, 1, (byte) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14)); - output.set(1, 2, (byte) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14)); - output.set(2, 0, (byte) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24)); - output.set(2, 1, (byte) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24)); - output.set(2, 2, (byte) (f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23 + f_c42*s_c24)); - output.set(3, 0, (byte) (f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33 + f_c40*s_c34)); - output.set(3, 1, (byte) (f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33 + f_c41*s_c34)); - output.set(3, 2, (byte) (f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33 + f_c42*s_c34)); - output.set(4, 0, (byte) (f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42 + f_c30*s_c43 + f_c40*s_c44)); - output.set(4, 1, (byte) (f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42 + f_c31*s_c43 + f_c41*s_c44)); - output.set(4, 2, (byte) (f_c02*s_c40 + f_c12*s_c41 + f_c22*s_c42 + f_c32*s_c43 + f_c42*s_c44)); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte f30 = matrix1.get(3, 0); + final byte f40 = matrix1.get(4, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f21 = matrix1.get(2, 1); + final byte f31 = matrix1.get(3, 1); + final byte f41 = matrix1.get(4, 1); + final byte f02 = matrix1.get(0, 2); + final byte f12 = matrix1.get(1, 2); + final byte f22 = matrix1.get(2, 2); + final byte f32 = matrix1.get(3, 2); + final byte f42 = matrix1.get(4, 2); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + final byte s30 = matrix2.get(3, 0); + final byte s40 = matrix2.get(4, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s21 = matrix2.get(2, 1); + final byte s31 = matrix2.get(3, 1); + final byte s41 = matrix2.get(4, 1); + final byte s02 = matrix2.get(0, 2); + final byte s12 = matrix2.get(1, 2); + final byte s22 = matrix2.get(2, 2); + final byte s32 = matrix2.get(3, 2); + final byte s42 = matrix2.get(4, 2); + final byte s03 = matrix2.get(0, 3); + final byte s13 = matrix2.get(1, 3); + final byte s23 = matrix2.get(2, 3); + final byte s33 = matrix2.get(3, 3); + final byte s43 = matrix2.get(4, 3); + final byte s04 = matrix2.get(0, 4); + final byte s14 = matrix2.get(1, 4); + final byte s24 = matrix2.get(2, 4); + final byte s34 = matrix2.get(3, 4); + final byte s44 = matrix2.get(4, 4); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14)); + output.set(2, 0, (byte) (f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24)); + output.set(3, 0, (byte) (f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33 + f40 * s34)); + output.set(4, 0, (byte) (f00 * s40 + f10 * s41 + f20 * s42 + f30 * s43 + f40 * s44)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04)); + output.set(1, 1, (byte) (f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14)); + output.set(2, 1, (byte) (f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24)); + output.set(3, 1, (byte) (f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33 + f41 * s34)); + output.set(4, 1, (byte) (f01 * s40 + f11 * s41 + f21 * s42 + f31 * s43 + f41 * s44)); + output.set(0, 2, (byte) (f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04)); + output.set(1, 2, (byte) (f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14)); + output.set(2, 2, (byte) (f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23 + f42 * s24)); + output.set(3, 2, (byte) (f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33 + f42 * s34)); + output.set(4, 2, (byte) (f02 * s40 + f12 * s41 + f22 * s42 + f32 * s43 + f42 * s44)); + return output; + } + + private static IMatrixSetterByte multiplyMatrix4x5x1(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte f30 = matrix1.get(3, 0); + final byte f40 = matrix1.get(4, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f21 = matrix1.get(2, 1); + final byte f31 = matrix1.get(3, 1); + final byte f41 = matrix1.get(4, 1); + final byte f02 = matrix1.get(0, 2); + final byte f12 = matrix1.get(1, 2); + final byte f22 = matrix1.get(2, 2); + final byte f32 = matrix1.get(3, 2); + final byte f42 = matrix1.get(4, 2); + final byte f03 = matrix1.get(0, 3); + final byte f13 = matrix1.get(1, 3); + final byte f23 = matrix1.get(2, 3); + final byte f33 = matrix1.get(3, 3); + final byte f43 = matrix1.get(4, 3); + final byte s00 = matrix2.get(0, 0); + final byte s01 = matrix2.get(0, 1); + final byte s02 = matrix2.get(0, 2); + final byte s03 = matrix2.get(0, 3); + final byte s04 = matrix2.get(0, 4); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04)); + output.set(0, 2, (byte) (f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04)); + output.set(0, 3, (byte) (f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03 + f43 * s04)); return output; } private static IMatrixSetterByte multiplyMatrix4x5x2(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final byte f_c00 = matrix1.get(0, 0); - final byte f_c10 = matrix1.get(1, 0); - final byte f_c20 = matrix1.get(2, 0); - final byte f_c30 = matrix1.get(3, 0); - final byte f_c40 = matrix1.get(4, 0); - final byte f_c01 = matrix1.get(0, 1); - final byte f_c11 = matrix1.get(1, 1); - final byte f_c21 = matrix1.get(2, 1); - final byte f_c31 = matrix1.get(3, 1); - final byte f_c41 = matrix1.get(4, 1); - final byte f_c02 = matrix1.get(0, 2); - final byte f_c12 = matrix1.get(1, 2); - final byte f_c22 = matrix1.get(2, 2); - final byte f_c32 = matrix1.get(3, 2); - final byte f_c42 = matrix1.get(4, 2); - final byte f_c03 = matrix1.get(0, 3); - final byte f_c13 = matrix1.get(1, 3); - final byte f_c23 = matrix1.get(2, 3); - final byte f_c33 = matrix1.get(3, 3); - final byte f_c43 = matrix1.get(4, 3); - final byte s_c00 = matrix2.get(0, 0); - final byte s_c10 = matrix2.get(1, 0); - final byte s_c01 = matrix2.get(0, 1); - final byte s_c11 = matrix2.get(1, 1); - final byte s_c02 = matrix2.get(0, 2); - final byte s_c12 = matrix2.get(1, 2); - final byte s_c03 = matrix2.get(0, 3); - final byte s_c13 = matrix2.get(1, 3); - final byte s_c04 = matrix2.get(0, 4); - final byte s_c14 = matrix2.get(1, 4); - output.set(0, 0, (byte) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04)); - output.set(0, 1, (byte) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04)); - output.set(0, 2, (byte) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04)); - output.set(0, 3, (byte) (f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03 + f_c43*s_c04)); - output.set(1, 0, (byte) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14)); - output.set(1, 1, (byte) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14)); - output.set(1, 2, (byte) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14)); - output.set(1, 3, (byte) (f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13 + f_c43*s_c14)); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte f30 = matrix1.get(3, 0); + final byte f40 = matrix1.get(4, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f21 = matrix1.get(2, 1); + final byte f31 = matrix1.get(3, 1); + final byte f41 = matrix1.get(4, 1); + final byte f02 = matrix1.get(0, 2); + final byte f12 = matrix1.get(1, 2); + final byte f22 = matrix1.get(2, 2); + final byte f32 = matrix1.get(3, 2); + final byte f42 = matrix1.get(4, 2); + final byte f03 = matrix1.get(0, 3); + final byte f13 = matrix1.get(1, 3); + final byte f23 = matrix1.get(2, 3); + final byte f33 = matrix1.get(3, 3); + final byte f43 = matrix1.get(4, 3); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s02 = matrix2.get(0, 2); + final byte s12 = matrix2.get(1, 2); + final byte s03 = matrix2.get(0, 3); + final byte s13 = matrix2.get(1, 3); + final byte s04 = matrix2.get(0, 4); + final byte s14 = matrix2.get(1, 4); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04)); + output.set(1, 1, (byte) (f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14)); + output.set(0, 2, (byte) (f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04)); + output.set(1, 2, (byte) (f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14)); + output.set(0, 3, (byte) (f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03 + f43 * s04)); + output.set(1, 3, (byte) (f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13 + f43 * s14)); return output; } private static IMatrixSetterByte multiplyMatrix4x5x3(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final byte f_c00 = matrix1.get(0, 0); - final byte f_c10 = matrix1.get(1, 0); - final byte f_c20 = matrix1.get(2, 0); - final byte f_c30 = matrix1.get(3, 0); - final byte f_c40 = matrix1.get(4, 0); - final byte f_c01 = matrix1.get(0, 1); - final byte f_c11 = matrix1.get(1, 1); - final byte f_c21 = matrix1.get(2, 1); - final byte f_c31 = matrix1.get(3, 1); - final byte f_c41 = matrix1.get(4, 1); - final byte f_c02 = matrix1.get(0, 2); - final byte f_c12 = matrix1.get(1, 2); - final byte f_c22 = matrix1.get(2, 2); - final byte f_c32 = matrix1.get(3, 2); - final byte f_c42 = matrix1.get(4, 2); - final byte f_c03 = matrix1.get(0, 3); - final byte f_c13 = matrix1.get(1, 3); - final byte f_c23 = matrix1.get(2, 3); - final byte f_c33 = matrix1.get(3, 3); - final byte f_c43 = matrix1.get(4, 3); - final byte s_c00 = matrix2.get(0, 0); - final byte s_c10 = matrix2.get(1, 0); - final byte s_c20 = matrix2.get(2, 0); - final byte s_c01 = matrix2.get(0, 1); - final byte s_c11 = matrix2.get(1, 1); - final byte s_c21 = matrix2.get(2, 1); - final byte s_c02 = matrix2.get(0, 2); - final byte s_c12 = matrix2.get(1, 2); - final byte s_c22 = matrix2.get(2, 2); - final byte s_c03 = matrix2.get(0, 3); - final byte s_c13 = matrix2.get(1, 3); - final byte s_c23 = matrix2.get(2, 3); - final byte s_c04 = matrix2.get(0, 4); - final byte s_c14 = matrix2.get(1, 4); - final byte s_c24 = matrix2.get(2, 4); - output.set(0, 0, (byte) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04)); - output.set(0, 1, (byte) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04)); - output.set(0, 2, (byte) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04)); - output.set(0, 3, (byte) (f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03 + f_c43*s_c04)); - output.set(1, 0, (byte) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14)); - output.set(1, 1, (byte) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14)); - output.set(1, 2, (byte) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14)); - output.set(1, 3, (byte) (f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13 + f_c43*s_c14)); - output.set(2, 0, (byte) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24)); - output.set(2, 1, (byte) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24)); - output.set(2, 2, (byte) (f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23 + f_c42*s_c24)); - output.set(2, 3, (byte) (f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23 + f_c43*s_c24)); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte f30 = matrix1.get(3, 0); + final byte f40 = matrix1.get(4, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f21 = matrix1.get(2, 1); + final byte f31 = matrix1.get(3, 1); + final byte f41 = matrix1.get(4, 1); + final byte f02 = matrix1.get(0, 2); + final byte f12 = matrix1.get(1, 2); + final byte f22 = matrix1.get(2, 2); + final byte f32 = matrix1.get(3, 2); + final byte f42 = matrix1.get(4, 2); + final byte f03 = matrix1.get(0, 3); + final byte f13 = matrix1.get(1, 3); + final byte f23 = matrix1.get(2, 3); + final byte f33 = matrix1.get(3, 3); + final byte f43 = matrix1.get(4, 3); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s21 = matrix2.get(2, 1); + final byte s02 = matrix2.get(0, 2); + final byte s12 = matrix2.get(1, 2); + final byte s22 = matrix2.get(2, 2); + final byte s03 = matrix2.get(0, 3); + final byte s13 = matrix2.get(1, 3); + final byte s23 = matrix2.get(2, 3); + final byte s04 = matrix2.get(0, 4); + final byte s14 = matrix2.get(1, 4); + final byte s24 = matrix2.get(2, 4); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14)); + output.set(2, 0, (byte) (f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04)); + output.set(1, 1, (byte) (f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14)); + output.set(2, 1, (byte) (f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24)); + output.set(0, 2, (byte) (f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04)); + output.set(1, 2, (byte) (f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14)); + output.set(2, 2, (byte) (f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23 + f42 * s24)); + output.set(0, 3, (byte) (f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03 + f43 * s04)); + output.set(1, 3, (byte) (f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13 + f43 * s14)); + output.set(2, 3, (byte) (f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23 + f43 * s24)); return output; } private static IMatrixSetterByte multiplyMatrix4x5x4(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final byte f_c00 = matrix1.get(0, 0); - final byte f_c10 = matrix1.get(1, 0); - final byte f_c20 = matrix1.get(2, 0); - final byte f_c30 = matrix1.get(3, 0); - final byte f_c40 = matrix1.get(4, 0); - final byte f_c01 = matrix1.get(0, 1); - final byte f_c11 = matrix1.get(1, 1); - final byte f_c21 = matrix1.get(2, 1); - final byte f_c31 = matrix1.get(3, 1); - final byte f_c41 = matrix1.get(4, 1); - final byte f_c02 = matrix1.get(0, 2); - final byte f_c12 = matrix1.get(1, 2); - final byte f_c22 = matrix1.get(2, 2); - final byte f_c32 = matrix1.get(3, 2); - final byte f_c42 = matrix1.get(4, 2); - final byte f_c03 = matrix1.get(0, 3); - final byte f_c13 = matrix1.get(1, 3); - final byte f_c23 = matrix1.get(2, 3); - final byte f_c33 = matrix1.get(3, 3); - final byte f_c43 = matrix1.get(4, 3); - final byte s_c00 = matrix2.get(0, 0); - final byte s_c10 = matrix2.get(1, 0); - final byte s_c20 = matrix2.get(2, 0); - final byte s_c30 = matrix2.get(3, 0); - final byte s_c01 = matrix2.get(0, 1); - final byte s_c11 = matrix2.get(1, 1); - final byte s_c21 = matrix2.get(2, 1); - final byte s_c31 = matrix2.get(3, 1); - final byte s_c02 = matrix2.get(0, 2); - final byte s_c12 = matrix2.get(1, 2); - final byte s_c22 = matrix2.get(2, 2); - final byte s_c32 = matrix2.get(3, 2); - final byte s_c03 = matrix2.get(0, 3); - final byte s_c13 = matrix2.get(1, 3); - final byte s_c23 = matrix2.get(2, 3); - final byte s_c33 = matrix2.get(3, 3); - final byte s_c04 = matrix2.get(0, 4); - final byte s_c14 = matrix2.get(1, 4); - final byte s_c24 = matrix2.get(2, 4); - final byte s_c34 = matrix2.get(3, 4); - output.set(0, 0, (byte) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04)); - output.set(0, 1, (byte) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04)); - output.set(0, 2, (byte) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04)); - output.set(0, 3, (byte) (f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03 + f_c43*s_c04)); - output.set(1, 0, (byte) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14)); - output.set(1, 1, (byte) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14)); - output.set(1, 2, (byte) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14)); - output.set(1, 3, (byte) (f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13 + f_c43*s_c14)); - output.set(2, 0, (byte) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24)); - output.set(2, 1, (byte) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24)); - output.set(2, 2, (byte) (f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23 + f_c42*s_c24)); - output.set(2, 3, (byte) (f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23 + f_c43*s_c24)); - output.set(3, 0, (byte) (f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33 + f_c40*s_c34)); - output.set(3, 1, (byte) (f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33 + f_c41*s_c34)); - output.set(3, 2, (byte) (f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33 + f_c42*s_c34)); - output.set(3, 3, (byte) (f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32 + f_c33*s_c33 + f_c43*s_c34)); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte f30 = matrix1.get(3, 0); + final byte f40 = matrix1.get(4, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f21 = matrix1.get(2, 1); + final byte f31 = matrix1.get(3, 1); + final byte f41 = matrix1.get(4, 1); + final byte f02 = matrix1.get(0, 2); + final byte f12 = matrix1.get(1, 2); + final byte f22 = matrix1.get(2, 2); + final byte f32 = matrix1.get(3, 2); + final byte f42 = matrix1.get(4, 2); + final byte f03 = matrix1.get(0, 3); + final byte f13 = matrix1.get(1, 3); + final byte f23 = matrix1.get(2, 3); + final byte f33 = matrix1.get(3, 3); + final byte f43 = matrix1.get(4, 3); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + final byte s30 = matrix2.get(3, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s21 = matrix2.get(2, 1); + final byte s31 = matrix2.get(3, 1); + final byte s02 = matrix2.get(0, 2); + final byte s12 = matrix2.get(1, 2); + final byte s22 = matrix2.get(2, 2); + final byte s32 = matrix2.get(3, 2); + final byte s03 = matrix2.get(0, 3); + final byte s13 = matrix2.get(1, 3); + final byte s23 = matrix2.get(2, 3); + final byte s33 = matrix2.get(3, 3); + final byte s04 = matrix2.get(0, 4); + final byte s14 = matrix2.get(1, 4); + final byte s24 = matrix2.get(2, 4); + final byte s34 = matrix2.get(3, 4); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14)); + output.set(2, 0, (byte) (f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24)); + output.set(3, 0, (byte) (f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33 + f40 * s34)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04)); + output.set(1, 1, (byte) (f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14)); + output.set(2, 1, (byte) (f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24)); + output.set(3, 1, (byte) (f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33 + f41 * s34)); + output.set(0, 2, (byte) (f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04)); + output.set(1, 2, (byte) (f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14)); + output.set(2, 2, (byte) (f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23 + f42 * s24)); + output.set(3, 2, (byte) (f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33 + f42 * s34)); + output.set(0, 3, (byte) (f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03 + f43 * s04)); + output.set(1, 3, (byte) (f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13 + f43 * s14)); + output.set(2, 3, (byte) (f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23 + f43 * s24)); + output.set(3, 3, (byte) (f03 * s30 + f13 * s31 + f23 * s32 + f33 * s33 + f43 * s34)); return output; } private static IMatrixSetterByte multiplyMatrix4x5x5(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final byte f_c00 = matrix1.get(0, 0); - final byte f_c10 = matrix1.get(1, 0); - final byte f_c20 = matrix1.get(2, 0); - final byte f_c30 = matrix1.get(3, 0); - final byte f_c40 = matrix1.get(4, 0); - final byte f_c01 = matrix1.get(0, 1); - final byte f_c11 = matrix1.get(1, 1); - final byte f_c21 = matrix1.get(2, 1); - final byte f_c31 = matrix1.get(3, 1); - final byte f_c41 = matrix1.get(4, 1); - final byte f_c02 = matrix1.get(0, 2); - final byte f_c12 = matrix1.get(1, 2); - final byte f_c22 = matrix1.get(2, 2); - final byte f_c32 = matrix1.get(3, 2); - final byte f_c42 = matrix1.get(4, 2); - final byte f_c03 = matrix1.get(0, 3); - final byte f_c13 = matrix1.get(1, 3); - final byte f_c23 = matrix1.get(2, 3); - final byte f_c33 = matrix1.get(3, 3); - final byte f_c43 = matrix1.get(4, 3); - final byte s_c00 = matrix2.get(0, 0); - final byte s_c10 = matrix2.get(1, 0); - final byte s_c20 = matrix2.get(2, 0); - final byte s_c30 = matrix2.get(3, 0); - final byte s_c40 = matrix2.get(4, 0); - final byte s_c01 = matrix2.get(0, 1); - final byte s_c11 = matrix2.get(1, 1); - final byte s_c21 = matrix2.get(2, 1); - final byte s_c31 = matrix2.get(3, 1); - final byte s_c41 = matrix2.get(4, 1); - final byte s_c02 = matrix2.get(0, 2); - final byte s_c12 = matrix2.get(1, 2); - final byte s_c22 = matrix2.get(2, 2); - final byte s_c32 = matrix2.get(3, 2); - final byte s_c42 = matrix2.get(4, 2); - final byte s_c03 = matrix2.get(0, 3); - final byte s_c13 = matrix2.get(1, 3); - final byte s_c23 = matrix2.get(2, 3); - final byte s_c33 = matrix2.get(3, 3); - final byte s_c43 = matrix2.get(4, 3); - final byte s_c04 = matrix2.get(0, 4); - final byte s_c14 = matrix2.get(1, 4); - final byte s_c24 = matrix2.get(2, 4); - final byte s_c34 = matrix2.get(3, 4); - final byte s_c44 = matrix2.get(4, 4); - output.set(0, 0, (byte) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04)); - output.set(0, 1, (byte) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04)); - output.set(0, 2, (byte) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04)); - output.set(0, 3, (byte) (f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03 + f_c43*s_c04)); - output.set(1, 0, (byte) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14)); - output.set(1, 1, (byte) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14)); - output.set(1, 2, (byte) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14)); - output.set(1, 3, (byte) (f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13 + f_c43*s_c14)); - output.set(2, 0, (byte) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24)); - output.set(2, 1, (byte) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24)); - output.set(2, 2, (byte) (f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23 + f_c42*s_c24)); - output.set(2, 3, (byte) (f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23 + f_c43*s_c24)); - output.set(3, 0, (byte) (f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33 + f_c40*s_c34)); - output.set(3, 1, (byte) (f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33 + f_c41*s_c34)); - output.set(3, 2, (byte) (f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33 + f_c42*s_c34)); - output.set(3, 3, (byte) (f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32 + f_c33*s_c33 + f_c43*s_c34)); - output.set(4, 0, (byte) (f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42 + f_c30*s_c43 + f_c40*s_c44)); - output.set(4, 1, (byte) (f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42 + f_c31*s_c43 + f_c41*s_c44)); - output.set(4, 2, (byte) (f_c02*s_c40 + f_c12*s_c41 + f_c22*s_c42 + f_c32*s_c43 + f_c42*s_c44)); - output.set(4, 3, (byte) (f_c03*s_c40 + f_c13*s_c41 + f_c23*s_c42 + f_c33*s_c43 + f_c43*s_c44)); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte f30 = matrix1.get(3, 0); + final byte f40 = matrix1.get(4, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f21 = matrix1.get(2, 1); + final byte f31 = matrix1.get(3, 1); + final byte f41 = matrix1.get(4, 1); + final byte f02 = matrix1.get(0, 2); + final byte f12 = matrix1.get(1, 2); + final byte f22 = matrix1.get(2, 2); + final byte f32 = matrix1.get(3, 2); + final byte f42 = matrix1.get(4, 2); + final byte f03 = matrix1.get(0, 3); + final byte f13 = matrix1.get(1, 3); + final byte f23 = matrix1.get(2, 3); + final byte f33 = matrix1.get(3, 3); + final byte f43 = matrix1.get(4, 3); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + final byte s30 = matrix2.get(3, 0); + final byte s40 = matrix2.get(4, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s21 = matrix2.get(2, 1); + final byte s31 = matrix2.get(3, 1); + final byte s41 = matrix2.get(4, 1); + final byte s02 = matrix2.get(0, 2); + final byte s12 = matrix2.get(1, 2); + final byte s22 = matrix2.get(2, 2); + final byte s32 = matrix2.get(3, 2); + final byte s42 = matrix2.get(4, 2); + final byte s03 = matrix2.get(0, 3); + final byte s13 = matrix2.get(1, 3); + final byte s23 = matrix2.get(2, 3); + final byte s33 = matrix2.get(3, 3); + final byte s43 = matrix2.get(4, 3); + final byte s04 = matrix2.get(0, 4); + final byte s14 = matrix2.get(1, 4); + final byte s24 = matrix2.get(2, 4); + final byte s34 = matrix2.get(3, 4); + final byte s44 = matrix2.get(4, 4); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14)); + output.set(2, 0, (byte) (f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24)); + output.set(3, 0, (byte) (f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33 + f40 * s34)); + output.set(4, 0, (byte) (f00 * s40 + f10 * s41 + f20 * s42 + f30 * s43 + f40 * s44)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04)); + output.set(1, 1, (byte) (f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14)); + output.set(2, 1, (byte) (f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24)); + output.set(3, 1, (byte) (f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33 + f41 * s34)); + output.set(4, 1, (byte) (f01 * s40 + f11 * s41 + f21 * s42 + f31 * s43 + f41 * s44)); + output.set(0, 2, (byte) (f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04)); + output.set(1, 2, (byte) (f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14)); + output.set(2, 2, (byte) (f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23 + f42 * s24)); + output.set(3, 2, (byte) (f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33 + f42 * s34)); + output.set(4, 2, (byte) (f02 * s40 + f12 * s41 + f22 * s42 + f32 * s43 + f42 * s44)); + output.set(0, 3, (byte) (f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03 + f43 * s04)); + output.set(1, 3, (byte) (f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13 + f43 * s14)); + output.set(2, 3, (byte) (f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23 + f43 * s24)); + output.set(3, 3, (byte) (f03 * s30 + f13 * s31 + f23 * s32 + f33 * s33 + f43 * s34)); + output.set(4, 3, (byte) (f03 * s40 + f13 * s41 + f23 * s42 + f33 * s43 + f43 * s44)); + return output; + } + + private static IMatrixSetterByte multiplyMatrix5x5x1(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte f30 = matrix1.get(3, 0); + final byte f40 = matrix1.get(4, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f21 = matrix1.get(2, 1); + final byte f31 = matrix1.get(3, 1); + final byte f41 = matrix1.get(4, 1); + final byte f02 = matrix1.get(0, 2); + final byte f12 = matrix1.get(1, 2); + final byte f22 = matrix1.get(2, 2); + final byte f32 = matrix1.get(3, 2); + final byte f42 = matrix1.get(4, 2); + final byte f03 = matrix1.get(0, 3); + final byte f13 = matrix1.get(1, 3); + final byte f23 = matrix1.get(2, 3); + final byte f33 = matrix1.get(3, 3); + final byte f43 = matrix1.get(4, 3); + final byte f04 = matrix1.get(0, 4); + final byte f14 = matrix1.get(1, 4); + final byte f24 = matrix1.get(2, 4); + final byte f34 = matrix1.get(3, 4); + final byte f44 = matrix1.get(4, 4); + final byte s00 = matrix2.get(0, 0); + final byte s01 = matrix2.get(0, 1); + final byte s02 = matrix2.get(0, 2); + final byte s03 = matrix2.get(0, 3); + final byte s04 = matrix2.get(0, 4); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04)); + output.set(0, 2, (byte) (f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04)); + output.set(0, 3, (byte) (f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03 + f43 * s04)); + output.set(0, 4, (byte) (f04 * s00 + f14 * s01 + f24 * s02 + f34 * s03 + f44 * s04)); return output; } private static IMatrixSetterByte multiplyMatrix5x5x2(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final byte f_c00 = matrix1.get(0, 0); - final byte f_c10 = matrix1.get(1, 0); - final byte f_c20 = matrix1.get(2, 0); - final byte f_c30 = matrix1.get(3, 0); - final byte f_c40 = matrix1.get(4, 0); - final byte f_c01 = matrix1.get(0, 1); - final byte f_c11 = matrix1.get(1, 1); - final byte f_c21 = matrix1.get(2, 1); - final byte f_c31 = matrix1.get(3, 1); - final byte f_c41 = matrix1.get(4, 1); - final byte f_c02 = matrix1.get(0, 2); - final byte f_c12 = matrix1.get(1, 2); - final byte f_c22 = matrix1.get(2, 2); - final byte f_c32 = matrix1.get(3, 2); - final byte f_c42 = matrix1.get(4, 2); - final byte f_c03 = matrix1.get(0, 3); - final byte f_c13 = matrix1.get(1, 3); - final byte f_c23 = matrix1.get(2, 3); - final byte f_c33 = matrix1.get(3, 3); - final byte f_c43 = matrix1.get(4, 3); - final byte f_c04 = matrix1.get(0, 4); - final byte f_c14 = matrix1.get(1, 4); - final byte f_c24 = matrix1.get(2, 4); - final byte f_c34 = matrix1.get(3, 4); - final byte f_c44 = matrix1.get(4, 4); - final byte s_c00 = matrix2.get(0, 0); - final byte s_c10 = matrix2.get(1, 0); - final byte s_c01 = matrix2.get(0, 1); - final byte s_c11 = matrix2.get(1, 1); - final byte s_c02 = matrix2.get(0, 2); - final byte s_c12 = matrix2.get(1, 2); - final byte s_c03 = matrix2.get(0, 3); - final byte s_c13 = matrix2.get(1, 3); - final byte s_c04 = matrix2.get(0, 4); - final byte s_c14 = matrix2.get(1, 4); - output.set(0, 0, (byte) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04)); - output.set(0, 1, (byte) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04)); - output.set(0, 2, (byte) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04)); - output.set(0, 3, (byte) (f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03 + f_c43*s_c04)); - output.set(0, 4, (byte) (f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02 + f_c34*s_c03 + f_c44*s_c04)); - output.set(1, 0, (byte) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14)); - output.set(1, 1, (byte) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14)); - output.set(1, 2, (byte) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14)); - output.set(1, 3, (byte) (f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13 + f_c43*s_c14)); - output.set(1, 4, (byte) (f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12 + f_c34*s_c13 + f_c44*s_c14)); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte f30 = matrix1.get(3, 0); + final byte f40 = matrix1.get(4, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f21 = matrix1.get(2, 1); + final byte f31 = matrix1.get(3, 1); + final byte f41 = matrix1.get(4, 1); + final byte f02 = matrix1.get(0, 2); + final byte f12 = matrix1.get(1, 2); + final byte f22 = matrix1.get(2, 2); + final byte f32 = matrix1.get(3, 2); + final byte f42 = matrix1.get(4, 2); + final byte f03 = matrix1.get(0, 3); + final byte f13 = matrix1.get(1, 3); + final byte f23 = matrix1.get(2, 3); + final byte f33 = matrix1.get(3, 3); + final byte f43 = matrix1.get(4, 3); + final byte f04 = matrix1.get(0, 4); + final byte f14 = matrix1.get(1, 4); + final byte f24 = matrix1.get(2, 4); + final byte f34 = matrix1.get(3, 4); + final byte f44 = matrix1.get(4, 4); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s02 = matrix2.get(0, 2); + final byte s12 = matrix2.get(1, 2); + final byte s03 = matrix2.get(0, 3); + final byte s13 = matrix2.get(1, 3); + final byte s04 = matrix2.get(0, 4); + final byte s14 = matrix2.get(1, 4); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04)); + output.set(1, 1, (byte) (f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14)); + output.set(0, 2, (byte) (f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04)); + output.set(1, 2, (byte) (f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14)); + output.set(0, 3, (byte) (f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03 + f43 * s04)); + output.set(1, 3, (byte) (f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13 + f43 * s14)); + output.set(0, 4, (byte) (f04 * s00 + f14 * s01 + f24 * s02 + f34 * s03 + f44 * s04)); + output.set(1, 4, (byte) (f04 * s10 + f14 * s11 + f24 * s12 + f34 * s13 + f44 * s14)); return output; } private static IMatrixSetterByte multiplyMatrix5x5x3(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final byte f_c00 = matrix1.get(0, 0); - final byte f_c10 = matrix1.get(1, 0); - final byte f_c20 = matrix1.get(2, 0); - final byte f_c30 = matrix1.get(3, 0); - final byte f_c40 = matrix1.get(4, 0); - final byte f_c01 = matrix1.get(0, 1); - final byte f_c11 = matrix1.get(1, 1); - final byte f_c21 = matrix1.get(2, 1); - final byte f_c31 = matrix1.get(3, 1); - final byte f_c41 = matrix1.get(4, 1); - final byte f_c02 = matrix1.get(0, 2); - final byte f_c12 = matrix1.get(1, 2); - final byte f_c22 = matrix1.get(2, 2); - final byte f_c32 = matrix1.get(3, 2); - final byte f_c42 = matrix1.get(4, 2); - final byte f_c03 = matrix1.get(0, 3); - final byte f_c13 = matrix1.get(1, 3); - final byte f_c23 = matrix1.get(2, 3); - final byte f_c33 = matrix1.get(3, 3); - final byte f_c43 = matrix1.get(4, 3); - final byte f_c04 = matrix1.get(0, 4); - final byte f_c14 = matrix1.get(1, 4); - final byte f_c24 = matrix1.get(2, 4); - final byte f_c34 = matrix1.get(3, 4); - final byte f_c44 = matrix1.get(4, 4); - final byte s_c00 = matrix2.get(0, 0); - final byte s_c10 = matrix2.get(1, 0); - final byte s_c20 = matrix2.get(2, 0); - final byte s_c01 = matrix2.get(0, 1); - final byte s_c11 = matrix2.get(1, 1); - final byte s_c21 = matrix2.get(2, 1); - final byte s_c02 = matrix2.get(0, 2); - final byte s_c12 = matrix2.get(1, 2); - final byte s_c22 = matrix2.get(2, 2); - final byte s_c03 = matrix2.get(0, 3); - final byte s_c13 = matrix2.get(1, 3); - final byte s_c23 = matrix2.get(2, 3); - final byte s_c04 = matrix2.get(0, 4); - final byte s_c14 = matrix2.get(1, 4); - final byte s_c24 = matrix2.get(2, 4); - output.set(0, 0, (byte) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04)); - output.set(0, 1, (byte) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04)); - output.set(0, 2, (byte) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04)); - output.set(0, 3, (byte) (f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03 + f_c43*s_c04)); - output.set(0, 4, (byte) (f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02 + f_c34*s_c03 + f_c44*s_c04)); - output.set(1, 0, (byte) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14)); - output.set(1, 1, (byte) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14)); - output.set(1, 2, (byte) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14)); - output.set(1, 3, (byte) (f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13 + f_c43*s_c14)); - output.set(1, 4, (byte) (f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12 + f_c34*s_c13 + f_c44*s_c14)); - output.set(2, 0, (byte) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24)); - output.set(2, 1, (byte) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24)); - output.set(2, 2, (byte) (f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23 + f_c42*s_c24)); - output.set(2, 3, (byte) (f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23 + f_c43*s_c24)); - output.set(2, 4, (byte) (f_c04*s_c20 + f_c14*s_c21 + f_c24*s_c22 + f_c34*s_c23 + f_c44*s_c24)); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte f30 = matrix1.get(3, 0); + final byte f40 = matrix1.get(4, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f21 = matrix1.get(2, 1); + final byte f31 = matrix1.get(3, 1); + final byte f41 = matrix1.get(4, 1); + final byte f02 = matrix1.get(0, 2); + final byte f12 = matrix1.get(1, 2); + final byte f22 = matrix1.get(2, 2); + final byte f32 = matrix1.get(3, 2); + final byte f42 = matrix1.get(4, 2); + final byte f03 = matrix1.get(0, 3); + final byte f13 = matrix1.get(1, 3); + final byte f23 = matrix1.get(2, 3); + final byte f33 = matrix1.get(3, 3); + final byte f43 = matrix1.get(4, 3); + final byte f04 = matrix1.get(0, 4); + final byte f14 = matrix1.get(1, 4); + final byte f24 = matrix1.get(2, 4); + final byte f34 = matrix1.get(3, 4); + final byte f44 = matrix1.get(4, 4); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s21 = matrix2.get(2, 1); + final byte s02 = matrix2.get(0, 2); + final byte s12 = matrix2.get(1, 2); + final byte s22 = matrix2.get(2, 2); + final byte s03 = matrix2.get(0, 3); + final byte s13 = matrix2.get(1, 3); + final byte s23 = matrix2.get(2, 3); + final byte s04 = matrix2.get(0, 4); + final byte s14 = matrix2.get(1, 4); + final byte s24 = matrix2.get(2, 4); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14)); + output.set(2, 0, (byte) (f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04)); + output.set(1, 1, (byte) (f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14)); + output.set(2, 1, (byte) (f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24)); + output.set(0, 2, (byte) (f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04)); + output.set(1, 2, (byte) (f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14)); + output.set(2, 2, (byte) (f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23 + f42 * s24)); + output.set(0, 3, (byte) (f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03 + f43 * s04)); + output.set(1, 3, (byte) (f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13 + f43 * s14)); + output.set(2, 3, (byte) (f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23 + f43 * s24)); + output.set(0, 4, (byte) (f04 * s00 + f14 * s01 + f24 * s02 + f34 * s03 + f44 * s04)); + output.set(1, 4, (byte) (f04 * s10 + f14 * s11 + f24 * s12 + f34 * s13 + f44 * s14)); + output.set(2, 4, (byte) (f04 * s20 + f14 * s21 + f24 * s22 + f34 * s23 + f44 * s24)); return output; } private static IMatrixSetterByte multiplyMatrix5x5x4(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final byte f_c00 = matrix1.get(0, 0); - final byte f_c10 = matrix1.get(1, 0); - final byte f_c20 = matrix1.get(2, 0); - final byte f_c30 = matrix1.get(3, 0); - final byte f_c40 = matrix1.get(4, 0); - final byte f_c01 = matrix1.get(0, 1); - final byte f_c11 = matrix1.get(1, 1); - final byte f_c21 = matrix1.get(2, 1); - final byte f_c31 = matrix1.get(3, 1); - final byte f_c41 = matrix1.get(4, 1); - final byte f_c02 = matrix1.get(0, 2); - final byte f_c12 = matrix1.get(1, 2); - final byte f_c22 = matrix1.get(2, 2); - final byte f_c32 = matrix1.get(3, 2); - final byte f_c42 = matrix1.get(4, 2); - final byte f_c03 = matrix1.get(0, 3); - final byte f_c13 = matrix1.get(1, 3); - final byte f_c23 = matrix1.get(2, 3); - final byte f_c33 = matrix1.get(3, 3); - final byte f_c43 = matrix1.get(4, 3); - final byte f_c04 = matrix1.get(0, 4); - final byte f_c14 = matrix1.get(1, 4); - final byte f_c24 = matrix1.get(2, 4); - final byte f_c34 = matrix1.get(3, 4); - final byte f_c44 = matrix1.get(4, 4); - final byte s_c00 = matrix2.get(0, 0); - final byte s_c10 = matrix2.get(1, 0); - final byte s_c20 = matrix2.get(2, 0); - final byte s_c30 = matrix2.get(3, 0); - final byte s_c01 = matrix2.get(0, 1); - final byte s_c11 = matrix2.get(1, 1); - final byte s_c21 = matrix2.get(2, 1); - final byte s_c31 = matrix2.get(3, 1); - final byte s_c02 = matrix2.get(0, 2); - final byte s_c12 = matrix2.get(1, 2); - final byte s_c22 = matrix2.get(2, 2); - final byte s_c32 = matrix2.get(3, 2); - final byte s_c03 = matrix2.get(0, 3); - final byte s_c13 = matrix2.get(1, 3); - final byte s_c23 = matrix2.get(2, 3); - final byte s_c33 = matrix2.get(3, 3); - final byte s_c04 = matrix2.get(0, 4); - final byte s_c14 = matrix2.get(1, 4); - final byte s_c24 = matrix2.get(2, 4); - final byte s_c34 = matrix2.get(3, 4); - output.set(0, 0, (byte) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04)); - output.set(0, 1, (byte) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04)); - output.set(0, 2, (byte) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04)); - output.set(0, 3, (byte) (f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03 + f_c43*s_c04)); - output.set(0, 4, (byte) (f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02 + f_c34*s_c03 + f_c44*s_c04)); - output.set(1, 0, (byte) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14)); - output.set(1, 1, (byte) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14)); - output.set(1, 2, (byte) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14)); - output.set(1, 3, (byte) (f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13 + f_c43*s_c14)); - output.set(1, 4, (byte) (f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12 + f_c34*s_c13 + f_c44*s_c14)); - output.set(2, 0, (byte) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24)); - output.set(2, 1, (byte) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24)); - output.set(2, 2, (byte) (f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23 + f_c42*s_c24)); - output.set(2, 3, (byte) (f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23 + f_c43*s_c24)); - output.set(2, 4, (byte) (f_c04*s_c20 + f_c14*s_c21 + f_c24*s_c22 + f_c34*s_c23 + f_c44*s_c24)); - output.set(3, 0, (byte) (f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33 + f_c40*s_c34)); - output.set(3, 1, (byte) (f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33 + f_c41*s_c34)); - output.set(3, 2, (byte) (f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33 + f_c42*s_c34)); - output.set(3, 3, (byte) (f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32 + f_c33*s_c33 + f_c43*s_c34)); - output.set(3, 4, (byte) (f_c04*s_c30 + f_c14*s_c31 + f_c24*s_c32 + f_c34*s_c33 + f_c44*s_c34)); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte f30 = matrix1.get(3, 0); + final byte f40 = matrix1.get(4, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f21 = matrix1.get(2, 1); + final byte f31 = matrix1.get(3, 1); + final byte f41 = matrix1.get(4, 1); + final byte f02 = matrix1.get(0, 2); + final byte f12 = matrix1.get(1, 2); + final byte f22 = matrix1.get(2, 2); + final byte f32 = matrix1.get(3, 2); + final byte f42 = matrix1.get(4, 2); + final byte f03 = matrix1.get(0, 3); + final byte f13 = matrix1.get(1, 3); + final byte f23 = matrix1.get(2, 3); + final byte f33 = matrix1.get(3, 3); + final byte f43 = matrix1.get(4, 3); + final byte f04 = matrix1.get(0, 4); + final byte f14 = matrix1.get(1, 4); + final byte f24 = matrix1.get(2, 4); + final byte f34 = matrix1.get(3, 4); + final byte f44 = matrix1.get(4, 4); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + final byte s30 = matrix2.get(3, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s21 = matrix2.get(2, 1); + final byte s31 = matrix2.get(3, 1); + final byte s02 = matrix2.get(0, 2); + final byte s12 = matrix2.get(1, 2); + final byte s22 = matrix2.get(2, 2); + final byte s32 = matrix2.get(3, 2); + final byte s03 = matrix2.get(0, 3); + final byte s13 = matrix2.get(1, 3); + final byte s23 = matrix2.get(2, 3); + final byte s33 = matrix2.get(3, 3); + final byte s04 = matrix2.get(0, 4); + final byte s14 = matrix2.get(1, 4); + final byte s24 = matrix2.get(2, 4); + final byte s34 = matrix2.get(3, 4); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14)); + output.set(2, 0, (byte) (f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24)); + output.set(3, 0, (byte) (f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33 + f40 * s34)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04)); + output.set(1, 1, (byte) (f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14)); + output.set(2, 1, (byte) (f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24)); + output.set(3, 1, (byte) (f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33 + f41 * s34)); + output.set(0, 2, (byte) (f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04)); + output.set(1, 2, (byte) (f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14)); + output.set(2, 2, (byte) (f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23 + f42 * s24)); + output.set(3, 2, (byte) (f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33 + f42 * s34)); + output.set(0, 3, (byte) (f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03 + f43 * s04)); + output.set(1, 3, (byte) (f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13 + f43 * s14)); + output.set(2, 3, (byte) (f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23 + f43 * s24)); + output.set(3, 3, (byte) (f03 * s30 + f13 * s31 + f23 * s32 + f33 * s33 + f43 * s34)); + output.set(0, 4, (byte) (f04 * s00 + f14 * s01 + f24 * s02 + f34 * s03 + f44 * s04)); + output.set(1, 4, (byte) (f04 * s10 + f14 * s11 + f24 * s12 + f34 * s13 + f44 * s14)); + output.set(2, 4, (byte) (f04 * s20 + f14 * s21 + f24 * s22 + f34 * s23 + f44 * s24)); + output.set(3, 4, (byte) (f04 * s30 + f14 * s31 + f24 * s32 + f34 * s33 + f44 * s34)); return output; } private static IMatrixSetterByte multiplyMatrix5x5x5(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final byte f_c00 = matrix1.get(0, 0); - final byte f_c10 = matrix1.get(1, 0); - final byte f_c20 = matrix1.get(2, 0); - final byte f_c30 = matrix1.get(3, 0); - final byte f_c40 = matrix1.get(4, 0); - final byte f_c01 = matrix1.get(0, 1); - final byte f_c11 = matrix1.get(1, 1); - final byte f_c21 = matrix1.get(2, 1); - final byte f_c31 = matrix1.get(3, 1); - final byte f_c41 = matrix1.get(4, 1); - final byte f_c02 = matrix1.get(0, 2); - final byte f_c12 = matrix1.get(1, 2); - final byte f_c22 = matrix1.get(2, 2); - final byte f_c32 = matrix1.get(3, 2); - final byte f_c42 = matrix1.get(4, 2); - final byte f_c03 = matrix1.get(0, 3); - final byte f_c13 = matrix1.get(1, 3); - final byte f_c23 = matrix1.get(2, 3); - final byte f_c33 = matrix1.get(3, 3); - final byte f_c43 = matrix1.get(4, 3); - final byte f_c04 = matrix1.get(0, 4); - final byte f_c14 = matrix1.get(1, 4); - final byte f_c24 = matrix1.get(2, 4); - final byte f_c34 = matrix1.get(3, 4); - final byte f_c44 = matrix1.get(4, 4); - final byte s_c00 = matrix2.get(0, 0); - final byte s_c10 = matrix2.get(1, 0); - final byte s_c20 = matrix2.get(2, 0); - final byte s_c30 = matrix2.get(3, 0); - final byte s_c40 = matrix2.get(4, 0); - final byte s_c01 = matrix2.get(0, 1); - final byte s_c11 = matrix2.get(1, 1); - final byte s_c21 = matrix2.get(2, 1); - final byte s_c31 = matrix2.get(3, 1); - final byte s_c41 = matrix2.get(4, 1); - final byte s_c02 = matrix2.get(0, 2); - final byte s_c12 = matrix2.get(1, 2); - final byte s_c22 = matrix2.get(2, 2); - final byte s_c32 = matrix2.get(3, 2); - final byte s_c42 = matrix2.get(4, 2); - final byte s_c03 = matrix2.get(0, 3); - final byte s_c13 = matrix2.get(1, 3); - final byte s_c23 = matrix2.get(2, 3); - final byte s_c33 = matrix2.get(3, 3); - final byte s_c43 = matrix2.get(4, 3); - final byte s_c04 = matrix2.get(0, 4); - final byte s_c14 = matrix2.get(1, 4); - final byte s_c24 = matrix2.get(2, 4); - final byte s_c34 = matrix2.get(3, 4); - final byte s_c44 = matrix2.get(4, 4); - output.set(0, 0, (byte) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04)); - output.set(0, 1, (byte) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04)); - output.set(0, 2, (byte) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04)); - output.set(0, 3, (byte) (f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03 + f_c43*s_c04)); - output.set(0, 4, (byte) (f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02 + f_c34*s_c03 + f_c44*s_c04)); - output.set(1, 0, (byte) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14)); - output.set(1, 1, (byte) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14)); - output.set(1, 2, (byte) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14)); - output.set(1, 3, (byte) (f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13 + f_c43*s_c14)); - output.set(1, 4, (byte) (f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12 + f_c34*s_c13 + f_c44*s_c14)); - output.set(2, 0, (byte) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24)); - output.set(2, 1, (byte) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24)); - output.set(2, 2, (byte) (f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23 + f_c42*s_c24)); - output.set(2, 3, (byte) (f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23 + f_c43*s_c24)); - output.set(2, 4, (byte) (f_c04*s_c20 + f_c14*s_c21 + f_c24*s_c22 + f_c34*s_c23 + f_c44*s_c24)); - output.set(3, 0, (byte) (f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33 + f_c40*s_c34)); - output.set(3, 1, (byte) (f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33 + f_c41*s_c34)); - output.set(3, 2, (byte) (f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33 + f_c42*s_c34)); - output.set(3, 3, (byte) (f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32 + f_c33*s_c33 + f_c43*s_c34)); - output.set(3, 4, (byte) (f_c04*s_c30 + f_c14*s_c31 + f_c24*s_c32 + f_c34*s_c33 + f_c44*s_c34)); - output.set(4, 0, (byte) (f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42 + f_c30*s_c43 + f_c40*s_c44)); - output.set(4, 1, (byte) (f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42 + f_c31*s_c43 + f_c41*s_c44)); - output.set(4, 2, (byte) (f_c02*s_c40 + f_c12*s_c41 + f_c22*s_c42 + f_c32*s_c43 + f_c42*s_c44)); - output.set(4, 3, (byte) (f_c03*s_c40 + f_c13*s_c41 + f_c23*s_c42 + f_c33*s_c43 + f_c43*s_c44)); - output.set(4, 4, (byte) (f_c04*s_c40 + f_c14*s_c41 + f_c24*s_c42 + f_c34*s_c43 + f_c44*s_c44)); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final byte f00 = matrix1.get(0, 0); + final byte f10 = matrix1.get(1, 0); + final byte f20 = matrix1.get(2, 0); + final byte f30 = matrix1.get(3, 0); + final byte f40 = matrix1.get(4, 0); + final byte f01 = matrix1.get(0, 1); + final byte f11 = matrix1.get(1, 1); + final byte f21 = matrix1.get(2, 1); + final byte f31 = matrix1.get(3, 1); + final byte f41 = matrix1.get(4, 1); + final byte f02 = matrix1.get(0, 2); + final byte f12 = matrix1.get(1, 2); + final byte f22 = matrix1.get(2, 2); + final byte f32 = matrix1.get(3, 2); + final byte f42 = matrix1.get(4, 2); + final byte f03 = matrix1.get(0, 3); + final byte f13 = matrix1.get(1, 3); + final byte f23 = matrix1.get(2, 3); + final byte f33 = matrix1.get(3, 3); + final byte f43 = matrix1.get(4, 3); + final byte f04 = matrix1.get(0, 4); + final byte f14 = matrix1.get(1, 4); + final byte f24 = matrix1.get(2, 4); + final byte f34 = matrix1.get(3, 4); + final byte f44 = matrix1.get(4, 4); + final byte s00 = matrix2.get(0, 0); + final byte s10 = matrix2.get(1, 0); + final byte s20 = matrix2.get(2, 0); + final byte s30 = matrix2.get(3, 0); + final byte s40 = matrix2.get(4, 0); + final byte s01 = matrix2.get(0, 1); + final byte s11 = matrix2.get(1, 1); + final byte s21 = matrix2.get(2, 1); + final byte s31 = matrix2.get(3, 1); + final byte s41 = matrix2.get(4, 1); + final byte s02 = matrix2.get(0, 2); + final byte s12 = matrix2.get(1, 2); + final byte s22 = matrix2.get(2, 2); + final byte s32 = matrix2.get(3, 2); + final byte s42 = matrix2.get(4, 2); + final byte s03 = matrix2.get(0, 3); + final byte s13 = matrix2.get(1, 3); + final byte s23 = matrix2.get(2, 3); + final byte s33 = matrix2.get(3, 3); + final byte s43 = matrix2.get(4, 3); + final byte s04 = matrix2.get(0, 4); + final byte s14 = matrix2.get(1, 4); + final byte s24 = matrix2.get(2, 4); + final byte s34 = matrix2.get(3, 4); + final byte s44 = matrix2.get(4, 4); + output.set(0, 0, (byte) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04)); + output.set(1, 0, (byte) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14)); + output.set(2, 0, (byte) (f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24)); + output.set(3, 0, (byte) (f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33 + f40 * s34)); + output.set(4, 0, (byte) (f00 * s40 + f10 * s41 + f20 * s42 + f30 * s43 + f40 * s44)); + output.set(0, 1, (byte) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04)); + output.set(1, 1, (byte) (f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14)); + output.set(2, 1, (byte) (f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24)); + output.set(3, 1, (byte) (f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33 + f41 * s34)); + output.set(4, 1, (byte) (f01 * s40 + f11 * s41 + f21 * s42 + f31 * s43 + f41 * s44)); + output.set(0, 2, (byte) (f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04)); + output.set(1, 2, (byte) (f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14)); + output.set(2, 2, (byte) (f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23 + f42 * s24)); + output.set(3, 2, (byte) (f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33 + f42 * s34)); + output.set(4, 2, (byte) (f02 * s40 + f12 * s41 + f22 * s42 + f32 * s43 + f42 * s44)); + output.set(0, 3, (byte) (f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03 + f43 * s04)); + output.set(1, 3, (byte) (f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13 + f43 * s14)); + output.set(2, 3, (byte) (f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23 + f43 * s24)); + output.set(3, 3, (byte) (f03 * s30 + f13 * s31 + f23 * s32 + f33 * s33 + f43 * s34)); + output.set(4, 3, (byte) (f03 * s40 + f13 * s41 + f23 * s42 + f33 * s43 + f43 * s44)); + output.set(0, 4, (byte) (f04 * s00 + f14 * s01 + f24 * s02 + f34 * s03 + f44 * s04)); + output.set(1, 4, (byte) (f04 * s10 + f14 * s11 + f24 * s12 + f34 * s13 + f44 * s14)); + output.set(2, 4, (byte) (f04 * s20 + f14 * s21 + f24 * s22 + f34 * s23 + f44 * s24)); + output.set(3, 4, (byte) (f04 * s30 + f14 * s31 + f24 * s32 + f34 * s33 + f44 * s34)); + output.set(4, 4, (byte) (f04 * s40 + f14 * s41 + f24 * s42 + f34 * s43 + f44 * s44)); return output; } /** * Automatically generated concrete matrix multiplication. If no mapping exist, this method returns null. * - * @return new Byte2Dimensional + * @return new Byte2Dimensional */ - @org.jetbrains.annotations.Nullable - public static Byte2Dimensional multiplyMatrix(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2) { + @org.jetbrains.annotations.Nullable + public static Byte2Dimensional multiplyMatrix(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2) { if (matrix1.getColumns() != matrix2.getRows()) return null; - switch (matrix1.getColumns()) { - case 2: switch (matrix1.getRows()) { - case 2: switch (matrix2.getColumns()) { + switch(matrix1.getColumns()) { + case 1: switch(matrix1.getRows()) { + case 1: switch(matrix2.getColumns()) { + case 1: return (Byte2Dimensional) multiplyMatrix1x1x1(matrix1, matrix2, new Byte2Dimensional(1, 1)); + case 2: return (Byte2Dimensional) multiplyMatrix1x1x2(matrix1, matrix2, new Byte2Dimensional(2, 1)); + case 3: return (Byte2Dimensional) multiplyMatrix1x1x3(matrix1, matrix2, new Byte2Dimensional(3, 1)); + case 4: return (Byte2Dimensional) multiplyMatrix1x1x4(matrix1, matrix2, new Byte2Dimensional(4, 1)); + case 5: return (Byte2Dimensional) multiplyMatrix1x1x5(matrix1, matrix2, new Byte2Dimensional(5, 1)); + default: return null; + } + case 2: switch(matrix2.getColumns()) { + case 1: return (Byte2Dimensional) multiplyMatrix2x1x1(matrix1, matrix2, new Byte2Dimensional(1, 2)); + case 2: return (Byte2Dimensional) multiplyMatrix2x1x2(matrix1, matrix2, new Byte2Dimensional(2, 2)); + case 3: return (Byte2Dimensional) multiplyMatrix2x1x3(matrix1, matrix2, new Byte2Dimensional(3, 2)); + case 4: return (Byte2Dimensional) multiplyMatrix2x1x4(matrix1, matrix2, new Byte2Dimensional(4, 2)); + case 5: return (Byte2Dimensional) multiplyMatrix2x1x5(matrix1, matrix2, new Byte2Dimensional(5, 2)); + default: return null; + } + case 3: switch(matrix2.getColumns()) { + case 1: return (Byte2Dimensional) multiplyMatrix3x1x1(matrix1, matrix2, new Byte2Dimensional(1, 3)); + case 2: return (Byte2Dimensional) multiplyMatrix3x1x2(matrix1, matrix2, new Byte2Dimensional(2, 3)); + case 3: return (Byte2Dimensional) multiplyMatrix3x1x3(matrix1, matrix2, new Byte2Dimensional(3, 3)); + case 4: return (Byte2Dimensional) multiplyMatrix3x1x4(matrix1, matrix2, new Byte2Dimensional(4, 3)); + case 5: return (Byte2Dimensional) multiplyMatrix3x1x5(matrix1, matrix2, new Byte2Dimensional(5, 3)); + default: return null; + } + case 4: switch(matrix2.getColumns()) { + case 1: return (Byte2Dimensional) multiplyMatrix4x1x1(matrix1, matrix2, new Byte2Dimensional(1, 4)); + case 2: return (Byte2Dimensional) multiplyMatrix4x1x2(matrix1, matrix2, new Byte2Dimensional(2, 4)); + case 3: return (Byte2Dimensional) multiplyMatrix4x1x3(matrix1, matrix2, new Byte2Dimensional(3, 4)); + case 4: return (Byte2Dimensional) multiplyMatrix4x1x4(matrix1, matrix2, new Byte2Dimensional(4, 4)); + case 5: return (Byte2Dimensional) multiplyMatrix4x1x5(matrix1, matrix2, new Byte2Dimensional(5, 4)); + default: return null; + } + case 5: switch(matrix2.getColumns()) { + case 1: return (Byte2Dimensional) multiplyMatrix5x1x1(matrix1, matrix2, new Byte2Dimensional(1, 5)); + case 2: return (Byte2Dimensional) multiplyMatrix5x1x2(matrix1, matrix2, new Byte2Dimensional(2, 5)); + case 3: return (Byte2Dimensional) multiplyMatrix5x1x3(matrix1, matrix2, new Byte2Dimensional(3, 5)); + case 4: return (Byte2Dimensional) multiplyMatrix5x1x4(matrix1, matrix2, new Byte2Dimensional(4, 5)); + case 5: return (Byte2Dimensional) multiplyMatrix5x1x5(matrix1, matrix2, new Byte2Dimensional(5, 5)); + default: return null; + } + default: return null; + } + case 2: switch(matrix1.getRows()) { + case 1: switch(matrix2.getColumns()) { + case 1: return (Byte2Dimensional) multiplyMatrix1x2x1(matrix1, matrix2, new Byte2Dimensional(1, 1)); + case 2: return (Byte2Dimensional) multiplyMatrix1x2x2(matrix1, matrix2, new Byte2Dimensional(2, 1)); + case 3: return (Byte2Dimensional) multiplyMatrix1x2x3(matrix1, matrix2, new Byte2Dimensional(3, 1)); + case 4: return (Byte2Dimensional) multiplyMatrix1x2x4(matrix1, matrix2, new Byte2Dimensional(4, 1)); + case 5: return (Byte2Dimensional) multiplyMatrix1x2x5(matrix1, matrix2, new Byte2Dimensional(5, 1)); + default: return null; + } + case 2: switch(matrix2.getColumns()) { + case 1: return (Byte2Dimensional) multiplyMatrix2x2x1(matrix1, matrix2, new Byte2Dimensional(1, 2)); case 2: return (Byte2Dimensional) multiplyMatrix2x2x2(matrix1, matrix2, new Byte2Dimensional(2, 2)); case 3: return (Byte2Dimensional) multiplyMatrix2x2x3(matrix1, matrix2, new Byte2Dimensional(3, 2)); case 4: return (Byte2Dimensional) multiplyMatrix2x2x4(matrix1, matrix2, new Byte2Dimensional(4, 2)); case 5: return (Byte2Dimensional) multiplyMatrix2x2x5(matrix1, matrix2, new Byte2Dimensional(5, 2)); default: return null; } - case 3: switch (matrix2.getColumns()) { + case 3: switch(matrix2.getColumns()) { + case 1: return (Byte2Dimensional) multiplyMatrix3x2x1(matrix1, matrix2, new Byte2Dimensional(1, 3)); case 2: return (Byte2Dimensional) multiplyMatrix3x2x2(matrix1, matrix2, new Byte2Dimensional(2, 3)); case 3: return (Byte2Dimensional) multiplyMatrix3x2x3(matrix1, matrix2, new Byte2Dimensional(3, 3)); case 4: return (Byte2Dimensional) multiplyMatrix3x2x4(matrix1, matrix2, new Byte2Dimensional(4, 3)); case 5: return (Byte2Dimensional) multiplyMatrix3x2x5(matrix1, matrix2, new Byte2Dimensional(5, 3)); default: return null; } - case 4: switch (matrix2.getColumns()) { + case 4: switch(matrix2.getColumns()) { + case 1: return (Byte2Dimensional) multiplyMatrix4x2x1(matrix1, matrix2, new Byte2Dimensional(1, 4)); case 2: return (Byte2Dimensional) multiplyMatrix4x2x2(matrix1, matrix2, new Byte2Dimensional(2, 4)); case 3: return (Byte2Dimensional) multiplyMatrix4x2x3(matrix1, matrix2, new Byte2Dimensional(3, 4)); case 4: return (Byte2Dimensional) multiplyMatrix4x2x4(matrix1, matrix2, new Byte2Dimensional(4, 4)); case 5: return (Byte2Dimensional) multiplyMatrix4x2x5(matrix1, matrix2, new Byte2Dimensional(5, 4)); default: return null; } - case 5: switch (matrix2.getColumns()) { + case 5: switch(matrix2.getColumns()) { + case 1: return (Byte2Dimensional) multiplyMatrix5x2x1(matrix1, matrix2, new Byte2Dimensional(1, 5)); case 2: return (Byte2Dimensional) multiplyMatrix5x2x2(matrix1, matrix2, new Byte2Dimensional(2, 5)); case 3: return (Byte2Dimensional) multiplyMatrix5x2x3(matrix1, matrix2, new Byte2Dimensional(3, 5)); case 4: return (Byte2Dimensional) multiplyMatrix5x2x4(matrix1, matrix2, new Byte2Dimensional(4, 5)); @@ -2788,29 +4230,41 @@ public final class MultiplicationsByte { } default: return null; } - case 3: switch (matrix1.getRows()) { - case 2: switch (matrix2.getColumns()) { + case 3: switch(matrix1.getRows()) { + case 1: switch(matrix2.getColumns()) { + case 1: return (Byte2Dimensional) multiplyMatrix1x3x1(matrix1, matrix2, new Byte2Dimensional(1, 1)); + case 2: return (Byte2Dimensional) multiplyMatrix1x3x2(matrix1, matrix2, new Byte2Dimensional(2, 1)); + case 3: return (Byte2Dimensional) multiplyMatrix1x3x3(matrix1, matrix2, new Byte2Dimensional(3, 1)); + case 4: return (Byte2Dimensional) multiplyMatrix1x3x4(matrix1, matrix2, new Byte2Dimensional(4, 1)); + case 5: return (Byte2Dimensional) multiplyMatrix1x3x5(matrix1, matrix2, new Byte2Dimensional(5, 1)); + default: return null; + } + case 2: switch(matrix2.getColumns()) { + case 1: return (Byte2Dimensional) multiplyMatrix2x3x1(matrix1, matrix2, new Byte2Dimensional(1, 2)); case 2: return (Byte2Dimensional) multiplyMatrix2x3x2(matrix1, matrix2, new Byte2Dimensional(2, 2)); case 3: return (Byte2Dimensional) multiplyMatrix2x3x3(matrix1, matrix2, new Byte2Dimensional(3, 2)); case 4: return (Byte2Dimensional) multiplyMatrix2x3x4(matrix1, matrix2, new Byte2Dimensional(4, 2)); case 5: return (Byte2Dimensional) multiplyMatrix2x3x5(matrix1, matrix2, new Byte2Dimensional(5, 2)); default: return null; } - case 3: switch (matrix2.getColumns()) { + case 3: switch(matrix2.getColumns()) { + case 1: return (Byte2Dimensional) multiplyMatrix3x3x1(matrix1, matrix2, new Byte2Dimensional(1, 3)); case 2: return (Byte2Dimensional) multiplyMatrix3x3x2(matrix1, matrix2, new Byte2Dimensional(2, 3)); case 3: return (Byte2Dimensional) multiplyMatrix3x3x3(matrix1, matrix2, new Byte2Dimensional(3, 3)); case 4: return (Byte2Dimensional) multiplyMatrix3x3x4(matrix1, matrix2, new Byte2Dimensional(4, 3)); case 5: return (Byte2Dimensional) multiplyMatrix3x3x5(matrix1, matrix2, new Byte2Dimensional(5, 3)); default: return null; } - case 4: switch (matrix2.getColumns()) { + case 4: switch(matrix2.getColumns()) { + case 1: return (Byte2Dimensional) multiplyMatrix4x3x1(matrix1, matrix2, new Byte2Dimensional(1, 4)); case 2: return (Byte2Dimensional) multiplyMatrix4x3x2(matrix1, matrix2, new Byte2Dimensional(2, 4)); case 3: return (Byte2Dimensional) multiplyMatrix4x3x3(matrix1, matrix2, new Byte2Dimensional(3, 4)); case 4: return (Byte2Dimensional) multiplyMatrix4x3x4(matrix1, matrix2, new Byte2Dimensional(4, 4)); case 5: return (Byte2Dimensional) multiplyMatrix4x3x5(matrix1, matrix2, new Byte2Dimensional(5, 4)); default: return null; } - case 5: switch (matrix2.getColumns()) { + case 5: switch(matrix2.getColumns()) { + case 1: return (Byte2Dimensional) multiplyMatrix5x3x1(matrix1, matrix2, new Byte2Dimensional(1, 5)); case 2: return (Byte2Dimensional) multiplyMatrix5x3x2(matrix1, matrix2, new Byte2Dimensional(2, 5)); case 3: return (Byte2Dimensional) multiplyMatrix5x3x3(matrix1, matrix2, new Byte2Dimensional(3, 5)); case 4: return (Byte2Dimensional) multiplyMatrix5x3x4(matrix1, matrix2, new Byte2Dimensional(4, 5)); @@ -2819,29 +4273,41 @@ public final class MultiplicationsByte { } default: return null; } - case 4: switch (matrix1.getRows()) { - case 2: switch (matrix2.getColumns()) { + case 4: switch(matrix1.getRows()) { + case 1: switch(matrix2.getColumns()) { + case 1: return (Byte2Dimensional) multiplyMatrix1x4x1(matrix1, matrix2, new Byte2Dimensional(1, 1)); + case 2: return (Byte2Dimensional) multiplyMatrix1x4x2(matrix1, matrix2, new Byte2Dimensional(2, 1)); + case 3: return (Byte2Dimensional) multiplyMatrix1x4x3(matrix1, matrix2, new Byte2Dimensional(3, 1)); + case 4: return (Byte2Dimensional) multiplyMatrix1x4x4(matrix1, matrix2, new Byte2Dimensional(4, 1)); + case 5: return (Byte2Dimensional) multiplyMatrix1x4x5(matrix1, matrix2, new Byte2Dimensional(5, 1)); + default: return null; + } + case 2: switch(matrix2.getColumns()) { + case 1: return (Byte2Dimensional) multiplyMatrix2x4x1(matrix1, matrix2, new Byte2Dimensional(1, 2)); case 2: return (Byte2Dimensional) multiplyMatrix2x4x2(matrix1, matrix2, new Byte2Dimensional(2, 2)); case 3: return (Byte2Dimensional) multiplyMatrix2x4x3(matrix1, matrix2, new Byte2Dimensional(3, 2)); case 4: return (Byte2Dimensional) multiplyMatrix2x4x4(matrix1, matrix2, new Byte2Dimensional(4, 2)); case 5: return (Byte2Dimensional) multiplyMatrix2x4x5(matrix1, matrix2, new Byte2Dimensional(5, 2)); default: return null; } - case 3: switch (matrix2.getColumns()) { + case 3: switch(matrix2.getColumns()) { + case 1: return (Byte2Dimensional) multiplyMatrix3x4x1(matrix1, matrix2, new Byte2Dimensional(1, 3)); case 2: return (Byte2Dimensional) multiplyMatrix3x4x2(matrix1, matrix2, new Byte2Dimensional(2, 3)); case 3: return (Byte2Dimensional) multiplyMatrix3x4x3(matrix1, matrix2, new Byte2Dimensional(3, 3)); case 4: return (Byte2Dimensional) multiplyMatrix3x4x4(matrix1, matrix2, new Byte2Dimensional(4, 3)); case 5: return (Byte2Dimensional) multiplyMatrix3x4x5(matrix1, matrix2, new Byte2Dimensional(5, 3)); default: return null; } - case 4: switch (matrix2.getColumns()) { + case 4: switch(matrix2.getColumns()) { + case 1: return (Byte2Dimensional) multiplyMatrix4x4x1(matrix1, matrix2, new Byte2Dimensional(1, 4)); case 2: return (Byte2Dimensional) multiplyMatrix4x4x2(matrix1, matrix2, new Byte2Dimensional(2, 4)); case 3: return (Byte2Dimensional) multiplyMatrix4x4x3(matrix1, matrix2, new Byte2Dimensional(3, 4)); case 4: return (Byte2Dimensional) multiplyMatrix4x4x4(matrix1, matrix2, new Byte2Dimensional(4, 4)); case 5: return (Byte2Dimensional) multiplyMatrix4x4x5(matrix1, matrix2, new Byte2Dimensional(5, 4)); default: return null; } - case 5: switch (matrix2.getColumns()) { + case 5: switch(matrix2.getColumns()) { + case 1: return (Byte2Dimensional) multiplyMatrix5x4x1(matrix1, matrix2, new Byte2Dimensional(1, 5)); case 2: return (Byte2Dimensional) multiplyMatrix5x4x2(matrix1, matrix2, new Byte2Dimensional(2, 5)); case 3: return (Byte2Dimensional) multiplyMatrix5x4x3(matrix1, matrix2, new Byte2Dimensional(3, 5)); case 4: return (Byte2Dimensional) multiplyMatrix5x4x4(matrix1, matrix2, new Byte2Dimensional(4, 5)); @@ -2850,29 +4316,41 @@ public final class MultiplicationsByte { } default: return null; } - case 5: switch (matrix1.getRows()) { - case 2: switch (matrix2.getColumns()) { + case 5: switch(matrix1.getRows()) { + case 1: switch(matrix2.getColumns()) { + case 1: return (Byte2Dimensional) multiplyMatrix1x5x1(matrix1, matrix2, new Byte2Dimensional(1, 1)); + case 2: return (Byte2Dimensional) multiplyMatrix1x5x2(matrix1, matrix2, new Byte2Dimensional(2, 1)); + case 3: return (Byte2Dimensional) multiplyMatrix1x5x3(matrix1, matrix2, new Byte2Dimensional(3, 1)); + case 4: return (Byte2Dimensional) multiplyMatrix1x5x4(matrix1, matrix2, new Byte2Dimensional(4, 1)); + case 5: return (Byte2Dimensional) multiplyMatrix1x5x5(matrix1, matrix2, new Byte2Dimensional(5, 1)); + default: return null; + } + case 2: switch(matrix2.getColumns()) { + case 1: return (Byte2Dimensional) multiplyMatrix2x5x1(matrix1, matrix2, new Byte2Dimensional(1, 2)); case 2: return (Byte2Dimensional) multiplyMatrix2x5x2(matrix1, matrix2, new Byte2Dimensional(2, 2)); case 3: return (Byte2Dimensional) multiplyMatrix2x5x3(matrix1, matrix2, new Byte2Dimensional(3, 2)); case 4: return (Byte2Dimensional) multiplyMatrix2x5x4(matrix1, matrix2, new Byte2Dimensional(4, 2)); case 5: return (Byte2Dimensional) multiplyMatrix2x5x5(matrix1, matrix2, new Byte2Dimensional(5, 2)); default: return null; } - case 3: switch (matrix2.getColumns()) { + case 3: switch(matrix2.getColumns()) { + case 1: return (Byte2Dimensional) multiplyMatrix3x5x1(matrix1, matrix2, new Byte2Dimensional(1, 3)); case 2: return (Byte2Dimensional) multiplyMatrix3x5x2(matrix1, matrix2, new Byte2Dimensional(2, 3)); case 3: return (Byte2Dimensional) multiplyMatrix3x5x3(matrix1, matrix2, new Byte2Dimensional(3, 3)); case 4: return (Byte2Dimensional) multiplyMatrix3x5x4(matrix1, matrix2, new Byte2Dimensional(4, 3)); case 5: return (Byte2Dimensional) multiplyMatrix3x5x5(matrix1, matrix2, new Byte2Dimensional(5, 3)); default: return null; } - case 4: switch (matrix2.getColumns()) { + case 4: switch(matrix2.getColumns()) { + case 1: return (Byte2Dimensional) multiplyMatrix4x5x1(matrix1, matrix2, new Byte2Dimensional(1, 4)); case 2: return (Byte2Dimensional) multiplyMatrix4x5x2(matrix1, matrix2, new Byte2Dimensional(2, 4)); case 3: return (Byte2Dimensional) multiplyMatrix4x5x3(matrix1, matrix2, new Byte2Dimensional(3, 4)); case 4: return (Byte2Dimensional) multiplyMatrix4x5x4(matrix1, matrix2, new Byte2Dimensional(4, 4)); case 5: return (Byte2Dimensional) multiplyMatrix4x5x5(matrix1, matrix2, new Byte2Dimensional(5, 4)); default: return null; } - case 5: switch (matrix2.getColumns()) { + case 5: switch(matrix2.getColumns()) { + case 1: return (Byte2Dimensional) multiplyMatrix5x5x1(matrix1, matrix2, new Byte2Dimensional(1, 5)); case 2: return (Byte2Dimensional) multiplyMatrix5x5x2(matrix1, matrix2, new Byte2Dimensional(2, 5)); case 3: return (Byte2Dimensional) multiplyMatrix5x5x3(matrix1, matrix2, new Byte2Dimensional(3, 5)); case 4: return (Byte2Dimensional) multiplyMatrix5x5x4(matrix1, matrix2, new Byte2Dimensional(4, 5)); @@ -2884,39 +4362,94 @@ public final class MultiplicationsByte { default: return null; } } - /** - * Automatically generated concrete matrix multiplication. If no mapping exist, this method returns null. - * This method writes the result to specified [output] - * @return provided IMatrixSetterByte if mapping exists and computed, or null if mapping does not exist + * Automatically generated concrete matrix multiplication. + * This function writes the result onto specified output, and returns it, if mapping exists and computed, otherwise returns null. + * + * @return provided output, or null if mapping does not exist */ - @org.jetbrains.annotations.Nullable - public static IMatrixSetterByte multiplyMatrix(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { + @org.jetbrains.annotations.Nullable + public static IMatrixSetterByte multiplyMatrix(final IMatrixGetterByte matrix1, final IMatrixGetterByte matrix2, final IMatrixSetterByte output) { if (matrix1.getColumns() != matrix2.getRows()) return null; - switch (matrix1.getColumns()) { - case 2: switch (matrix1.getRows()) { - case 2: switch (matrix2.getColumns()) { + switch(matrix1.getColumns()) { + case 1: switch(matrix1.getRows()) { + case 1: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix1x1x1(matrix1, matrix2, output); + case 2: return multiplyMatrix1x1x2(matrix1, matrix2, output); + case 3: return multiplyMatrix1x1x3(matrix1, matrix2, output); + case 4: return multiplyMatrix1x1x4(matrix1, matrix2, output); + case 5: return multiplyMatrix1x1x5(matrix1, matrix2, output); + default: return null; + } + case 2: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix2x1x1(matrix1, matrix2, output); + case 2: return multiplyMatrix2x1x2(matrix1, matrix2, output); + case 3: return multiplyMatrix2x1x3(matrix1, matrix2, output); + case 4: return multiplyMatrix2x1x4(matrix1, matrix2, output); + case 5: return multiplyMatrix2x1x5(matrix1, matrix2, output); + default: return null; + } + case 3: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix3x1x1(matrix1, matrix2, output); + case 2: return multiplyMatrix3x1x2(matrix1, matrix2, output); + case 3: return multiplyMatrix3x1x3(matrix1, matrix2, output); + case 4: return multiplyMatrix3x1x4(matrix1, matrix2, output); + case 5: return multiplyMatrix3x1x5(matrix1, matrix2, output); + default: return null; + } + case 4: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix4x1x1(matrix1, matrix2, output); + case 2: return multiplyMatrix4x1x2(matrix1, matrix2, output); + case 3: return multiplyMatrix4x1x3(matrix1, matrix2, output); + case 4: return multiplyMatrix4x1x4(matrix1, matrix2, output); + case 5: return multiplyMatrix4x1x5(matrix1, matrix2, output); + default: return null; + } + case 5: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix5x1x1(matrix1, matrix2, output); + case 2: return multiplyMatrix5x1x2(matrix1, matrix2, output); + case 3: return multiplyMatrix5x1x3(matrix1, matrix2, output); + case 4: return multiplyMatrix5x1x4(matrix1, matrix2, output); + case 5: return multiplyMatrix5x1x5(matrix1, matrix2, output); + default: return null; + } + default: return null; + } + case 2: switch(matrix1.getRows()) { + case 1: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix1x2x1(matrix1, matrix2, output); + case 2: return multiplyMatrix1x2x2(matrix1, matrix2, output); + case 3: return multiplyMatrix1x2x3(matrix1, matrix2, output); + case 4: return multiplyMatrix1x2x4(matrix1, matrix2, output); + case 5: return multiplyMatrix1x2x5(matrix1, matrix2, output); + default: return null; + } + case 2: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix2x2x1(matrix1, matrix2, output); case 2: return multiplyMatrix2x2x2(matrix1, matrix2, output); case 3: return multiplyMatrix2x2x3(matrix1, matrix2, output); case 4: return multiplyMatrix2x2x4(matrix1, matrix2, output); case 5: return multiplyMatrix2x2x5(matrix1, matrix2, output); default: return null; } - case 3: switch (matrix2.getColumns()) { + case 3: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix3x2x1(matrix1, matrix2, output); case 2: return multiplyMatrix3x2x2(matrix1, matrix2, output); case 3: return multiplyMatrix3x2x3(matrix1, matrix2, output); case 4: return multiplyMatrix3x2x4(matrix1, matrix2, output); case 5: return multiplyMatrix3x2x5(matrix1, matrix2, output); default: return null; } - case 4: switch (matrix2.getColumns()) { + case 4: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix4x2x1(matrix1, matrix2, output); case 2: return multiplyMatrix4x2x2(matrix1, matrix2, output); case 3: return multiplyMatrix4x2x3(matrix1, matrix2, output); case 4: return multiplyMatrix4x2x4(matrix1, matrix2, output); case 5: return multiplyMatrix4x2x5(matrix1, matrix2, output); default: return null; } - case 5: switch (matrix2.getColumns()) { + case 5: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix5x2x1(matrix1, matrix2, output); case 2: return multiplyMatrix5x2x2(matrix1, matrix2, output); case 3: return multiplyMatrix5x2x3(matrix1, matrix2, output); case 4: return multiplyMatrix5x2x4(matrix1, matrix2, output); @@ -2925,29 +4458,41 @@ public final class MultiplicationsByte { } default: return null; } - case 3: switch (matrix1.getRows()) { - case 2: switch (matrix2.getColumns()) { + case 3: switch(matrix1.getRows()) { + case 1: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix1x3x1(matrix1, matrix2, output); + case 2: return multiplyMatrix1x3x2(matrix1, matrix2, output); + case 3: return multiplyMatrix1x3x3(matrix1, matrix2, output); + case 4: return multiplyMatrix1x3x4(matrix1, matrix2, output); + case 5: return multiplyMatrix1x3x5(matrix1, matrix2, output); + default: return null; + } + case 2: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix2x3x1(matrix1, matrix2, output); case 2: return multiplyMatrix2x3x2(matrix1, matrix2, output); case 3: return multiplyMatrix2x3x3(matrix1, matrix2, output); case 4: return multiplyMatrix2x3x4(matrix1, matrix2, output); case 5: return multiplyMatrix2x3x5(matrix1, matrix2, output); default: return null; } - case 3: switch (matrix2.getColumns()) { + case 3: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix3x3x1(matrix1, matrix2, output); case 2: return multiplyMatrix3x3x2(matrix1, matrix2, output); case 3: return multiplyMatrix3x3x3(matrix1, matrix2, output); case 4: return multiplyMatrix3x3x4(matrix1, matrix2, output); case 5: return multiplyMatrix3x3x5(matrix1, matrix2, output); default: return null; } - case 4: switch (matrix2.getColumns()) { + case 4: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix4x3x1(matrix1, matrix2, output); case 2: return multiplyMatrix4x3x2(matrix1, matrix2, output); case 3: return multiplyMatrix4x3x3(matrix1, matrix2, output); case 4: return multiplyMatrix4x3x4(matrix1, matrix2, output); case 5: return multiplyMatrix4x3x5(matrix1, matrix2, output); default: return null; } - case 5: switch (matrix2.getColumns()) { + case 5: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix5x3x1(matrix1, matrix2, output); case 2: return multiplyMatrix5x3x2(matrix1, matrix2, output); case 3: return multiplyMatrix5x3x3(matrix1, matrix2, output); case 4: return multiplyMatrix5x3x4(matrix1, matrix2, output); @@ -2956,29 +4501,41 @@ public final class MultiplicationsByte { } default: return null; } - case 4: switch (matrix1.getRows()) { - case 2: switch (matrix2.getColumns()) { + case 4: switch(matrix1.getRows()) { + case 1: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix1x4x1(matrix1, matrix2, output); + case 2: return multiplyMatrix1x4x2(matrix1, matrix2, output); + case 3: return multiplyMatrix1x4x3(matrix1, matrix2, output); + case 4: return multiplyMatrix1x4x4(matrix1, matrix2, output); + case 5: return multiplyMatrix1x4x5(matrix1, matrix2, output); + default: return null; + } + case 2: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix2x4x1(matrix1, matrix2, output); case 2: return multiplyMatrix2x4x2(matrix1, matrix2, output); case 3: return multiplyMatrix2x4x3(matrix1, matrix2, output); case 4: return multiplyMatrix2x4x4(matrix1, matrix2, output); case 5: return multiplyMatrix2x4x5(matrix1, matrix2, output); default: return null; } - case 3: switch (matrix2.getColumns()) { + case 3: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix3x4x1(matrix1, matrix2, output); case 2: return multiplyMatrix3x4x2(matrix1, matrix2, output); case 3: return multiplyMatrix3x4x3(matrix1, matrix2, output); case 4: return multiplyMatrix3x4x4(matrix1, matrix2, output); case 5: return multiplyMatrix3x4x5(matrix1, matrix2, output); default: return null; } - case 4: switch (matrix2.getColumns()) { + case 4: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix4x4x1(matrix1, matrix2, output); case 2: return multiplyMatrix4x4x2(matrix1, matrix2, output); case 3: return multiplyMatrix4x4x3(matrix1, matrix2, output); case 4: return multiplyMatrix4x4x4(matrix1, matrix2, output); case 5: return multiplyMatrix4x4x5(matrix1, matrix2, output); default: return null; } - case 5: switch (matrix2.getColumns()) { + case 5: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix5x4x1(matrix1, matrix2, output); case 2: return multiplyMatrix5x4x2(matrix1, matrix2, output); case 3: return multiplyMatrix5x4x3(matrix1, matrix2, output); case 4: return multiplyMatrix5x4x4(matrix1, matrix2, output); @@ -2987,29 +4544,41 @@ public final class MultiplicationsByte { } default: return null; } - case 5: switch (matrix1.getRows()) { - case 2: switch (matrix2.getColumns()) { + case 5: switch(matrix1.getRows()) { + case 1: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix1x5x1(matrix1, matrix2, output); + case 2: return multiplyMatrix1x5x2(matrix1, matrix2, output); + case 3: return multiplyMatrix1x5x3(matrix1, matrix2, output); + case 4: return multiplyMatrix1x5x4(matrix1, matrix2, output); + case 5: return multiplyMatrix1x5x5(matrix1, matrix2, output); + default: return null; + } + case 2: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix2x5x1(matrix1, matrix2, output); case 2: return multiplyMatrix2x5x2(matrix1, matrix2, output); case 3: return multiplyMatrix2x5x3(matrix1, matrix2, output); case 4: return multiplyMatrix2x5x4(matrix1, matrix2, output); case 5: return multiplyMatrix2x5x5(matrix1, matrix2, output); default: return null; } - case 3: switch (matrix2.getColumns()) { + case 3: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix3x5x1(matrix1, matrix2, output); case 2: return multiplyMatrix3x5x2(matrix1, matrix2, output); case 3: return multiplyMatrix3x5x3(matrix1, matrix2, output); case 4: return multiplyMatrix3x5x4(matrix1, matrix2, output); case 5: return multiplyMatrix3x5x5(matrix1, matrix2, output); default: return null; } - case 4: switch (matrix2.getColumns()) { + case 4: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix4x5x1(matrix1, matrix2, output); case 2: return multiplyMatrix4x5x2(matrix1, matrix2, output); case 3: return multiplyMatrix4x5x3(matrix1, matrix2, output); case 4: return multiplyMatrix4x5x4(matrix1, matrix2, output); case 5: return multiplyMatrix4x5x5(matrix1, matrix2, output); default: return null; } - case 5: switch (matrix2.getColumns()) { + case 5: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix5x5x1(matrix1, matrix2, output); case 2: return multiplyMatrix5x5x2(matrix1, matrix2, output); case 3: return multiplyMatrix5x5x3(matrix1, matrix2, output); case 4: return multiplyMatrix5x5x4(matrix1, matrix2, output); diff --git a/src/kvector/java/ru/dbotthepony/kvector/matrix/generated/MultiplicationsDouble.java b/src/kvector/java/ru/dbotthepony/kvector/matrix/generated/MultiplicationsDouble.java index 3696c029..6e522450 100644 --- a/src/kvector/java/ru/dbotthepony/kvector/matrix/generated/MultiplicationsDouble.java +++ b/src/kvector/java/ru/dbotthepony/kvector/matrix/generated/MultiplicationsDouble.java @@ -3,7 +3,6 @@ package ru.dbotthepony.kvector.matrix.generated; import ru.dbotthepony.kvector.api.*; import ru.dbotthepony.kvector.narray.*; -// Some metaprogramming ///////////////////////////////// // THIS FILE IS AUTO GENERATED // // DO NOT EDIT // @@ -11,2775 +10,4218 @@ import ru.dbotthepony.kvector.narray.*; public final class MultiplicationsDouble { private MultiplicationsDouble() {} + private static IMatrixSetterDouble multiplyMatrix1x1x1(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final double f00 = matrix1.get(0, 0); + final double s00 = matrix2.get(0, 0); + output.set(0, 0, f00 * s00); + return output; + } + + private static IMatrixSetterDouble multiplyMatrix1x1x2(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final double f00 = matrix1.get(0, 0); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + return output; + } + + private static IMatrixSetterDouble multiplyMatrix1x1x3(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final double f00 = matrix1.get(0, 0); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(2, 0, f00 * s20); + return output; + } + + private static IMatrixSetterDouble multiplyMatrix1x1x4(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final double f00 = matrix1.get(0, 0); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + final double s30 = matrix2.get(3, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(2, 0, f00 * s20); + output.set(3, 0, f00 * s30); + return output; + } + + private static IMatrixSetterDouble multiplyMatrix1x1x5(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final double f00 = matrix1.get(0, 0); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + final double s30 = matrix2.get(3, 0); + final double s40 = matrix2.get(4, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(2, 0, f00 * s20); + output.set(3, 0, f00 * s30); + output.set(4, 0, f00 * s40); + return output; + } + + private static IMatrixSetterDouble multiplyMatrix2x1x1(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final double f00 = matrix1.get(0, 0); + final double f01 = matrix1.get(0, 1); + final double s00 = matrix2.get(0, 0); + output.set(0, 0, f00 * s00); + output.set(0, 1, f01 * s00); + return output; + } + + private static IMatrixSetterDouble multiplyMatrix2x1x2(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final double f00 = matrix1.get(0, 0); + final double f01 = matrix1.get(0, 1); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(0, 1, f01 * s00); + output.set(1, 1, f01 * s10); + return output; + } + + private static IMatrixSetterDouble multiplyMatrix2x1x3(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final double f00 = matrix1.get(0, 0); + final double f01 = matrix1.get(0, 1); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(2, 0, f00 * s20); + output.set(0, 1, f01 * s00); + output.set(1, 1, f01 * s10); + output.set(2, 1, f01 * s20); + return output; + } + + private static IMatrixSetterDouble multiplyMatrix2x1x4(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final double f00 = matrix1.get(0, 0); + final double f01 = matrix1.get(0, 1); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + final double s30 = matrix2.get(3, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(2, 0, f00 * s20); + output.set(3, 0, f00 * s30); + output.set(0, 1, f01 * s00); + output.set(1, 1, f01 * s10); + output.set(2, 1, f01 * s20); + output.set(3, 1, f01 * s30); + return output; + } + + private static IMatrixSetterDouble multiplyMatrix2x1x5(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final double f00 = matrix1.get(0, 0); + final double f01 = matrix1.get(0, 1); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + final double s30 = matrix2.get(3, 0); + final double s40 = matrix2.get(4, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(2, 0, f00 * s20); + output.set(3, 0, f00 * s30); + output.set(4, 0, f00 * s40); + output.set(0, 1, f01 * s00); + output.set(1, 1, f01 * s10); + output.set(2, 1, f01 * s20); + output.set(3, 1, f01 * s30); + output.set(4, 1, f01 * s40); + return output; + } + + private static IMatrixSetterDouble multiplyMatrix3x1x1(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final double f00 = matrix1.get(0, 0); + final double f01 = matrix1.get(0, 1); + final double f02 = matrix1.get(0, 2); + final double s00 = matrix2.get(0, 0); + output.set(0, 0, f00 * s00); + output.set(0, 1, f01 * s00); + output.set(0, 2, f02 * s00); + return output; + } + + private static IMatrixSetterDouble multiplyMatrix3x1x2(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final double f00 = matrix1.get(0, 0); + final double f01 = matrix1.get(0, 1); + final double f02 = matrix1.get(0, 2); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(0, 1, f01 * s00); + output.set(1, 1, f01 * s10); + output.set(0, 2, f02 * s00); + output.set(1, 2, f02 * s10); + return output; + } + + private static IMatrixSetterDouble multiplyMatrix3x1x3(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final double f00 = matrix1.get(0, 0); + final double f01 = matrix1.get(0, 1); + final double f02 = matrix1.get(0, 2); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(2, 0, f00 * s20); + output.set(0, 1, f01 * s00); + output.set(1, 1, f01 * s10); + output.set(2, 1, f01 * s20); + output.set(0, 2, f02 * s00); + output.set(1, 2, f02 * s10); + output.set(2, 2, f02 * s20); + return output; + } + + private static IMatrixSetterDouble multiplyMatrix3x1x4(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final double f00 = matrix1.get(0, 0); + final double f01 = matrix1.get(0, 1); + final double f02 = matrix1.get(0, 2); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + final double s30 = matrix2.get(3, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(2, 0, f00 * s20); + output.set(3, 0, f00 * s30); + output.set(0, 1, f01 * s00); + output.set(1, 1, f01 * s10); + output.set(2, 1, f01 * s20); + output.set(3, 1, f01 * s30); + output.set(0, 2, f02 * s00); + output.set(1, 2, f02 * s10); + output.set(2, 2, f02 * s20); + output.set(3, 2, f02 * s30); + return output; + } + + private static IMatrixSetterDouble multiplyMatrix3x1x5(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final double f00 = matrix1.get(0, 0); + final double f01 = matrix1.get(0, 1); + final double f02 = matrix1.get(0, 2); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + final double s30 = matrix2.get(3, 0); + final double s40 = matrix2.get(4, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(2, 0, f00 * s20); + output.set(3, 0, f00 * s30); + output.set(4, 0, f00 * s40); + output.set(0, 1, f01 * s00); + output.set(1, 1, f01 * s10); + output.set(2, 1, f01 * s20); + output.set(3, 1, f01 * s30); + output.set(4, 1, f01 * s40); + output.set(0, 2, f02 * s00); + output.set(1, 2, f02 * s10); + output.set(2, 2, f02 * s20); + output.set(3, 2, f02 * s30); + output.set(4, 2, f02 * s40); + return output; + } + + private static IMatrixSetterDouble multiplyMatrix4x1x1(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final double f00 = matrix1.get(0, 0); + final double f01 = matrix1.get(0, 1); + final double f02 = matrix1.get(0, 2); + final double f03 = matrix1.get(0, 3); + final double s00 = matrix2.get(0, 0); + output.set(0, 0, f00 * s00); + output.set(0, 1, f01 * s00); + output.set(0, 2, f02 * s00); + output.set(0, 3, f03 * s00); + return output; + } + + private static IMatrixSetterDouble multiplyMatrix4x1x2(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final double f00 = matrix1.get(0, 0); + final double f01 = matrix1.get(0, 1); + final double f02 = matrix1.get(0, 2); + final double f03 = matrix1.get(0, 3); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(0, 1, f01 * s00); + output.set(1, 1, f01 * s10); + output.set(0, 2, f02 * s00); + output.set(1, 2, f02 * s10); + output.set(0, 3, f03 * s00); + output.set(1, 3, f03 * s10); + return output; + } + + private static IMatrixSetterDouble multiplyMatrix4x1x3(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final double f00 = matrix1.get(0, 0); + final double f01 = matrix1.get(0, 1); + final double f02 = matrix1.get(0, 2); + final double f03 = matrix1.get(0, 3); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(2, 0, f00 * s20); + output.set(0, 1, f01 * s00); + output.set(1, 1, f01 * s10); + output.set(2, 1, f01 * s20); + output.set(0, 2, f02 * s00); + output.set(1, 2, f02 * s10); + output.set(2, 2, f02 * s20); + output.set(0, 3, f03 * s00); + output.set(1, 3, f03 * s10); + output.set(2, 3, f03 * s20); + return output; + } + + private static IMatrixSetterDouble multiplyMatrix4x1x4(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final double f00 = matrix1.get(0, 0); + final double f01 = matrix1.get(0, 1); + final double f02 = matrix1.get(0, 2); + final double f03 = matrix1.get(0, 3); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + final double s30 = matrix2.get(3, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(2, 0, f00 * s20); + output.set(3, 0, f00 * s30); + output.set(0, 1, f01 * s00); + output.set(1, 1, f01 * s10); + output.set(2, 1, f01 * s20); + output.set(3, 1, f01 * s30); + output.set(0, 2, f02 * s00); + output.set(1, 2, f02 * s10); + output.set(2, 2, f02 * s20); + output.set(3, 2, f02 * s30); + output.set(0, 3, f03 * s00); + output.set(1, 3, f03 * s10); + output.set(2, 3, f03 * s20); + output.set(3, 3, f03 * s30); + return output; + } + + private static IMatrixSetterDouble multiplyMatrix4x1x5(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final double f00 = matrix1.get(0, 0); + final double f01 = matrix1.get(0, 1); + final double f02 = matrix1.get(0, 2); + final double f03 = matrix1.get(0, 3); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + final double s30 = matrix2.get(3, 0); + final double s40 = matrix2.get(4, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(2, 0, f00 * s20); + output.set(3, 0, f00 * s30); + output.set(4, 0, f00 * s40); + output.set(0, 1, f01 * s00); + output.set(1, 1, f01 * s10); + output.set(2, 1, f01 * s20); + output.set(3, 1, f01 * s30); + output.set(4, 1, f01 * s40); + output.set(0, 2, f02 * s00); + output.set(1, 2, f02 * s10); + output.set(2, 2, f02 * s20); + output.set(3, 2, f02 * s30); + output.set(4, 2, f02 * s40); + output.set(0, 3, f03 * s00); + output.set(1, 3, f03 * s10); + output.set(2, 3, f03 * s20); + output.set(3, 3, f03 * s30); + output.set(4, 3, f03 * s40); + return output; + } + + private static IMatrixSetterDouble multiplyMatrix5x1x1(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final double f00 = matrix1.get(0, 0); + final double f01 = matrix1.get(0, 1); + final double f02 = matrix1.get(0, 2); + final double f03 = matrix1.get(0, 3); + final double f04 = matrix1.get(0, 4); + final double s00 = matrix2.get(0, 0); + output.set(0, 0, f00 * s00); + output.set(0, 1, f01 * s00); + output.set(0, 2, f02 * s00); + output.set(0, 3, f03 * s00); + output.set(0, 4, f04 * s00); + return output; + } + + private static IMatrixSetterDouble multiplyMatrix5x1x2(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final double f00 = matrix1.get(0, 0); + final double f01 = matrix1.get(0, 1); + final double f02 = matrix1.get(0, 2); + final double f03 = matrix1.get(0, 3); + final double f04 = matrix1.get(0, 4); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(0, 1, f01 * s00); + output.set(1, 1, f01 * s10); + output.set(0, 2, f02 * s00); + output.set(1, 2, f02 * s10); + output.set(0, 3, f03 * s00); + output.set(1, 3, f03 * s10); + output.set(0, 4, f04 * s00); + output.set(1, 4, f04 * s10); + return output; + } + + private static IMatrixSetterDouble multiplyMatrix5x1x3(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final double f00 = matrix1.get(0, 0); + final double f01 = matrix1.get(0, 1); + final double f02 = matrix1.get(0, 2); + final double f03 = matrix1.get(0, 3); + final double f04 = matrix1.get(0, 4); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(2, 0, f00 * s20); + output.set(0, 1, f01 * s00); + output.set(1, 1, f01 * s10); + output.set(2, 1, f01 * s20); + output.set(0, 2, f02 * s00); + output.set(1, 2, f02 * s10); + output.set(2, 2, f02 * s20); + output.set(0, 3, f03 * s00); + output.set(1, 3, f03 * s10); + output.set(2, 3, f03 * s20); + output.set(0, 4, f04 * s00); + output.set(1, 4, f04 * s10); + output.set(2, 4, f04 * s20); + return output; + } + + private static IMatrixSetterDouble multiplyMatrix5x1x4(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final double f00 = matrix1.get(0, 0); + final double f01 = matrix1.get(0, 1); + final double f02 = matrix1.get(0, 2); + final double f03 = matrix1.get(0, 3); + final double f04 = matrix1.get(0, 4); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + final double s30 = matrix2.get(3, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(2, 0, f00 * s20); + output.set(3, 0, f00 * s30); + output.set(0, 1, f01 * s00); + output.set(1, 1, f01 * s10); + output.set(2, 1, f01 * s20); + output.set(3, 1, f01 * s30); + output.set(0, 2, f02 * s00); + output.set(1, 2, f02 * s10); + output.set(2, 2, f02 * s20); + output.set(3, 2, f02 * s30); + output.set(0, 3, f03 * s00); + output.set(1, 3, f03 * s10); + output.set(2, 3, f03 * s20); + output.set(3, 3, f03 * s30); + output.set(0, 4, f04 * s00); + output.set(1, 4, f04 * s10); + output.set(2, 4, f04 * s20); + output.set(3, 4, f04 * s30); + return output; + } + + private static IMatrixSetterDouble multiplyMatrix5x1x5(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final double f00 = matrix1.get(0, 0); + final double f01 = matrix1.get(0, 1); + final double f02 = matrix1.get(0, 2); + final double f03 = matrix1.get(0, 3); + final double f04 = matrix1.get(0, 4); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + final double s30 = matrix2.get(3, 0); + final double s40 = matrix2.get(4, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(2, 0, f00 * s20); + output.set(3, 0, f00 * s30); + output.set(4, 0, f00 * s40); + output.set(0, 1, f01 * s00); + output.set(1, 1, f01 * s10); + output.set(2, 1, f01 * s20); + output.set(3, 1, f01 * s30); + output.set(4, 1, f01 * s40); + output.set(0, 2, f02 * s00); + output.set(1, 2, f02 * s10); + output.set(2, 2, f02 * s20); + output.set(3, 2, f02 * s30); + output.set(4, 2, f02 * s40); + output.set(0, 3, f03 * s00); + output.set(1, 3, f03 * s10); + output.set(2, 3, f03 * s20); + output.set(3, 3, f03 * s30); + output.set(4, 3, f03 * s40); + output.set(0, 4, f04 * s00); + output.set(1, 4, f04 * s10); + output.set(2, 4, f04 * s20); + output.set(3, 4, f04 * s30); + output.set(4, 4, f04 * s40); + return output; + } + + private static IMatrixSetterDouble multiplyMatrix1x2x1(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double s00 = matrix2.get(0, 0); + final double s01 = matrix2.get(0, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + return output; + } + + private static IMatrixSetterDouble multiplyMatrix1x2x2(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + return output; + } + + private static IMatrixSetterDouble multiplyMatrix1x2x3(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s21 = matrix2.get(2, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(2, 0, f00 * s20 + f10 * s21); + return output; + } + + private static IMatrixSetterDouble multiplyMatrix1x2x4(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + final double s30 = matrix2.get(3, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s21 = matrix2.get(2, 1); + final double s31 = matrix2.get(3, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(2, 0, f00 * s20 + f10 * s21); + output.set(3, 0, f00 * s30 + f10 * s31); + return output; + } + + private static IMatrixSetterDouble multiplyMatrix1x2x5(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + final double s30 = matrix2.get(3, 0); + final double s40 = matrix2.get(4, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s21 = matrix2.get(2, 1); + final double s31 = matrix2.get(3, 1); + final double s41 = matrix2.get(4, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(2, 0, f00 * s20 + f10 * s21); + output.set(3, 0, f00 * s30 + f10 * s31); + output.set(4, 0, f00 * s40 + f10 * s41); + return output; + } + + private static IMatrixSetterDouble multiplyMatrix2x2x1(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double s00 = matrix2.get(0, 0); + final double s01 = matrix2.get(0, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(0, 1, f01 * s00 + f11 * s01); + return output; + } private static IMatrixSetterDouble multiplyMatrix2x2x2(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final double f_c00 = matrix1.get(0, 0); - final double f_c10 = matrix1.get(1, 0); - final double f_c01 = matrix1.get(0, 1); - final double f_c11 = matrix1.get(1, 1); - final double s_c00 = matrix2.get(0, 0); - final double s_c10 = matrix2.get(1, 0); - final double s_c01 = matrix2.get(0, 1); - final double s_c11 = matrix2.get(1, 1); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(1, 1, f01 * s10 + f11 * s11); return output; } private static IMatrixSetterDouble multiplyMatrix2x2x3(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final double f_c00 = matrix1.get(0, 0); - final double f_c10 = matrix1.get(1, 0); - final double f_c01 = matrix1.get(0, 1); - final double f_c11 = matrix1.get(1, 1); - final double s_c00 = matrix2.get(0, 0); - final double s_c10 = matrix2.get(1, 0); - final double s_c20 = matrix2.get(2, 0); - final double s_c01 = matrix2.get(0, 1); - final double s_c11 = matrix2.get(1, 1); - final double s_c21 = matrix2.get(2, 1); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s21 = matrix2.get(2, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(2, 0, f00 * s20 + f10 * s21); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(1, 1, f01 * s10 + f11 * s11); + output.set(2, 1, f01 * s20 + f11 * s21); return output; } private static IMatrixSetterDouble multiplyMatrix2x2x4(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final double f_c00 = matrix1.get(0, 0); - final double f_c10 = matrix1.get(1, 0); - final double f_c01 = matrix1.get(0, 1); - final double f_c11 = matrix1.get(1, 1); - final double s_c00 = matrix2.get(0, 0); - final double s_c10 = matrix2.get(1, 0); - final double s_c20 = matrix2.get(2, 0); - final double s_c30 = matrix2.get(3, 0); - final double s_c01 = matrix2.get(0, 1); - final double s_c11 = matrix2.get(1, 1); - final double s_c21 = matrix2.get(2, 1); - final double s_c31 = matrix2.get(3, 1); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + final double s30 = matrix2.get(3, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s21 = matrix2.get(2, 1); + final double s31 = matrix2.get(3, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(2, 0, f00 * s20 + f10 * s21); + output.set(3, 0, f00 * s30 + f10 * s31); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(1, 1, f01 * s10 + f11 * s11); + output.set(2, 1, f01 * s20 + f11 * s21); + output.set(3, 1, f01 * s30 + f11 * s31); return output; } private static IMatrixSetterDouble multiplyMatrix2x2x5(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final double f_c00 = matrix1.get(0, 0); - final double f_c10 = matrix1.get(1, 0); - final double f_c01 = matrix1.get(0, 1); - final double f_c11 = matrix1.get(1, 1); - final double s_c00 = matrix2.get(0, 0); - final double s_c10 = matrix2.get(1, 0); - final double s_c20 = matrix2.get(2, 0); - final double s_c30 = matrix2.get(3, 0); - final double s_c40 = matrix2.get(4, 0); - final double s_c01 = matrix2.get(0, 1); - final double s_c11 = matrix2.get(1, 1); - final double s_c21 = matrix2.get(2, 1); - final double s_c31 = matrix2.get(3, 1); - final double s_c41 = matrix2.get(4, 1); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31); - output.set(4, 0, f_c00*s_c40 + f_c10*s_c41); - output.set(4, 1, f_c01*s_c40 + f_c11*s_c41); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + final double s30 = matrix2.get(3, 0); + final double s40 = matrix2.get(4, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s21 = matrix2.get(2, 1); + final double s31 = matrix2.get(3, 1); + final double s41 = matrix2.get(4, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(2, 0, f00 * s20 + f10 * s21); + output.set(3, 0, f00 * s30 + f10 * s31); + output.set(4, 0, f00 * s40 + f10 * s41); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(1, 1, f01 * s10 + f11 * s11); + output.set(2, 1, f01 * s20 + f11 * s21); + output.set(3, 1, f01 * s30 + f11 * s31); + output.set(4, 1, f01 * s40 + f11 * s41); + return output; + } + + private static IMatrixSetterDouble multiplyMatrix3x2x1(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f02 = matrix1.get(0, 2); + final double f12 = matrix1.get(1, 2); + final double s00 = matrix2.get(0, 0); + final double s01 = matrix2.get(0, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(0, 2, f02 * s00 + f12 * s01); return output; } private static IMatrixSetterDouble multiplyMatrix3x2x2(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final double f_c00 = matrix1.get(0, 0); - final double f_c10 = matrix1.get(1, 0); - final double f_c01 = matrix1.get(0, 1); - final double f_c11 = matrix1.get(1, 1); - final double f_c02 = matrix1.get(0, 2); - final double f_c12 = matrix1.get(1, 2); - final double s_c00 = matrix2.get(0, 0); - final double s_c10 = matrix2.get(1, 0); - final double s_c01 = matrix2.get(0, 1); - final double s_c11 = matrix2.get(1, 1); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f02 = matrix1.get(0, 2); + final double f12 = matrix1.get(1, 2); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(1, 1, f01 * s10 + f11 * s11); + output.set(0, 2, f02 * s00 + f12 * s01); + output.set(1, 2, f02 * s10 + f12 * s11); return output; } private static IMatrixSetterDouble multiplyMatrix3x2x3(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final double f_c00 = matrix1.get(0, 0); - final double f_c10 = matrix1.get(1, 0); - final double f_c01 = matrix1.get(0, 1); - final double f_c11 = matrix1.get(1, 1); - final double f_c02 = matrix1.get(0, 2); - final double f_c12 = matrix1.get(1, 2); - final double s_c00 = matrix2.get(0, 0); - final double s_c10 = matrix2.get(1, 0); - final double s_c20 = matrix2.get(2, 0); - final double s_c01 = matrix2.get(0, 1); - final double s_c11 = matrix2.get(1, 1); - final double s_c21 = matrix2.get(2, 1); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f02 = matrix1.get(0, 2); + final double f12 = matrix1.get(1, 2); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s21 = matrix2.get(2, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(2, 0, f00 * s20 + f10 * s21); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(1, 1, f01 * s10 + f11 * s11); + output.set(2, 1, f01 * s20 + f11 * s21); + output.set(0, 2, f02 * s00 + f12 * s01); + output.set(1, 2, f02 * s10 + f12 * s11); + output.set(2, 2, f02 * s20 + f12 * s21); return output; } private static IMatrixSetterDouble multiplyMatrix3x2x4(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final double f_c00 = matrix1.get(0, 0); - final double f_c10 = matrix1.get(1, 0); - final double f_c01 = matrix1.get(0, 1); - final double f_c11 = matrix1.get(1, 1); - final double f_c02 = matrix1.get(0, 2); - final double f_c12 = matrix1.get(1, 2); - final double s_c00 = matrix2.get(0, 0); - final double s_c10 = matrix2.get(1, 0); - final double s_c20 = matrix2.get(2, 0); - final double s_c30 = matrix2.get(3, 0); - final double s_c01 = matrix2.get(0, 1); - final double s_c11 = matrix2.get(1, 1); - final double s_c21 = matrix2.get(2, 1); - final double s_c31 = matrix2.get(3, 1); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f02 = matrix1.get(0, 2); + final double f12 = matrix1.get(1, 2); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + final double s30 = matrix2.get(3, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s21 = matrix2.get(2, 1); + final double s31 = matrix2.get(3, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(2, 0, f00 * s20 + f10 * s21); + output.set(3, 0, f00 * s30 + f10 * s31); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(1, 1, f01 * s10 + f11 * s11); + output.set(2, 1, f01 * s20 + f11 * s21); + output.set(3, 1, f01 * s30 + f11 * s31); + output.set(0, 2, f02 * s00 + f12 * s01); + output.set(1, 2, f02 * s10 + f12 * s11); + output.set(2, 2, f02 * s20 + f12 * s21); + output.set(3, 2, f02 * s30 + f12 * s31); return output; } private static IMatrixSetterDouble multiplyMatrix3x2x5(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final double f_c00 = matrix1.get(0, 0); - final double f_c10 = matrix1.get(1, 0); - final double f_c01 = matrix1.get(0, 1); - final double f_c11 = matrix1.get(1, 1); - final double f_c02 = matrix1.get(0, 2); - final double f_c12 = matrix1.get(1, 2); - final double s_c00 = matrix2.get(0, 0); - final double s_c10 = matrix2.get(1, 0); - final double s_c20 = matrix2.get(2, 0); - final double s_c30 = matrix2.get(3, 0); - final double s_c40 = matrix2.get(4, 0); - final double s_c01 = matrix2.get(0, 1); - final double s_c11 = matrix2.get(1, 1); - final double s_c21 = matrix2.get(2, 1); - final double s_c31 = matrix2.get(3, 1); - final double s_c41 = matrix2.get(4, 1); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31); - output.set(4, 0, f_c00*s_c40 + f_c10*s_c41); - output.set(4, 1, f_c01*s_c40 + f_c11*s_c41); - output.set(4, 2, f_c02*s_c40 + f_c12*s_c41); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f02 = matrix1.get(0, 2); + final double f12 = matrix1.get(1, 2); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + final double s30 = matrix2.get(3, 0); + final double s40 = matrix2.get(4, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s21 = matrix2.get(2, 1); + final double s31 = matrix2.get(3, 1); + final double s41 = matrix2.get(4, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(2, 0, f00 * s20 + f10 * s21); + output.set(3, 0, f00 * s30 + f10 * s31); + output.set(4, 0, f00 * s40 + f10 * s41); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(1, 1, f01 * s10 + f11 * s11); + output.set(2, 1, f01 * s20 + f11 * s21); + output.set(3, 1, f01 * s30 + f11 * s31); + output.set(4, 1, f01 * s40 + f11 * s41); + output.set(0, 2, f02 * s00 + f12 * s01); + output.set(1, 2, f02 * s10 + f12 * s11); + output.set(2, 2, f02 * s20 + f12 * s21); + output.set(3, 2, f02 * s30 + f12 * s31); + output.set(4, 2, f02 * s40 + f12 * s41); + return output; + } + + private static IMatrixSetterDouble multiplyMatrix4x2x1(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f02 = matrix1.get(0, 2); + final double f12 = matrix1.get(1, 2); + final double f03 = matrix1.get(0, 3); + final double f13 = matrix1.get(1, 3); + final double s00 = matrix2.get(0, 0); + final double s01 = matrix2.get(0, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(0, 2, f02 * s00 + f12 * s01); + output.set(0, 3, f03 * s00 + f13 * s01); return output; } private static IMatrixSetterDouble multiplyMatrix4x2x2(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final double f_c00 = matrix1.get(0, 0); - final double f_c10 = matrix1.get(1, 0); - final double f_c01 = matrix1.get(0, 1); - final double f_c11 = matrix1.get(1, 1); - final double f_c02 = matrix1.get(0, 2); - final double f_c12 = matrix1.get(1, 2); - final double f_c03 = matrix1.get(0, 3); - final double f_c13 = matrix1.get(1, 3); - final double s_c00 = matrix2.get(0, 0); - final double s_c10 = matrix2.get(1, 0); - final double s_c01 = matrix2.get(0, 1); - final double s_c11 = matrix2.get(1, 1); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f02 = matrix1.get(0, 2); + final double f12 = matrix1.get(1, 2); + final double f03 = matrix1.get(0, 3); + final double f13 = matrix1.get(1, 3); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(1, 1, f01 * s10 + f11 * s11); + output.set(0, 2, f02 * s00 + f12 * s01); + output.set(1, 2, f02 * s10 + f12 * s11); + output.set(0, 3, f03 * s00 + f13 * s01); + output.set(1, 3, f03 * s10 + f13 * s11); return output; } private static IMatrixSetterDouble multiplyMatrix4x2x3(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final double f_c00 = matrix1.get(0, 0); - final double f_c10 = matrix1.get(1, 0); - final double f_c01 = matrix1.get(0, 1); - final double f_c11 = matrix1.get(1, 1); - final double f_c02 = matrix1.get(0, 2); - final double f_c12 = matrix1.get(1, 2); - final double f_c03 = matrix1.get(0, 3); - final double f_c13 = matrix1.get(1, 3); - final double s_c00 = matrix2.get(0, 0); - final double s_c10 = matrix2.get(1, 0); - final double s_c20 = matrix2.get(2, 0); - final double s_c01 = matrix2.get(0, 1); - final double s_c11 = matrix2.get(1, 1); - final double s_c21 = matrix2.get(2, 1); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f02 = matrix1.get(0, 2); + final double f12 = matrix1.get(1, 2); + final double f03 = matrix1.get(0, 3); + final double f13 = matrix1.get(1, 3); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s21 = matrix2.get(2, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(2, 0, f00 * s20 + f10 * s21); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(1, 1, f01 * s10 + f11 * s11); + output.set(2, 1, f01 * s20 + f11 * s21); + output.set(0, 2, f02 * s00 + f12 * s01); + output.set(1, 2, f02 * s10 + f12 * s11); + output.set(2, 2, f02 * s20 + f12 * s21); + output.set(0, 3, f03 * s00 + f13 * s01); + output.set(1, 3, f03 * s10 + f13 * s11); + output.set(2, 3, f03 * s20 + f13 * s21); return output; } private static IMatrixSetterDouble multiplyMatrix4x2x4(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final double f_c00 = matrix1.get(0, 0); - final double f_c10 = matrix1.get(1, 0); - final double f_c01 = matrix1.get(0, 1); - final double f_c11 = matrix1.get(1, 1); - final double f_c02 = matrix1.get(0, 2); - final double f_c12 = matrix1.get(1, 2); - final double f_c03 = matrix1.get(0, 3); - final double f_c13 = matrix1.get(1, 3); - final double s_c00 = matrix2.get(0, 0); - final double s_c10 = matrix2.get(1, 0); - final double s_c20 = matrix2.get(2, 0); - final double s_c30 = matrix2.get(3, 0); - final double s_c01 = matrix2.get(0, 1); - final double s_c11 = matrix2.get(1, 1); - final double s_c21 = matrix2.get(2, 1); - final double s_c31 = matrix2.get(3, 1); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31); - output.set(3, 3, f_c03*s_c30 + f_c13*s_c31); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f02 = matrix1.get(0, 2); + final double f12 = matrix1.get(1, 2); + final double f03 = matrix1.get(0, 3); + final double f13 = matrix1.get(1, 3); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + final double s30 = matrix2.get(3, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s21 = matrix2.get(2, 1); + final double s31 = matrix2.get(3, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(2, 0, f00 * s20 + f10 * s21); + output.set(3, 0, f00 * s30 + f10 * s31); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(1, 1, f01 * s10 + f11 * s11); + output.set(2, 1, f01 * s20 + f11 * s21); + output.set(3, 1, f01 * s30 + f11 * s31); + output.set(0, 2, f02 * s00 + f12 * s01); + output.set(1, 2, f02 * s10 + f12 * s11); + output.set(2, 2, f02 * s20 + f12 * s21); + output.set(3, 2, f02 * s30 + f12 * s31); + output.set(0, 3, f03 * s00 + f13 * s01); + output.set(1, 3, f03 * s10 + f13 * s11); + output.set(2, 3, f03 * s20 + f13 * s21); + output.set(3, 3, f03 * s30 + f13 * s31); return output; } private static IMatrixSetterDouble multiplyMatrix4x2x5(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final double f_c00 = matrix1.get(0, 0); - final double f_c10 = matrix1.get(1, 0); - final double f_c01 = matrix1.get(0, 1); - final double f_c11 = matrix1.get(1, 1); - final double f_c02 = matrix1.get(0, 2); - final double f_c12 = matrix1.get(1, 2); - final double f_c03 = matrix1.get(0, 3); - final double f_c13 = matrix1.get(1, 3); - final double s_c00 = matrix2.get(0, 0); - final double s_c10 = matrix2.get(1, 0); - final double s_c20 = matrix2.get(2, 0); - final double s_c30 = matrix2.get(3, 0); - final double s_c40 = matrix2.get(4, 0); - final double s_c01 = matrix2.get(0, 1); - final double s_c11 = matrix2.get(1, 1); - final double s_c21 = matrix2.get(2, 1); - final double s_c31 = matrix2.get(3, 1); - final double s_c41 = matrix2.get(4, 1); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31); - output.set(3, 3, f_c03*s_c30 + f_c13*s_c31); - output.set(4, 0, f_c00*s_c40 + f_c10*s_c41); - output.set(4, 1, f_c01*s_c40 + f_c11*s_c41); - output.set(4, 2, f_c02*s_c40 + f_c12*s_c41); - output.set(4, 3, f_c03*s_c40 + f_c13*s_c41); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f02 = matrix1.get(0, 2); + final double f12 = matrix1.get(1, 2); + final double f03 = matrix1.get(0, 3); + final double f13 = matrix1.get(1, 3); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + final double s30 = matrix2.get(3, 0); + final double s40 = matrix2.get(4, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s21 = matrix2.get(2, 1); + final double s31 = matrix2.get(3, 1); + final double s41 = matrix2.get(4, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(2, 0, f00 * s20 + f10 * s21); + output.set(3, 0, f00 * s30 + f10 * s31); + output.set(4, 0, f00 * s40 + f10 * s41); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(1, 1, f01 * s10 + f11 * s11); + output.set(2, 1, f01 * s20 + f11 * s21); + output.set(3, 1, f01 * s30 + f11 * s31); + output.set(4, 1, f01 * s40 + f11 * s41); + output.set(0, 2, f02 * s00 + f12 * s01); + output.set(1, 2, f02 * s10 + f12 * s11); + output.set(2, 2, f02 * s20 + f12 * s21); + output.set(3, 2, f02 * s30 + f12 * s31); + output.set(4, 2, f02 * s40 + f12 * s41); + output.set(0, 3, f03 * s00 + f13 * s01); + output.set(1, 3, f03 * s10 + f13 * s11); + output.set(2, 3, f03 * s20 + f13 * s21); + output.set(3, 3, f03 * s30 + f13 * s31); + output.set(4, 3, f03 * s40 + f13 * s41); + return output; + } + + private static IMatrixSetterDouble multiplyMatrix5x2x1(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f02 = matrix1.get(0, 2); + final double f12 = matrix1.get(1, 2); + final double f03 = matrix1.get(0, 3); + final double f13 = matrix1.get(1, 3); + final double f04 = matrix1.get(0, 4); + final double f14 = matrix1.get(1, 4); + final double s00 = matrix2.get(0, 0); + final double s01 = matrix2.get(0, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(0, 2, f02 * s00 + f12 * s01); + output.set(0, 3, f03 * s00 + f13 * s01); + output.set(0, 4, f04 * s00 + f14 * s01); return output; } private static IMatrixSetterDouble multiplyMatrix5x2x2(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final double f_c00 = matrix1.get(0, 0); - final double f_c10 = matrix1.get(1, 0); - final double f_c01 = matrix1.get(0, 1); - final double f_c11 = matrix1.get(1, 1); - final double f_c02 = matrix1.get(0, 2); - final double f_c12 = matrix1.get(1, 2); - final double f_c03 = matrix1.get(0, 3); - final double f_c13 = matrix1.get(1, 3); - final double f_c04 = matrix1.get(0, 4); - final double f_c14 = matrix1.get(1, 4); - final double s_c00 = matrix2.get(0, 0); - final double s_c10 = matrix2.get(1, 0); - final double s_c01 = matrix2.get(0, 1); - final double s_c11 = matrix2.get(1, 1); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01); - output.set(0, 4, f_c04*s_c00 + f_c14*s_c01); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11); - output.set(1, 4, f_c04*s_c10 + f_c14*s_c11); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f02 = matrix1.get(0, 2); + final double f12 = matrix1.get(1, 2); + final double f03 = matrix1.get(0, 3); + final double f13 = matrix1.get(1, 3); + final double f04 = matrix1.get(0, 4); + final double f14 = matrix1.get(1, 4); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(1, 1, f01 * s10 + f11 * s11); + output.set(0, 2, f02 * s00 + f12 * s01); + output.set(1, 2, f02 * s10 + f12 * s11); + output.set(0, 3, f03 * s00 + f13 * s01); + output.set(1, 3, f03 * s10 + f13 * s11); + output.set(0, 4, f04 * s00 + f14 * s01); + output.set(1, 4, f04 * s10 + f14 * s11); return output; } private static IMatrixSetterDouble multiplyMatrix5x2x3(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final double f_c00 = matrix1.get(0, 0); - final double f_c10 = matrix1.get(1, 0); - final double f_c01 = matrix1.get(0, 1); - final double f_c11 = matrix1.get(1, 1); - final double f_c02 = matrix1.get(0, 2); - final double f_c12 = matrix1.get(1, 2); - final double f_c03 = matrix1.get(0, 3); - final double f_c13 = matrix1.get(1, 3); - final double f_c04 = matrix1.get(0, 4); - final double f_c14 = matrix1.get(1, 4); - final double s_c00 = matrix2.get(0, 0); - final double s_c10 = matrix2.get(1, 0); - final double s_c20 = matrix2.get(2, 0); - final double s_c01 = matrix2.get(0, 1); - final double s_c11 = matrix2.get(1, 1); - final double s_c21 = matrix2.get(2, 1); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01); - output.set(0, 4, f_c04*s_c00 + f_c14*s_c01); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11); - output.set(1, 4, f_c04*s_c10 + f_c14*s_c11); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21); - output.set(2, 4, f_c04*s_c20 + f_c14*s_c21); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f02 = matrix1.get(0, 2); + final double f12 = matrix1.get(1, 2); + final double f03 = matrix1.get(0, 3); + final double f13 = matrix1.get(1, 3); + final double f04 = matrix1.get(0, 4); + final double f14 = matrix1.get(1, 4); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s21 = matrix2.get(2, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(2, 0, f00 * s20 + f10 * s21); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(1, 1, f01 * s10 + f11 * s11); + output.set(2, 1, f01 * s20 + f11 * s21); + output.set(0, 2, f02 * s00 + f12 * s01); + output.set(1, 2, f02 * s10 + f12 * s11); + output.set(2, 2, f02 * s20 + f12 * s21); + output.set(0, 3, f03 * s00 + f13 * s01); + output.set(1, 3, f03 * s10 + f13 * s11); + output.set(2, 3, f03 * s20 + f13 * s21); + output.set(0, 4, f04 * s00 + f14 * s01); + output.set(1, 4, f04 * s10 + f14 * s11); + output.set(2, 4, f04 * s20 + f14 * s21); return output; } private static IMatrixSetterDouble multiplyMatrix5x2x4(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final double f_c00 = matrix1.get(0, 0); - final double f_c10 = matrix1.get(1, 0); - final double f_c01 = matrix1.get(0, 1); - final double f_c11 = matrix1.get(1, 1); - final double f_c02 = matrix1.get(0, 2); - final double f_c12 = matrix1.get(1, 2); - final double f_c03 = matrix1.get(0, 3); - final double f_c13 = matrix1.get(1, 3); - final double f_c04 = matrix1.get(0, 4); - final double f_c14 = matrix1.get(1, 4); - final double s_c00 = matrix2.get(0, 0); - final double s_c10 = matrix2.get(1, 0); - final double s_c20 = matrix2.get(2, 0); - final double s_c30 = matrix2.get(3, 0); - final double s_c01 = matrix2.get(0, 1); - final double s_c11 = matrix2.get(1, 1); - final double s_c21 = matrix2.get(2, 1); - final double s_c31 = matrix2.get(3, 1); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01); - output.set(0, 4, f_c04*s_c00 + f_c14*s_c01); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11); - output.set(1, 4, f_c04*s_c10 + f_c14*s_c11); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21); - output.set(2, 4, f_c04*s_c20 + f_c14*s_c21); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31); - output.set(3, 3, f_c03*s_c30 + f_c13*s_c31); - output.set(3, 4, f_c04*s_c30 + f_c14*s_c31); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f02 = matrix1.get(0, 2); + final double f12 = matrix1.get(1, 2); + final double f03 = matrix1.get(0, 3); + final double f13 = matrix1.get(1, 3); + final double f04 = matrix1.get(0, 4); + final double f14 = matrix1.get(1, 4); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + final double s30 = matrix2.get(3, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s21 = matrix2.get(2, 1); + final double s31 = matrix2.get(3, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(2, 0, f00 * s20 + f10 * s21); + output.set(3, 0, f00 * s30 + f10 * s31); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(1, 1, f01 * s10 + f11 * s11); + output.set(2, 1, f01 * s20 + f11 * s21); + output.set(3, 1, f01 * s30 + f11 * s31); + output.set(0, 2, f02 * s00 + f12 * s01); + output.set(1, 2, f02 * s10 + f12 * s11); + output.set(2, 2, f02 * s20 + f12 * s21); + output.set(3, 2, f02 * s30 + f12 * s31); + output.set(0, 3, f03 * s00 + f13 * s01); + output.set(1, 3, f03 * s10 + f13 * s11); + output.set(2, 3, f03 * s20 + f13 * s21); + output.set(3, 3, f03 * s30 + f13 * s31); + output.set(0, 4, f04 * s00 + f14 * s01); + output.set(1, 4, f04 * s10 + f14 * s11); + output.set(2, 4, f04 * s20 + f14 * s21); + output.set(3, 4, f04 * s30 + f14 * s31); return output; } private static IMatrixSetterDouble multiplyMatrix5x2x5(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final double f_c00 = matrix1.get(0, 0); - final double f_c10 = matrix1.get(1, 0); - final double f_c01 = matrix1.get(0, 1); - final double f_c11 = matrix1.get(1, 1); - final double f_c02 = matrix1.get(0, 2); - final double f_c12 = matrix1.get(1, 2); - final double f_c03 = matrix1.get(0, 3); - final double f_c13 = matrix1.get(1, 3); - final double f_c04 = matrix1.get(0, 4); - final double f_c14 = matrix1.get(1, 4); - final double s_c00 = matrix2.get(0, 0); - final double s_c10 = matrix2.get(1, 0); - final double s_c20 = matrix2.get(2, 0); - final double s_c30 = matrix2.get(3, 0); - final double s_c40 = matrix2.get(4, 0); - final double s_c01 = matrix2.get(0, 1); - final double s_c11 = matrix2.get(1, 1); - final double s_c21 = matrix2.get(2, 1); - final double s_c31 = matrix2.get(3, 1); - final double s_c41 = matrix2.get(4, 1); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01); - output.set(0, 4, f_c04*s_c00 + f_c14*s_c01); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11); - output.set(1, 4, f_c04*s_c10 + f_c14*s_c11); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21); - output.set(2, 4, f_c04*s_c20 + f_c14*s_c21); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31); - output.set(3, 3, f_c03*s_c30 + f_c13*s_c31); - output.set(3, 4, f_c04*s_c30 + f_c14*s_c31); - output.set(4, 0, f_c00*s_c40 + f_c10*s_c41); - output.set(4, 1, f_c01*s_c40 + f_c11*s_c41); - output.set(4, 2, f_c02*s_c40 + f_c12*s_c41); - output.set(4, 3, f_c03*s_c40 + f_c13*s_c41); - output.set(4, 4, f_c04*s_c40 + f_c14*s_c41); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f02 = matrix1.get(0, 2); + final double f12 = matrix1.get(1, 2); + final double f03 = matrix1.get(0, 3); + final double f13 = matrix1.get(1, 3); + final double f04 = matrix1.get(0, 4); + final double f14 = matrix1.get(1, 4); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + final double s30 = matrix2.get(3, 0); + final double s40 = matrix2.get(4, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s21 = matrix2.get(2, 1); + final double s31 = matrix2.get(3, 1); + final double s41 = matrix2.get(4, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(2, 0, f00 * s20 + f10 * s21); + output.set(3, 0, f00 * s30 + f10 * s31); + output.set(4, 0, f00 * s40 + f10 * s41); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(1, 1, f01 * s10 + f11 * s11); + output.set(2, 1, f01 * s20 + f11 * s21); + output.set(3, 1, f01 * s30 + f11 * s31); + output.set(4, 1, f01 * s40 + f11 * s41); + output.set(0, 2, f02 * s00 + f12 * s01); + output.set(1, 2, f02 * s10 + f12 * s11); + output.set(2, 2, f02 * s20 + f12 * s21); + output.set(3, 2, f02 * s30 + f12 * s31); + output.set(4, 2, f02 * s40 + f12 * s41); + output.set(0, 3, f03 * s00 + f13 * s01); + output.set(1, 3, f03 * s10 + f13 * s11); + output.set(2, 3, f03 * s20 + f13 * s21); + output.set(3, 3, f03 * s30 + f13 * s31); + output.set(4, 3, f03 * s40 + f13 * s41); + output.set(0, 4, f04 * s00 + f14 * s01); + output.set(1, 4, f04 * s10 + f14 * s11); + output.set(2, 4, f04 * s20 + f14 * s21); + output.set(3, 4, f04 * s30 + f14 * s31); + output.set(4, 4, f04 * s40 + f14 * s41); + return output; + } + + private static IMatrixSetterDouble multiplyMatrix1x3x1(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double s00 = matrix2.get(0, 0); + final double s01 = matrix2.get(0, 1); + final double s02 = matrix2.get(0, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + return output; + } + + private static IMatrixSetterDouble multiplyMatrix1x3x2(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s02 = matrix2.get(0, 2); + final double s12 = matrix2.get(1, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + return output; + } + + private static IMatrixSetterDouble multiplyMatrix1x3x3(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s21 = matrix2.get(2, 1); + final double s02 = matrix2.get(0, 2); + final double s12 = matrix2.get(1, 2); + final double s22 = matrix2.get(2, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22); + return output; + } + + private static IMatrixSetterDouble multiplyMatrix1x3x4(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + final double s30 = matrix2.get(3, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s21 = matrix2.get(2, 1); + final double s31 = matrix2.get(3, 1); + final double s02 = matrix2.get(0, 2); + final double s12 = matrix2.get(1, 2); + final double s22 = matrix2.get(2, 2); + final double s32 = matrix2.get(3, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32); + return output; + } + + private static IMatrixSetterDouble multiplyMatrix1x3x5(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + final double s30 = matrix2.get(3, 0); + final double s40 = matrix2.get(4, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s21 = matrix2.get(2, 1); + final double s31 = matrix2.get(3, 1); + final double s41 = matrix2.get(4, 1); + final double s02 = matrix2.get(0, 2); + final double s12 = matrix2.get(1, 2); + final double s22 = matrix2.get(2, 2); + final double s32 = matrix2.get(3, 2); + final double s42 = matrix2.get(4, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32); + output.set(4, 0, f00 * s40 + f10 * s41 + f20 * s42); + return output; + } + + private static IMatrixSetterDouble multiplyMatrix2x3x1(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f21 = matrix1.get(2, 1); + final double s00 = matrix2.get(0, 0); + final double s01 = matrix2.get(0, 1); + final double s02 = matrix2.get(0, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); return output; } private static IMatrixSetterDouble multiplyMatrix2x3x2(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final double f_c00 = matrix1.get(0, 0); - final double f_c10 = matrix1.get(1, 0); - final double f_c20 = matrix1.get(2, 0); - final double f_c01 = matrix1.get(0, 1); - final double f_c11 = matrix1.get(1, 1); - final double f_c21 = matrix1.get(2, 1); - final double s_c00 = matrix2.get(0, 0); - final double s_c10 = matrix2.get(1, 0); - final double s_c01 = matrix2.get(0, 1); - final double s_c11 = matrix2.get(1, 1); - final double s_c02 = matrix2.get(0, 2); - final double s_c12 = matrix2.get(1, 2); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f21 = matrix1.get(2, 1); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s02 = matrix2.get(0, 2); + final double s12 = matrix2.get(1, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12); return output; } private static IMatrixSetterDouble multiplyMatrix2x3x3(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final double f_c00 = matrix1.get(0, 0); - final double f_c10 = matrix1.get(1, 0); - final double f_c20 = matrix1.get(2, 0); - final double f_c01 = matrix1.get(0, 1); - final double f_c11 = matrix1.get(1, 1); - final double f_c21 = matrix1.get(2, 1); - final double s_c00 = matrix2.get(0, 0); - final double s_c10 = matrix2.get(1, 0); - final double s_c20 = matrix2.get(2, 0); - final double s_c01 = matrix2.get(0, 1); - final double s_c11 = matrix2.get(1, 1); - final double s_c21 = matrix2.get(2, 1); - final double s_c02 = matrix2.get(0, 2); - final double s_c12 = matrix2.get(1, 2); - final double s_c22 = matrix2.get(2, 2); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f21 = matrix1.get(2, 1); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s21 = matrix2.get(2, 1); + final double s02 = matrix2.get(0, 2); + final double s12 = matrix2.get(1, 2); + final double s22 = matrix2.get(2, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22); return output; } private static IMatrixSetterDouble multiplyMatrix2x3x4(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final double f_c00 = matrix1.get(0, 0); - final double f_c10 = matrix1.get(1, 0); - final double f_c20 = matrix1.get(2, 0); - final double f_c01 = matrix1.get(0, 1); - final double f_c11 = matrix1.get(1, 1); - final double f_c21 = matrix1.get(2, 1); - final double s_c00 = matrix2.get(0, 0); - final double s_c10 = matrix2.get(1, 0); - final double s_c20 = matrix2.get(2, 0); - final double s_c30 = matrix2.get(3, 0); - final double s_c01 = matrix2.get(0, 1); - final double s_c11 = matrix2.get(1, 1); - final double s_c21 = matrix2.get(2, 1); - final double s_c31 = matrix2.get(3, 1); - final double s_c02 = matrix2.get(0, 2); - final double s_c12 = matrix2.get(1, 2); - final double s_c22 = matrix2.get(2, 2); - final double s_c32 = matrix2.get(3, 2); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f21 = matrix1.get(2, 1); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + final double s30 = matrix2.get(3, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s21 = matrix2.get(2, 1); + final double s31 = matrix2.get(3, 1); + final double s02 = matrix2.get(0, 2); + final double s12 = matrix2.get(1, 2); + final double s22 = matrix2.get(2, 2); + final double s32 = matrix2.get(3, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32); return output; } private static IMatrixSetterDouble multiplyMatrix2x3x5(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final double f_c00 = matrix1.get(0, 0); - final double f_c10 = matrix1.get(1, 0); - final double f_c20 = matrix1.get(2, 0); - final double f_c01 = matrix1.get(0, 1); - final double f_c11 = matrix1.get(1, 1); - final double f_c21 = matrix1.get(2, 1); - final double s_c00 = matrix2.get(0, 0); - final double s_c10 = matrix2.get(1, 0); - final double s_c20 = matrix2.get(2, 0); - final double s_c30 = matrix2.get(3, 0); - final double s_c40 = matrix2.get(4, 0); - final double s_c01 = matrix2.get(0, 1); - final double s_c11 = matrix2.get(1, 1); - final double s_c21 = matrix2.get(2, 1); - final double s_c31 = matrix2.get(3, 1); - final double s_c41 = matrix2.get(4, 1); - final double s_c02 = matrix2.get(0, 2); - final double s_c12 = matrix2.get(1, 2); - final double s_c22 = matrix2.get(2, 2); - final double s_c32 = matrix2.get(3, 2); - final double s_c42 = matrix2.get(4, 2); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32); - output.set(4, 0, f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42); - output.set(4, 1, f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f21 = matrix1.get(2, 1); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + final double s30 = matrix2.get(3, 0); + final double s40 = matrix2.get(4, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s21 = matrix2.get(2, 1); + final double s31 = matrix2.get(3, 1); + final double s41 = matrix2.get(4, 1); + final double s02 = matrix2.get(0, 2); + final double s12 = matrix2.get(1, 2); + final double s22 = matrix2.get(2, 2); + final double s32 = matrix2.get(3, 2); + final double s42 = matrix2.get(4, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32); + output.set(4, 0, f00 * s40 + f10 * s41 + f20 * s42); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32); + output.set(4, 1, f01 * s40 + f11 * s41 + f21 * s42); + return output; + } + + private static IMatrixSetterDouble multiplyMatrix3x3x1(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f21 = matrix1.get(2, 1); + final double f02 = matrix1.get(0, 2); + final double f12 = matrix1.get(1, 2); + final double f22 = matrix1.get(2, 2); + final double s00 = matrix2.get(0, 0); + final double s01 = matrix2.get(0, 1); + final double s02 = matrix2.get(0, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02); return output; } private static IMatrixSetterDouble multiplyMatrix3x3x2(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final double f_c00 = matrix1.get(0, 0); - final double f_c10 = matrix1.get(1, 0); - final double f_c20 = matrix1.get(2, 0); - final double f_c01 = matrix1.get(0, 1); - final double f_c11 = matrix1.get(1, 1); - final double f_c21 = matrix1.get(2, 1); - final double f_c02 = matrix1.get(0, 2); - final double f_c12 = matrix1.get(1, 2); - final double f_c22 = matrix1.get(2, 2); - final double s_c00 = matrix2.get(0, 0); - final double s_c10 = matrix2.get(1, 0); - final double s_c01 = matrix2.get(0, 1); - final double s_c11 = matrix2.get(1, 1); - final double s_c02 = matrix2.get(0, 2); - final double s_c12 = matrix2.get(1, 2); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f21 = matrix1.get(2, 1); + final double f02 = matrix1.get(0, 2); + final double f12 = matrix1.get(1, 2); + final double f22 = matrix1.get(2, 2); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s02 = matrix2.get(0, 2); + final double s12 = matrix2.get(1, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12); return output; } private static IMatrixSetterDouble multiplyMatrix3x3x3(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final double f_c00 = matrix1.get(0, 0); - final double f_c10 = matrix1.get(1, 0); - final double f_c20 = matrix1.get(2, 0); - final double f_c01 = matrix1.get(0, 1); - final double f_c11 = matrix1.get(1, 1); - final double f_c21 = matrix1.get(2, 1); - final double f_c02 = matrix1.get(0, 2); - final double f_c12 = matrix1.get(1, 2); - final double f_c22 = matrix1.get(2, 2); - final double s_c00 = matrix2.get(0, 0); - final double s_c10 = matrix2.get(1, 0); - final double s_c20 = matrix2.get(2, 0); - final double s_c01 = matrix2.get(0, 1); - final double s_c11 = matrix2.get(1, 1); - final double s_c21 = matrix2.get(2, 1); - final double s_c02 = matrix2.get(0, 2); - final double s_c12 = matrix2.get(1, 2); - final double s_c22 = matrix2.get(2, 2); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f21 = matrix1.get(2, 1); + final double f02 = matrix1.get(0, 2); + final double f12 = matrix1.get(1, 2); + final double f22 = matrix1.get(2, 2); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s21 = matrix2.get(2, 1); + final double s02 = matrix2.get(0, 2); + final double s12 = matrix2.get(1, 2); + final double s22 = matrix2.get(2, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22); return output; } private static IMatrixSetterDouble multiplyMatrix3x3x4(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final double f_c00 = matrix1.get(0, 0); - final double f_c10 = matrix1.get(1, 0); - final double f_c20 = matrix1.get(2, 0); - final double f_c01 = matrix1.get(0, 1); - final double f_c11 = matrix1.get(1, 1); - final double f_c21 = matrix1.get(2, 1); - final double f_c02 = matrix1.get(0, 2); - final double f_c12 = matrix1.get(1, 2); - final double f_c22 = matrix1.get(2, 2); - final double s_c00 = matrix2.get(0, 0); - final double s_c10 = matrix2.get(1, 0); - final double s_c20 = matrix2.get(2, 0); - final double s_c30 = matrix2.get(3, 0); - final double s_c01 = matrix2.get(0, 1); - final double s_c11 = matrix2.get(1, 1); - final double s_c21 = matrix2.get(2, 1); - final double s_c31 = matrix2.get(3, 1); - final double s_c02 = matrix2.get(0, 2); - final double s_c12 = matrix2.get(1, 2); - final double s_c22 = matrix2.get(2, 2); - final double s_c32 = matrix2.get(3, 2); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f21 = matrix1.get(2, 1); + final double f02 = matrix1.get(0, 2); + final double f12 = matrix1.get(1, 2); + final double f22 = matrix1.get(2, 2); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + final double s30 = matrix2.get(3, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s21 = matrix2.get(2, 1); + final double s31 = matrix2.get(3, 1); + final double s02 = matrix2.get(0, 2); + final double s12 = matrix2.get(1, 2); + final double s22 = matrix2.get(2, 2); + final double s32 = matrix2.get(3, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32); return output; } private static IMatrixSetterDouble multiplyMatrix3x3x5(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final double f_c00 = matrix1.get(0, 0); - final double f_c10 = matrix1.get(1, 0); - final double f_c20 = matrix1.get(2, 0); - final double f_c01 = matrix1.get(0, 1); - final double f_c11 = matrix1.get(1, 1); - final double f_c21 = matrix1.get(2, 1); - final double f_c02 = matrix1.get(0, 2); - final double f_c12 = matrix1.get(1, 2); - final double f_c22 = matrix1.get(2, 2); - final double s_c00 = matrix2.get(0, 0); - final double s_c10 = matrix2.get(1, 0); - final double s_c20 = matrix2.get(2, 0); - final double s_c30 = matrix2.get(3, 0); - final double s_c40 = matrix2.get(4, 0); - final double s_c01 = matrix2.get(0, 1); - final double s_c11 = matrix2.get(1, 1); - final double s_c21 = matrix2.get(2, 1); - final double s_c31 = matrix2.get(3, 1); - final double s_c41 = matrix2.get(4, 1); - final double s_c02 = matrix2.get(0, 2); - final double s_c12 = matrix2.get(1, 2); - final double s_c22 = matrix2.get(2, 2); - final double s_c32 = matrix2.get(3, 2); - final double s_c42 = matrix2.get(4, 2); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32); - output.set(4, 0, f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42); - output.set(4, 1, f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42); - output.set(4, 2, f_c02*s_c40 + f_c12*s_c41 + f_c22*s_c42); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f21 = matrix1.get(2, 1); + final double f02 = matrix1.get(0, 2); + final double f12 = matrix1.get(1, 2); + final double f22 = matrix1.get(2, 2); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + final double s30 = matrix2.get(3, 0); + final double s40 = matrix2.get(4, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s21 = matrix2.get(2, 1); + final double s31 = matrix2.get(3, 1); + final double s41 = matrix2.get(4, 1); + final double s02 = matrix2.get(0, 2); + final double s12 = matrix2.get(1, 2); + final double s22 = matrix2.get(2, 2); + final double s32 = matrix2.get(3, 2); + final double s42 = matrix2.get(4, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32); + output.set(4, 0, f00 * s40 + f10 * s41 + f20 * s42); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32); + output.set(4, 1, f01 * s40 + f11 * s41 + f21 * s42); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32); + output.set(4, 2, f02 * s40 + f12 * s41 + f22 * s42); + return output; + } + + private static IMatrixSetterDouble multiplyMatrix4x3x1(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f21 = matrix1.get(2, 1); + final double f02 = matrix1.get(0, 2); + final double f12 = matrix1.get(1, 2); + final double f22 = matrix1.get(2, 2); + final double f03 = matrix1.get(0, 3); + final double f13 = matrix1.get(1, 3); + final double f23 = matrix1.get(2, 3); + final double s00 = matrix2.get(0, 0); + final double s01 = matrix2.get(0, 1); + final double s02 = matrix2.get(0, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02); return output; } private static IMatrixSetterDouble multiplyMatrix4x3x2(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final double f_c00 = matrix1.get(0, 0); - final double f_c10 = matrix1.get(1, 0); - final double f_c20 = matrix1.get(2, 0); - final double f_c01 = matrix1.get(0, 1); - final double f_c11 = matrix1.get(1, 1); - final double f_c21 = matrix1.get(2, 1); - final double f_c02 = matrix1.get(0, 2); - final double f_c12 = matrix1.get(1, 2); - final double f_c22 = matrix1.get(2, 2); - final double f_c03 = matrix1.get(0, 3); - final double f_c13 = matrix1.get(1, 3); - final double f_c23 = matrix1.get(2, 3); - final double s_c00 = matrix2.get(0, 0); - final double s_c10 = matrix2.get(1, 0); - final double s_c01 = matrix2.get(0, 1); - final double s_c11 = matrix2.get(1, 1); - final double s_c02 = matrix2.get(0, 2); - final double s_c12 = matrix2.get(1, 2); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f21 = matrix1.get(2, 1); + final double f02 = matrix1.get(0, 2); + final double f12 = matrix1.get(1, 2); + final double f22 = matrix1.get(2, 2); + final double f03 = matrix1.get(0, 3); + final double f13 = matrix1.get(1, 3); + final double f23 = matrix1.get(2, 3); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s02 = matrix2.get(0, 2); + final double s12 = matrix2.get(1, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12); return output; } private static IMatrixSetterDouble multiplyMatrix4x3x3(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final double f_c00 = matrix1.get(0, 0); - final double f_c10 = matrix1.get(1, 0); - final double f_c20 = matrix1.get(2, 0); - final double f_c01 = matrix1.get(0, 1); - final double f_c11 = matrix1.get(1, 1); - final double f_c21 = matrix1.get(2, 1); - final double f_c02 = matrix1.get(0, 2); - final double f_c12 = matrix1.get(1, 2); - final double f_c22 = matrix1.get(2, 2); - final double f_c03 = matrix1.get(0, 3); - final double f_c13 = matrix1.get(1, 3); - final double f_c23 = matrix1.get(2, 3); - final double s_c00 = matrix2.get(0, 0); - final double s_c10 = matrix2.get(1, 0); - final double s_c20 = matrix2.get(2, 0); - final double s_c01 = matrix2.get(0, 1); - final double s_c11 = matrix2.get(1, 1); - final double s_c21 = matrix2.get(2, 1); - final double s_c02 = matrix2.get(0, 2); - final double s_c12 = matrix2.get(1, 2); - final double s_c22 = matrix2.get(2, 2); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f21 = matrix1.get(2, 1); + final double f02 = matrix1.get(0, 2); + final double f12 = matrix1.get(1, 2); + final double f22 = matrix1.get(2, 2); + final double f03 = matrix1.get(0, 3); + final double f13 = matrix1.get(1, 3); + final double f23 = matrix1.get(2, 3); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s21 = matrix2.get(2, 1); + final double s02 = matrix2.get(0, 2); + final double s12 = matrix2.get(1, 2); + final double s22 = matrix2.get(2, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22); return output; } private static IMatrixSetterDouble multiplyMatrix4x3x4(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final double f_c00 = matrix1.get(0, 0); - final double f_c10 = matrix1.get(1, 0); - final double f_c20 = matrix1.get(2, 0); - final double f_c01 = matrix1.get(0, 1); - final double f_c11 = matrix1.get(1, 1); - final double f_c21 = matrix1.get(2, 1); - final double f_c02 = matrix1.get(0, 2); - final double f_c12 = matrix1.get(1, 2); - final double f_c22 = matrix1.get(2, 2); - final double f_c03 = matrix1.get(0, 3); - final double f_c13 = matrix1.get(1, 3); - final double f_c23 = matrix1.get(2, 3); - final double s_c00 = matrix2.get(0, 0); - final double s_c10 = matrix2.get(1, 0); - final double s_c20 = matrix2.get(2, 0); - final double s_c30 = matrix2.get(3, 0); - final double s_c01 = matrix2.get(0, 1); - final double s_c11 = matrix2.get(1, 1); - final double s_c21 = matrix2.get(2, 1); - final double s_c31 = matrix2.get(3, 1); - final double s_c02 = matrix2.get(0, 2); - final double s_c12 = matrix2.get(1, 2); - final double s_c22 = matrix2.get(2, 2); - final double s_c32 = matrix2.get(3, 2); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32); - output.set(3, 3, f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f21 = matrix1.get(2, 1); + final double f02 = matrix1.get(0, 2); + final double f12 = matrix1.get(1, 2); + final double f22 = matrix1.get(2, 2); + final double f03 = matrix1.get(0, 3); + final double f13 = matrix1.get(1, 3); + final double f23 = matrix1.get(2, 3); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + final double s30 = matrix2.get(3, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s21 = matrix2.get(2, 1); + final double s31 = matrix2.get(3, 1); + final double s02 = matrix2.get(0, 2); + final double s12 = matrix2.get(1, 2); + final double s22 = matrix2.get(2, 2); + final double s32 = matrix2.get(3, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22); + output.set(3, 3, f03 * s30 + f13 * s31 + f23 * s32); return output; } private static IMatrixSetterDouble multiplyMatrix4x3x5(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final double f_c00 = matrix1.get(0, 0); - final double f_c10 = matrix1.get(1, 0); - final double f_c20 = matrix1.get(2, 0); - final double f_c01 = matrix1.get(0, 1); - final double f_c11 = matrix1.get(1, 1); - final double f_c21 = matrix1.get(2, 1); - final double f_c02 = matrix1.get(0, 2); - final double f_c12 = matrix1.get(1, 2); - final double f_c22 = matrix1.get(2, 2); - final double f_c03 = matrix1.get(0, 3); - final double f_c13 = matrix1.get(1, 3); - final double f_c23 = matrix1.get(2, 3); - final double s_c00 = matrix2.get(0, 0); - final double s_c10 = matrix2.get(1, 0); - final double s_c20 = matrix2.get(2, 0); - final double s_c30 = matrix2.get(3, 0); - final double s_c40 = matrix2.get(4, 0); - final double s_c01 = matrix2.get(0, 1); - final double s_c11 = matrix2.get(1, 1); - final double s_c21 = matrix2.get(2, 1); - final double s_c31 = matrix2.get(3, 1); - final double s_c41 = matrix2.get(4, 1); - final double s_c02 = matrix2.get(0, 2); - final double s_c12 = matrix2.get(1, 2); - final double s_c22 = matrix2.get(2, 2); - final double s_c32 = matrix2.get(3, 2); - final double s_c42 = matrix2.get(4, 2); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32); - output.set(3, 3, f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32); - output.set(4, 0, f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42); - output.set(4, 1, f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42); - output.set(4, 2, f_c02*s_c40 + f_c12*s_c41 + f_c22*s_c42); - output.set(4, 3, f_c03*s_c40 + f_c13*s_c41 + f_c23*s_c42); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f21 = matrix1.get(2, 1); + final double f02 = matrix1.get(0, 2); + final double f12 = matrix1.get(1, 2); + final double f22 = matrix1.get(2, 2); + final double f03 = matrix1.get(0, 3); + final double f13 = matrix1.get(1, 3); + final double f23 = matrix1.get(2, 3); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + final double s30 = matrix2.get(3, 0); + final double s40 = matrix2.get(4, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s21 = matrix2.get(2, 1); + final double s31 = matrix2.get(3, 1); + final double s41 = matrix2.get(4, 1); + final double s02 = matrix2.get(0, 2); + final double s12 = matrix2.get(1, 2); + final double s22 = matrix2.get(2, 2); + final double s32 = matrix2.get(3, 2); + final double s42 = matrix2.get(4, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32); + output.set(4, 0, f00 * s40 + f10 * s41 + f20 * s42); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32); + output.set(4, 1, f01 * s40 + f11 * s41 + f21 * s42); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32); + output.set(4, 2, f02 * s40 + f12 * s41 + f22 * s42); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22); + output.set(3, 3, f03 * s30 + f13 * s31 + f23 * s32); + output.set(4, 3, f03 * s40 + f13 * s41 + f23 * s42); + return output; + } + + private static IMatrixSetterDouble multiplyMatrix5x3x1(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f21 = matrix1.get(2, 1); + final double f02 = matrix1.get(0, 2); + final double f12 = matrix1.get(1, 2); + final double f22 = matrix1.get(2, 2); + final double f03 = matrix1.get(0, 3); + final double f13 = matrix1.get(1, 3); + final double f23 = matrix1.get(2, 3); + final double f04 = matrix1.get(0, 4); + final double f14 = matrix1.get(1, 4); + final double f24 = matrix1.get(2, 4); + final double s00 = matrix2.get(0, 0); + final double s01 = matrix2.get(0, 1); + final double s02 = matrix2.get(0, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02); + output.set(0, 4, f04 * s00 + f14 * s01 + f24 * s02); return output; } private static IMatrixSetterDouble multiplyMatrix5x3x2(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final double f_c00 = matrix1.get(0, 0); - final double f_c10 = matrix1.get(1, 0); - final double f_c20 = matrix1.get(2, 0); - final double f_c01 = matrix1.get(0, 1); - final double f_c11 = matrix1.get(1, 1); - final double f_c21 = matrix1.get(2, 1); - final double f_c02 = matrix1.get(0, 2); - final double f_c12 = matrix1.get(1, 2); - final double f_c22 = matrix1.get(2, 2); - final double f_c03 = matrix1.get(0, 3); - final double f_c13 = matrix1.get(1, 3); - final double f_c23 = matrix1.get(2, 3); - final double f_c04 = matrix1.get(0, 4); - final double f_c14 = matrix1.get(1, 4); - final double f_c24 = matrix1.get(2, 4); - final double s_c00 = matrix2.get(0, 0); - final double s_c10 = matrix2.get(1, 0); - final double s_c01 = matrix2.get(0, 1); - final double s_c11 = matrix2.get(1, 1); - final double s_c02 = matrix2.get(0, 2); - final double s_c12 = matrix2.get(1, 2); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02); - output.set(0, 4, f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12); - output.set(1, 4, f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f21 = matrix1.get(2, 1); + final double f02 = matrix1.get(0, 2); + final double f12 = matrix1.get(1, 2); + final double f22 = matrix1.get(2, 2); + final double f03 = matrix1.get(0, 3); + final double f13 = matrix1.get(1, 3); + final double f23 = matrix1.get(2, 3); + final double f04 = matrix1.get(0, 4); + final double f14 = matrix1.get(1, 4); + final double f24 = matrix1.get(2, 4); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s02 = matrix2.get(0, 2); + final double s12 = matrix2.get(1, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12); + output.set(0, 4, f04 * s00 + f14 * s01 + f24 * s02); + output.set(1, 4, f04 * s10 + f14 * s11 + f24 * s12); return output; } private static IMatrixSetterDouble multiplyMatrix5x3x3(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final double f_c00 = matrix1.get(0, 0); - final double f_c10 = matrix1.get(1, 0); - final double f_c20 = matrix1.get(2, 0); - final double f_c01 = matrix1.get(0, 1); - final double f_c11 = matrix1.get(1, 1); - final double f_c21 = matrix1.get(2, 1); - final double f_c02 = matrix1.get(0, 2); - final double f_c12 = matrix1.get(1, 2); - final double f_c22 = matrix1.get(2, 2); - final double f_c03 = matrix1.get(0, 3); - final double f_c13 = matrix1.get(1, 3); - final double f_c23 = matrix1.get(2, 3); - final double f_c04 = matrix1.get(0, 4); - final double f_c14 = matrix1.get(1, 4); - final double f_c24 = matrix1.get(2, 4); - final double s_c00 = matrix2.get(0, 0); - final double s_c10 = matrix2.get(1, 0); - final double s_c20 = matrix2.get(2, 0); - final double s_c01 = matrix2.get(0, 1); - final double s_c11 = matrix2.get(1, 1); - final double s_c21 = matrix2.get(2, 1); - final double s_c02 = matrix2.get(0, 2); - final double s_c12 = matrix2.get(1, 2); - final double s_c22 = matrix2.get(2, 2); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02); - output.set(0, 4, f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12); - output.set(1, 4, f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22); - output.set(2, 4, f_c04*s_c20 + f_c14*s_c21 + f_c24*s_c22); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f21 = matrix1.get(2, 1); + final double f02 = matrix1.get(0, 2); + final double f12 = matrix1.get(1, 2); + final double f22 = matrix1.get(2, 2); + final double f03 = matrix1.get(0, 3); + final double f13 = matrix1.get(1, 3); + final double f23 = matrix1.get(2, 3); + final double f04 = matrix1.get(0, 4); + final double f14 = matrix1.get(1, 4); + final double f24 = matrix1.get(2, 4); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s21 = matrix2.get(2, 1); + final double s02 = matrix2.get(0, 2); + final double s12 = matrix2.get(1, 2); + final double s22 = matrix2.get(2, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22); + output.set(0, 4, f04 * s00 + f14 * s01 + f24 * s02); + output.set(1, 4, f04 * s10 + f14 * s11 + f24 * s12); + output.set(2, 4, f04 * s20 + f14 * s21 + f24 * s22); return output; } private static IMatrixSetterDouble multiplyMatrix5x3x4(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final double f_c00 = matrix1.get(0, 0); - final double f_c10 = matrix1.get(1, 0); - final double f_c20 = matrix1.get(2, 0); - final double f_c01 = matrix1.get(0, 1); - final double f_c11 = matrix1.get(1, 1); - final double f_c21 = matrix1.get(2, 1); - final double f_c02 = matrix1.get(0, 2); - final double f_c12 = matrix1.get(1, 2); - final double f_c22 = matrix1.get(2, 2); - final double f_c03 = matrix1.get(0, 3); - final double f_c13 = matrix1.get(1, 3); - final double f_c23 = matrix1.get(2, 3); - final double f_c04 = matrix1.get(0, 4); - final double f_c14 = matrix1.get(1, 4); - final double f_c24 = matrix1.get(2, 4); - final double s_c00 = matrix2.get(0, 0); - final double s_c10 = matrix2.get(1, 0); - final double s_c20 = matrix2.get(2, 0); - final double s_c30 = matrix2.get(3, 0); - final double s_c01 = matrix2.get(0, 1); - final double s_c11 = matrix2.get(1, 1); - final double s_c21 = matrix2.get(2, 1); - final double s_c31 = matrix2.get(3, 1); - final double s_c02 = matrix2.get(0, 2); - final double s_c12 = matrix2.get(1, 2); - final double s_c22 = matrix2.get(2, 2); - final double s_c32 = matrix2.get(3, 2); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02); - output.set(0, 4, f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12); - output.set(1, 4, f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22); - output.set(2, 4, f_c04*s_c20 + f_c14*s_c21 + f_c24*s_c22); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32); - output.set(3, 3, f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32); - output.set(3, 4, f_c04*s_c30 + f_c14*s_c31 + f_c24*s_c32); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f21 = matrix1.get(2, 1); + final double f02 = matrix1.get(0, 2); + final double f12 = matrix1.get(1, 2); + final double f22 = matrix1.get(2, 2); + final double f03 = matrix1.get(0, 3); + final double f13 = matrix1.get(1, 3); + final double f23 = matrix1.get(2, 3); + final double f04 = matrix1.get(0, 4); + final double f14 = matrix1.get(1, 4); + final double f24 = matrix1.get(2, 4); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + final double s30 = matrix2.get(3, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s21 = matrix2.get(2, 1); + final double s31 = matrix2.get(3, 1); + final double s02 = matrix2.get(0, 2); + final double s12 = matrix2.get(1, 2); + final double s22 = matrix2.get(2, 2); + final double s32 = matrix2.get(3, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22); + output.set(3, 3, f03 * s30 + f13 * s31 + f23 * s32); + output.set(0, 4, f04 * s00 + f14 * s01 + f24 * s02); + output.set(1, 4, f04 * s10 + f14 * s11 + f24 * s12); + output.set(2, 4, f04 * s20 + f14 * s21 + f24 * s22); + output.set(3, 4, f04 * s30 + f14 * s31 + f24 * s32); return output; } private static IMatrixSetterDouble multiplyMatrix5x3x5(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final double f_c00 = matrix1.get(0, 0); - final double f_c10 = matrix1.get(1, 0); - final double f_c20 = matrix1.get(2, 0); - final double f_c01 = matrix1.get(0, 1); - final double f_c11 = matrix1.get(1, 1); - final double f_c21 = matrix1.get(2, 1); - final double f_c02 = matrix1.get(0, 2); - final double f_c12 = matrix1.get(1, 2); - final double f_c22 = matrix1.get(2, 2); - final double f_c03 = matrix1.get(0, 3); - final double f_c13 = matrix1.get(1, 3); - final double f_c23 = matrix1.get(2, 3); - final double f_c04 = matrix1.get(0, 4); - final double f_c14 = matrix1.get(1, 4); - final double f_c24 = matrix1.get(2, 4); - final double s_c00 = matrix2.get(0, 0); - final double s_c10 = matrix2.get(1, 0); - final double s_c20 = matrix2.get(2, 0); - final double s_c30 = matrix2.get(3, 0); - final double s_c40 = matrix2.get(4, 0); - final double s_c01 = matrix2.get(0, 1); - final double s_c11 = matrix2.get(1, 1); - final double s_c21 = matrix2.get(2, 1); - final double s_c31 = matrix2.get(3, 1); - final double s_c41 = matrix2.get(4, 1); - final double s_c02 = matrix2.get(0, 2); - final double s_c12 = matrix2.get(1, 2); - final double s_c22 = matrix2.get(2, 2); - final double s_c32 = matrix2.get(3, 2); - final double s_c42 = matrix2.get(4, 2); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02); - output.set(0, 4, f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12); - output.set(1, 4, f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22); - output.set(2, 4, f_c04*s_c20 + f_c14*s_c21 + f_c24*s_c22); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32); - output.set(3, 3, f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32); - output.set(3, 4, f_c04*s_c30 + f_c14*s_c31 + f_c24*s_c32); - output.set(4, 0, f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42); - output.set(4, 1, f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42); - output.set(4, 2, f_c02*s_c40 + f_c12*s_c41 + f_c22*s_c42); - output.set(4, 3, f_c03*s_c40 + f_c13*s_c41 + f_c23*s_c42); - output.set(4, 4, f_c04*s_c40 + f_c14*s_c41 + f_c24*s_c42); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f21 = matrix1.get(2, 1); + final double f02 = matrix1.get(0, 2); + final double f12 = matrix1.get(1, 2); + final double f22 = matrix1.get(2, 2); + final double f03 = matrix1.get(0, 3); + final double f13 = matrix1.get(1, 3); + final double f23 = matrix1.get(2, 3); + final double f04 = matrix1.get(0, 4); + final double f14 = matrix1.get(1, 4); + final double f24 = matrix1.get(2, 4); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + final double s30 = matrix2.get(3, 0); + final double s40 = matrix2.get(4, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s21 = matrix2.get(2, 1); + final double s31 = matrix2.get(3, 1); + final double s41 = matrix2.get(4, 1); + final double s02 = matrix2.get(0, 2); + final double s12 = matrix2.get(1, 2); + final double s22 = matrix2.get(2, 2); + final double s32 = matrix2.get(3, 2); + final double s42 = matrix2.get(4, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32); + output.set(4, 0, f00 * s40 + f10 * s41 + f20 * s42); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32); + output.set(4, 1, f01 * s40 + f11 * s41 + f21 * s42); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32); + output.set(4, 2, f02 * s40 + f12 * s41 + f22 * s42); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22); + output.set(3, 3, f03 * s30 + f13 * s31 + f23 * s32); + output.set(4, 3, f03 * s40 + f13 * s41 + f23 * s42); + output.set(0, 4, f04 * s00 + f14 * s01 + f24 * s02); + output.set(1, 4, f04 * s10 + f14 * s11 + f24 * s12); + output.set(2, 4, f04 * s20 + f14 * s21 + f24 * s22); + output.set(3, 4, f04 * s30 + f14 * s31 + f24 * s32); + output.set(4, 4, f04 * s40 + f14 * s41 + f24 * s42); + return output; + } + + private static IMatrixSetterDouble multiplyMatrix1x4x1(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double f30 = matrix1.get(3, 0); + final double s00 = matrix2.get(0, 0); + final double s01 = matrix2.get(0, 1); + final double s02 = matrix2.get(0, 2); + final double s03 = matrix2.get(0, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + return output; + } + + private static IMatrixSetterDouble multiplyMatrix1x4x2(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double f30 = matrix1.get(3, 0); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s02 = matrix2.get(0, 2); + final double s12 = matrix2.get(1, 2); + final double s03 = matrix2.get(0, 3); + final double s13 = matrix2.get(1, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + return output; + } + + private static IMatrixSetterDouble multiplyMatrix1x4x3(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double f30 = matrix1.get(3, 0); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s21 = matrix2.get(2, 1); + final double s02 = matrix2.get(0, 2); + final double s12 = matrix2.get(1, 2); + final double s22 = matrix2.get(2, 2); + final double s03 = matrix2.get(0, 3); + final double s13 = matrix2.get(1, 3); + final double s23 = matrix2.get(2, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23); + return output; + } + + private static IMatrixSetterDouble multiplyMatrix1x4x4(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double f30 = matrix1.get(3, 0); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + final double s30 = matrix2.get(3, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s21 = matrix2.get(2, 1); + final double s31 = matrix2.get(3, 1); + final double s02 = matrix2.get(0, 2); + final double s12 = matrix2.get(1, 2); + final double s22 = matrix2.get(2, 2); + final double s32 = matrix2.get(3, 2); + final double s03 = matrix2.get(0, 3); + final double s13 = matrix2.get(1, 3); + final double s23 = matrix2.get(2, 3); + final double s33 = matrix2.get(3, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33); + return output; + } + + private static IMatrixSetterDouble multiplyMatrix1x4x5(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double f30 = matrix1.get(3, 0); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + final double s30 = matrix2.get(3, 0); + final double s40 = matrix2.get(4, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s21 = matrix2.get(2, 1); + final double s31 = matrix2.get(3, 1); + final double s41 = matrix2.get(4, 1); + final double s02 = matrix2.get(0, 2); + final double s12 = matrix2.get(1, 2); + final double s22 = matrix2.get(2, 2); + final double s32 = matrix2.get(3, 2); + final double s42 = matrix2.get(4, 2); + final double s03 = matrix2.get(0, 3); + final double s13 = matrix2.get(1, 3); + final double s23 = matrix2.get(2, 3); + final double s33 = matrix2.get(3, 3); + final double s43 = matrix2.get(4, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33); + output.set(4, 0, f00 * s40 + f10 * s41 + f20 * s42 + f30 * s43); + return output; + } + + private static IMatrixSetterDouble multiplyMatrix2x4x1(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double f30 = matrix1.get(3, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f21 = matrix1.get(2, 1); + final double f31 = matrix1.get(3, 1); + final double s00 = matrix2.get(0, 0); + final double s01 = matrix2.get(0, 1); + final double s02 = matrix2.get(0, 2); + final double s03 = matrix2.get(0, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); return output; } private static IMatrixSetterDouble multiplyMatrix2x4x2(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final double f_c00 = matrix1.get(0, 0); - final double f_c10 = matrix1.get(1, 0); - final double f_c20 = matrix1.get(2, 0); - final double f_c30 = matrix1.get(3, 0); - final double f_c01 = matrix1.get(0, 1); - final double f_c11 = matrix1.get(1, 1); - final double f_c21 = matrix1.get(2, 1); - final double f_c31 = matrix1.get(3, 1); - final double s_c00 = matrix2.get(0, 0); - final double s_c10 = matrix2.get(1, 0); - final double s_c01 = matrix2.get(0, 1); - final double s_c11 = matrix2.get(1, 1); - final double s_c02 = matrix2.get(0, 2); - final double s_c12 = matrix2.get(1, 2); - final double s_c03 = matrix2.get(0, 3); - final double s_c13 = matrix2.get(1, 3); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double f30 = matrix1.get(3, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f21 = matrix1.get(2, 1); + final double f31 = matrix1.get(3, 1); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s02 = matrix2.get(0, 2); + final double s12 = matrix2.get(1, 2); + final double s03 = matrix2.get(0, 3); + final double s13 = matrix2.get(1, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13); return output; } private static IMatrixSetterDouble multiplyMatrix2x4x3(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final double f_c00 = matrix1.get(0, 0); - final double f_c10 = matrix1.get(1, 0); - final double f_c20 = matrix1.get(2, 0); - final double f_c30 = matrix1.get(3, 0); - final double f_c01 = matrix1.get(0, 1); - final double f_c11 = matrix1.get(1, 1); - final double f_c21 = matrix1.get(2, 1); - final double f_c31 = matrix1.get(3, 1); - final double s_c00 = matrix2.get(0, 0); - final double s_c10 = matrix2.get(1, 0); - final double s_c20 = matrix2.get(2, 0); - final double s_c01 = matrix2.get(0, 1); - final double s_c11 = matrix2.get(1, 1); - final double s_c21 = matrix2.get(2, 1); - final double s_c02 = matrix2.get(0, 2); - final double s_c12 = matrix2.get(1, 2); - final double s_c22 = matrix2.get(2, 2); - final double s_c03 = matrix2.get(0, 3); - final double s_c13 = matrix2.get(1, 3); - final double s_c23 = matrix2.get(2, 3); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double f30 = matrix1.get(3, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f21 = matrix1.get(2, 1); + final double f31 = matrix1.get(3, 1); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s21 = matrix2.get(2, 1); + final double s02 = matrix2.get(0, 2); + final double s12 = matrix2.get(1, 2); + final double s22 = matrix2.get(2, 2); + final double s03 = matrix2.get(0, 3); + final double s13 = matrix2.get(1, 3); + final double s23 = matrix2.get(2, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23); return output; } private static IMatrixSetterDouble multiplyMatrix2x4x4(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final double f_c00 = matrix1.get(0, 0); - final double f_c10 = matrix1.get(1, 0); - final double f_c20 = matrix1.get(2, 0); - final double f_c30 = matrix1.get(3, 0); - final double f_c01 = matrix1.get(0, 1); - final double f_c11 = matrix1.get(1, 1); - final double f_c21 = matrix1.get(2, 1); - final double f_c31 = matrix1.get(3, 1); - final double s_c00 = matrix2.get(0, 0); - final double s_c10 = matrix2.get(1, 0); - final double s_c20 = matrix2.get(2, 0); - final double s_c30 = matrix2.get(3, 0); - final double s_c01 = matrix2.get(0, 1); - final double s_c11 = matrix2.get(1, 1); - final double s_c21 = matrix2.get(2, 1); - final double s_c31 = matrix2.get(3, 1); - final double s_c02 = matrix2.get(0, 2); - final double s_c12 = matrix2.get(1, 2); - final double s_c22 = matrix2.get(2, 2); - final double s_c32 = matrix2.get(3, 2); - final double s_c03 = matrix2.get(0, 3); - final double s_c13 = matrix2.get(1, 3); - final double s_c23 = matrix2.get(2, 3); - final double s_c33 = matrix2.get(3, 3); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double f30 = matrix1.get(3, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f21 = matrix1.get(2, 1); + final double f31 = matrix1.get(3, 1); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + final double s30 = matrix2.get(3, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s21 = matrix2.get(2, 1); + final double s31 = matrix2.get(3, 1); + final double s02 = matrix2.get(0, 2); + final double s12 = matrix2.get(1, 2); + final double s22 = matrix2.get(2, 2); + final double s32 = matrix2.get(3, 2); + final double s03 = matrix2.get(0, 3); + final double s13 = matrix2.get(1, 3); + final double s23 = matrix2.get(2, 3); + final double s33 = matrix2.get(3, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33); return output; } private static IMatrixSetterDouble multiplyMatrix2x4x5(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final double f_c00 = matrix1.get(0, 0); - final double f_c10 = matrix1.get(1, 0); - final double f_c20 = matrix1.get(2, 0); - final double f_c30 = matrix1.get(3, 0); - final double f_c01 = matrix1.get(0, 1); - final double f_c11 = matrix1.get(1, 1); - final double f_c21 = matrix1.get(2, 1); - final double f_c31 = matrix1.get(3, 1); - final double s_c00 = matrix2.get(0, 0); - final double s_c10 = matrix2.get(1, 0); - final double s_c20 = matrix2.get(2, 0); - final double s_c30 = matrix2.get(3, 0); - final double s_c40 = matrix2.get(4, 0); - final double s_c01 = matrix2.get(0, 1); - final double s_c11 = matrix2.get(1, 1); - final double s_c21 = matrix2.get(2, 1); - final double s_c31 = matrix2.get(3, 1); - final double s_c41 = matrix2.get(4, 1); - final double s_c02 = matrix2.get(0, 2); - final double s_c12 = matrix2.get(1, 2); - final double s_c22 = matrix2.get(2, 2); - final double s_c32 = matrix2.get(3, 2); - final double s_c42 = matrix2.get(4, 2); - final double s_c03 = matrix2.get(0, 3); - final double s_c13 = matrix2.get(1, 3); - final double s_c23 = matrix2.get(2, 3); - final double s_c33 = matrix2.get(3, 3); - final double s_c43 = matrix2.get(4, 3); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33); - output.set(4, 0, f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42 + f_c30*s_c43); - output.set(4, 1, f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42 + f_c31*s_c43); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double f30 = matrix1.get(3, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f21 = matrix1.get(2, 1); + final double f31 = matrix1.get(3, 1); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + final double s30 = matrix2.get(3, 0); + final double s40 = matrix2.get(4, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s21 = matrix2.get(2, 1); + final double s31 = matrix2.get(3, 1); + final double s41 = matrix2.get(4, 1); + final double s02 = matrix2.get(0, 2); + final double s12 = matrix2.get(1, 2); + final double s22 = matrix2.get(2, 2); + final double s32 = matrix2.get(3, 2); + final double s42 = matrix2.get(4, 2); + final double s03 = matrix2.get(0, 3); + final double s13 = matrix2.get(1, 3); + final double s23 = matrix2.get(2, 3); + final double s33 = matrix2.get(3, 3); + final double s43 = matrix2.get(4, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33); + output.set(4, 0, f00 * s40 + f10 * s41 + f20 * s42 + f30 * s43); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33); + output.set(4, 1, f01 * s40 + f11 * s41 + f21 * s42 + f31 * s43); + return output; + } + + private static IMatrixSetterDouble multiplyMatrix3x4x1(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double f30 = matrix1.get(3, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f21 = matrix1.get(2, 1); + final double f31 = matrix1.get(3, 1); + final double f02 = matrix1.get(0, 2); + final double f12 = matrix1.get(1, 2); + final double f22 = matrix1.get(2, 2); + final double f32 = matrix1.get(3, 2); + final double s00 = matrix2.get(0, 0); + final double s01 = matrix2.get(0, 1); + final double s02 = matrix2.get(0, 2); + final double s03 = matrix2.get(0, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03); return output; } private static IMatrixSetterDouble multiplyMatrix3x4x2(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final double f_c00 = matrix1.get(0, 0); - final double f_c10 = matrix1.get(1, 0); - final double f_c20 = matrix1.get(2, 0); - final double f_c30 = matrix1.get(3, 0); - final double f_c01 = matrix1.get(0, 1); - final double f_c11 = matrix1.get(1, 1); - final double f_c21 = matrix1.get(2, 1); - final double f_c31 = matrix1.get(3, 1); - final double f_c02 = matrix1.get(0, 2); - final double f_c12 = matrix1.get(1, 2); - final double f_c22 = matrix1.get(2, 2); - final double f_c32 = matrix1.get(3, 2); - final double s_c00 = matrix2.get(0, 0); - final double s_c10 = matrix2.get(1, 0); - final double s_c01 = matrix2.get(0, 1); - final double s_c11 = matrix2.get(1, 1); - final double s_c02 = matrix2.get(0, 2); - final double s_c12 = matrix2.get(1, 2); - final double s_c03 = matrix2.get(0, 3); - final double s_c13 = matrix2.get(1, 3); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double f30 = matrix1.get(3, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f21 = matrix1.get(2, 1); + final double f31 = matrix1.get(3, 1); + final double f02 = matrix1.get(0, 2); + final double f12 = matrix1.get(1, 2); + final double f22 = matrix1.get(2, 2); + final double f32 = matrix1.get(3, 2); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s02 = matrix2.get(0, 2); + final double s12 = matrix2.get(1, 2); + final double s03 = matrix2.get(0, 3); + final double s13 = matrix2.get(1, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13); return output; } private static IMatrixSetterDouble multiplyMatrix3x4x3(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final double f_c00 = matrix1.get(0, 0); - final double f_c10 = matrix1.get(1, 0); - final double f_c20 = matrix1.get(2, 0); - final double f_c30 = matrix1.get(3, 0); - final double f_c01 = matrix1.get(0, 1); - final double f_c11 = matrix1.get(1, 1); - final double f_c21 = matrix1.get(2, 1); - final double f_c31 = matrix1.get(3, 1); - final double f_c02 = matrix1.get(0, 2); - final double f_c12 = matrix1.get(1, 2); - final double f_c22 = matrix1.get(2, 2); - final double f_c32 = matrix1.get(3, 2); - final double s_c00 = matrix2.get(0, 0); - final double s_c10 = matrix2.get(1, 0); - final double s_c20 = matrix2.get(2, 0); - final double s_c01 = matrix2.get(0, 1); - final double s_c11 = matrix2.get(1, 1); - final double s_c21 = matrix2.get(2, 1); - final double s_c02 = matrix2.get(0, 2); - final double s_c12 = matrix2.get(1, 2); - final double s_c22 = matrix2.get(2, 2); - final double s_c03 = matrix2.get(0, 3); - final double s_c13 = matrix2.get(1, 3); - final double s_c23 = matrix2.get(2, 3); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double f30 = matrix1.get(3, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f21 = matrix1.get(2, 1); + final double f31 = matrix1.get(3, 1); + final double f02 = matrix1.get(0, 2); + final double f12 = matrix1.get(1, 2); + final double f22 = matrix1.get(2, 2); + final double f32 = matrix1.get(3, 2); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s21 = matrix2.get(2, 1); + final double s02 = matrix2.get(0, 2); + final double s12 = matrix2.get(1, 2); + final double s22 = matrix2.get(2, 2); + final double s03 = matrix2.get(0, 3); + final double s13 = matrix2.get(1, 3); + final double s23 = matrix2.get(2, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23); return output; } private static IMatrixSetterDouble multiplyMatrix3x4x4(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final double f_c00 = matrix1.get(0, 0); - final double f_c10 = matrix1.get(1, 0); - final double f_c20 = matrix1.get(2, 0); - final double f_c30 = matrix1.get(3, 0); - final double f_c01 = matrix1.get(0, 1); - final double f_c11 = matrix1.get(1, 1); - final double f_c21 = matrix1.get(2, 1); - final double f_c31 = matrix1.get(3, 1); - final double f_c02 = matrix1.get(0, 2); - final double f_c12 = matrix1.get(1, 2); - final double f_c22 = matrix1.get(2, 2); - final double f_c32 = matrix1.get(3, 2); - final double s_c00 = matrix2.get(0, 0); - final double s_c10 = matrix2.get(1, 0); - final double s_c20 = matrix2.get(2, 0); - final double s_c30 = matrix2.get(3, 0); - final double s_c01 = matrix2.get(0, 1); - final double s_c11 = matrix2.get(1, 1); - final double s_c21 = matrix2.get(2, 1); - final double s_c31 = matrix2.get(3, 1); - final double s_c02 = matrix2.get(0, 2); - final double s_c12 = matrix2.get(1, 2); - final double s_c22 = matrix2.get(2, 2); - final double s_c32 = matrix2.get(3, 2); - final double s_c03 = matrix2.get(0, 3); - final double s_c13 = matrix2.get(1, 3); - final double s_c23 = matrix2.get(2, 3); - final double s_c33 = matrix2.get(3, 3); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double f30 = matrix1.get(3, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f21 = matrix1.get(2, 1); + final double f31 = matrix1.get(3, 1); + final double f02 = matrix1.get(0, 2); + final double f12 = matrix1.get(1, 2); + final double f22 = matrix1.get(2, 2); + final double f32 = matrix1.get(3, 2); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + final double s30 = matrix2.get(3, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s21 = matrix2.get(2, 1); + final double s31 = matrix2.get(3, 1); + final double s02 = matrix2.get(0, 2); + final double s12 = matrix2.get(1, 2); + final double s22 = matrix2.get(2, 2); + final double s32 = matrix2.get(3, 2); + final double s03 = matrix2.get(0, 3); + final double s13 = matrix2.get(1, 3); + final double s23 = matrix2.get(2, 3); + final double s33 = matrix2.get(3, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33); return output; } private static IMatrixSetterDouble multiplyMatrix3x4x5(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final double f_c00 = matrix1.get(0, 0); - final double f_c10 = matrix1.get(1, 0); - final double f_c20 = matrix1.get(2, 0); - final double f_c30 = matrix1.get(3, 0); - final double f_c01 = matrix1.get(0, 1); - final double f_c11 = matrix1.get(1, 1); - final double f_c21 = matrix1.get(2, 1); - final double f_c31 = matrix1.get(3, 1); - final double f_c02 = matrix1.get(0, 2); - final double f_c12 = matrix1.get(1, 2); - final double f_c22 = matrix1.get(2, 2); - final double f_c32 = matrix1.get(3, 2); - final double s_c00 = matrix2.get(0, 0); - final double s_c10 = matrix2.get(1, 0); - final double s_c20 = matrix2.get(2, 0); - final double s_c30 = matrix2.get(3, 0); - final double s_c40 = matrix2.get(4, 0); - final double s_c01 = matrix2.get(0, 1); - final double s_c11 = matrix2.get(1, 1); - final double s_c21 = matrix2.get(2, 1); - final double s_c31 = matrix2.get(3, 1); - final double s_c41 = matrix2.get(4, 1); - final double s_c02 = matrix2.get(0, 2); - final double s_c12 = matrix2.get(1, 2); - final double s_c22 = matrix2.get(2, 2); - final double s_c32 = matrix2.get(3, 2); - final double s_c42 = matrix2.get(4, 2); - final double s_c03 = matrix2.get(0, 3); - final double s_c13 = matrix2.get(1, 3); - final double s_c23 = matrix2.get(2, 3); - final double s_c33 = matrix2.get(3, 3); - final double s_c43 = matrix2.get(4, 3); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33); - output.set(4, 0, f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42 + f_c30*s_c43); - output.set(4, 1, f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42 + f_c31*s_c43); - output.set(4, 2, f_c02*s_c40 + f_c12*s_c41 + f_c22*s_c42 + f_c32*s_c43); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double f30 = matrix1.get(3, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f21 = matrix1.get(2, 1); + final double f31 = matrix1.get(3, 1); + final double f02 = matrix1.get(0, 2); + final double f12 = matrix1.get(1, 2); + final double f22 = matrix1.get(2, 2); + final double f32 = matrix1.get(3, 2); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + final double s30 = matrix2.get(3, 0); + final double s40 = matrix2.get(4, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s21 = matrix2.get(2, 1); + final double s31 = matrix2.get(3, 1); + final double s41 = matrix2.get(4, 1); + final double s02 = matrix2.get(0, 2); + final double s12 = matrix2.get(1, 2); + final double s22 = matrix2.get(2, 2); + final double s32 = matrix2.get(3, 2); + final double s42 = matrix2.get(4, 2); + final double s03 = matrix2.get(0, 3); + final double s13 = matrix2.get(1, 3); + final double s23 = matrix2.get(2, 3); + final double s33 = matrix2.get(3, 3); + final double s43 = matrix2.get(4, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33); + output.set(4, 0, f00 * s40 + f10 * s41 + f20 * s42 + f30 * s43); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33); + output.set(4, 1, f01 * s40 + f11 * s41 + f21 * s42 + f31 * s43); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33); + output.set(4, 2, f02 * s40 + f12 * s41 + f22 * s42 + f32 * s43); + return output; + } + + private static IMatrixSetterDouble multiplyMatrix4x4x1(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double f30 = matrix1.get(3, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f21 = matrix1.get(2, 1); + final double f31 = matrix1.get(3, 1); + final double f02 = matrix1.get(0, 2); + final double f12 = matrix1.get(1, 2); + final double f22 = matrix1.get(2, 2); + final double f32 = matrix1.get(3, 2); + final double f03 = matrix1.get(0, 3); + final double f13 = matrix1.get(1, 3); + final double f23 = matrix1.get(2, 3); + final double f33 = matrix1.get(3, 3); + final double s00 = matrix2.get(0, 0); + final double s01 = matrix2.get(0, 1); + final double s02 = matrix2.get(0, 2); + final double s03 = matrix2.get(0, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03); return output; } private static IMatrixSetterDouble multiplyMatrix4x4x2(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final double f_c00 = matrix1.get(0, 0); - final double f_c10 = matrix1.get(1, 0); - final double f_c20 = matrix1.get(2, 0); - final double f_c30 = matrix1.get(3, 0); - final double f_c01 = matrix1.get(0, 1); - final double f_c11 = matrix1.get(1, 1); - final double f_c21 = matrix1.get(2, 1); - final double f_c31 = matrix1.get(3, 1); - final double f_c02 = matrix1.get(0, 2); - final double f_c12 = matrix1.get(1, 2); - final double f_c22 = matrix1.get(2, 2); - final double f_c32 = matrix1.get(3, 2); - final double f_c03 = matrix1.get(0, 3); - final double f_c13 = matrix1.get(1, 3); - final double f_c23 = matrix1.get(2, 3); - final double f_c33 = matrix1.get(3, 3); - final double s_c00 = matrix2.get(0, 0); - final double s_c10 = matrix2.get(1, 0); - final double s_c01 = matrix2.get(0, 1); - final double s_c11 = matrix2.get(1, 1); - final double s_c02 = matrix2.get(0, 2); - final double s_c12 = matrix2.get(1, 2); - final double s_c03 = matrix2.get(0, 3); - final double s_c13 = matrix2.get(1, 3); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double f30 = matrix1.get(3, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f21 = matrix1.get(2, 1); + final double f31 = matrix1.get(3, 1); + final double f02 = matrix1.get(0, 2); + final double f12 = matrix1.get(1, 2); + final double f22 = matrix1.get(2, 2); + final double f32 = matrix1.get(3, 2); + final double f03 = matrix1.get(0, 3); + final double f13 = matrix1.get(1, 3); + final double f23 = matrix1.get(2, 3); + final double f33 = matrix1.get(3, 3); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s02 = matrix2.get(0, 2); + final double s12 = matrix2.get(1, 2); + final double s03 = matrix2.get(0, 3); + final double s13 = matrix2.get(1, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13); return output; } private static IMatrixSetterDouble multiplyMatrix4x4x3(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final double f_c00 = matrix1.get(0, 0); - final double f_c10 = matrix1.get(1, 0); - final double f_c20 = matrix1.get(2, 0); - final double f_c30 = matrix1.get(3, 0); - final double f_c01 = matrix1.get(0, 1); - final double f_c11 = matrix1.get(1, 1); - final double f_c21 = matrix1.get(2, 1); - final double f_c31 = matrix1.get(3, 1); - final double f_c02 = matrix1.get(0, 2); - final double f_c12 = matrix1.get(1, 2); - final double f_c22 = matrix1.get(2, 2); - final double f_c32 = matrix1.get(3, 2); - final double f_c03 = matrix1.get(0, 3); - final double f_c13 = matrix1.get(1, 3); - final double f_c23 = matrix1.get(2, 3); - final double f_c33 = matrix1.get(3, 3); - final double s_c00 = matrix2.get(0, 0); - final double s_c10 = matrix2.get(1, 0); - final double s_c20 = matrix2.get(2, 0); - final double s_c01 = matrix2.get(0, 1); - final double s_c11 = matrix2.get(1, 1); - final double s_c21 = matrix2.get(2, 1); - final double s_c02 = matrix2.get(0, 2); - final double s_c12 = matrix2.get(1, 2); - final double s_c22 = matrix2.get(2, 2); - final double s_c03 = matrix2.get(0, 3); - final double s_c13 = matrix2.get(1, 3); - final double s_c23 = matrix2.get(2, 3); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double f30 = matrix1.get(3, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f21 = matrix1.get(2, 1); + final double f31 = matrix1.get(3, 1); + final double f02 = matrix1.get(0, 2); + final double f12 = matrix1.get(1, 2); + final double f22 = matrix1.get(2, 2); + final double f32 = matrix1.get(3, 2); + final double f03 = matrix1.get(0, 3); + final double f13 = matrix1.get(1, 3); + final double f23 = matrix1.get(2, 3); + final double f33 = matrix1.get(3, 3); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s21 = matrix2.get(2, 1); + final double s02 = matrix2.get(0, 2); + final double s12 = matrix2.get(1, 2); + final double s22 = matrix2.get(2, 2); + final double s03 = matrix2.get(0, 3); + final double s13 = matrix2.get(1, 3); + final double s23 = matrix2.get(2, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23); return output; } private static IMatrixSetterDouble multiplyMatrix4x4x4(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final double f_c00 = matrix1.get(0, 0); - final double f_c10 = matrix1.get(1, 0); - final double f_c20 = matrix1.get(2, 0); - final double f_c30 = matrix1.get(3, 0); - final double f_c01 = matrix1.get(0, 1); - final double f_c11 = matrix1.get(1, 1); - final double f_c21 = matrix1.get(2, 1); - final double f_c31 = matrix1.get(3, 1); - final double f_c02 = matrix1.get(0, 2); - final double f_c12 = matrix1.get(1, 2); - final double f_c22 = matrix1.get(2, 2); - final double f_c32 = matrix1.get(3, 2); - final double f_c03 = matrix1.get(0, 3); - final double f_c13 = matrix1.get(1, 3); - final double f_c23 = matrix1.get(2, 3); - final double f_c33 = matrix1.get(3, 3); - final double s_c00 = matrix2.get(0, 0); - final double s_c10 = matrix2.get(1, 0); - final double s_c20 = matrix2.get(2, 0); - final double s_c30 = matrix2.get(3, 0); - final double s_c01 = matrix2.get(0, 1); - final double s_c11 = matrix2.get(1, 1); - final double s_c21 = matrix2.get(2, 1); - final double s_c31 = matrix2.get(3, 1); - final double s_c02 = matrix2.get(0, 2); - final double s_c12 = matrix2.get(1, 2); - final double s_c22 = matrix2.get(2, 2); - final double s_c32 = matrix2.get(3, 2); - final double s_c03 = matrix2.get(0, 3); - final double s_c13 = matrix2.get(1, 3); - final double s_c23 = matrix2.get(2, 3); - final double s_c33 = matrix2.get(3, 3); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33); - output.set(3, 3, f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32 + f_c33*s_c33); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double f30 = matrix1.get(3, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f21 = matrix1.get(2, 1); + final double f31 = matrix1.get(3, 1); + final double f02 = matrix1.get(0, 2); + final double f12 = matrix1.get(1, 2); + final double f22 = matrix1.get(2, 2); + final double f32 = matrix1.get(3, 2); + final double f03 = matrix1.get(0, 3); + final double f13 = matrix1.get(1, 3); + final double f23 = matrix1.get(2, 3); + final double f33 = matrix1.get(3, 3); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + final double s30 = matrix2.get(3, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s21 = matrix2.get(2, 1); + final double s31 = matrix2.get(3, 1); + final double s02 = matrix2.get(0, 2); + final double s12 = matrix2.get(1, 2); + final double s22 = matrix2.get(2, 2); + final double s32 = matrix2.get(3, 2); + final double s03 = matrix2.get(0, 3); + final double s13 = matrix2.get(1, 3); + final double s23 = matrix2.get(2, 3); + final double s33 = matrix2.get(3, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23); + output.set(3, 3, f03 * s30 + f13 * s31 + f23 * s32 + f33 * s33); return output; } private static IMatrixSetterDouble multiplyMatrix4x4x5(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final double f_c00 = matrix1.get(0, 0); - final double f_c10 = matrix1.get(1, 0); - final double f_c20 = matrix1.get(2, 0); - final double f_c30 = matrix1.get(3, 0); - final double f_c01 = matrix1.get(0, 1); - final double f_c11 = matrix1.get(1, 1); - final double f_c21 = matrix1.get(2, 1); - final double f_c31 = matrix1.get(3, 1); - final double f_c02 = matrix1.get(0, 2); - final double f_c12 = matrix1.get(1, 2); - final double f_c22 = matrix1.get(2, 2); - final double f_c32 = matrix1.get(3, 2); - final double f_c03 = matrix1.get(0, 3); - final double f_c13 = matrix1.get(1, 3); - final double f_c23 = matrix1.get(2, 3); - final double f_c33 = matrix1.get(3, 3); - final double s_c00 = matrix2.get(0, 0); - final double s_c10 = matrix2.get(1, 0); - final double s_c20 = matrix2.get(2, 0); - final double s_c30 = matrix2.get(3, 0); - final double s_c40 = matrix2.get(4, 0); - final double s_c01 = matrix2.get(0, 1); - final double s_c11 = matrix2.get(1, 1); - final double s_c21 = matrix2.get(2, 1); - final double s_c31 = matrix2.get(3, 1); - final double s_c41 = matrix2.get(4, 1); - final double s_c02 = matrix2.get(0, 2); - final double s_c12 = matrix2.get(1, 2); - final double s_c22 = matrix2.get(2, 2); - final double s_c32 = matrix2.get(3, 2); - final double s_c42 = matrix2.get(4, 2); - final double s_c03 = matrix2.get(0, 3); - final double s_c13 = matrix2.get(1, 3); - final double s_c23 = matrix2.get(2, 3); - final double s_c33 = matrix2.get(3, 3); - final double s_c43 = matrix2.get(4, 3); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33); - output.set(3, 3, f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32 + f_c33*s_c33); - output.set(4, 0, f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42 + f_c30*s_c43); - output.set(4, 1, f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42 + f_c31*s_c43); - output.set(4, 2, f_c02*s_c40 + f_c12*s_c41 + f_c22*s_c42 + f_c32*s_c43); - output.set(4, 3, f_c03*s_c40 + f_c13*s_c41 + f_c23*s_c42 + f_c33*s_c43); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double f30 = matrix1.get(3, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f21 = matrix1.get(2, 1); + final double f31 = matrix1.get(3, 1); + final double f02 = matrix1.get(0, 2); + final double f12 = matrix1.get(1, 2); + final double f22 = matrix1.get(2, 2); + final double f32 = matrix1.get(3, 2); + final double f03 = matrix1.get(0, 3); + final double f13 = matrix1.get(1, 3); + final double f23 = matrix1.get(2, 3); + final double f33 = matrix1.get(3, 3); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + final double s30 = matrix2.get(3, 0); + final double s40 = matrix2.get(4, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s21 = matrix2.get(2, 1); + final double s31 = matrix2.get(3, 1); + final double s41 = matrix2.get(4, 1); + final double s02 = matrix2.get(0, 2); + final double s12 = matrix2.get(1, 2); + final double s22 = matrix2.get(2, 2); + final double s32 = matrix2.get(3, 2); + final double s42 = matrix2.get(4, 2); + final double s03 = matrix2.get(0, 3); + final double s13 = matrix2.get(1, 3); + final double s23 = matrix2.get(2, 3); + final double s33 = matrix2.get(3, 3); + final double s43 = matrix2.get(4, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33); + output.set(4, 0, f00 * s40 + f10 * s41 + f20 * s42 + f30 * s43); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33); + output.set(4, 1, f01 * s40 + f11 * s41 + f21 * s42 + f31 * s43); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33); + output.set(4, 2, f02 * s40 + f12 * s41 + f22 * s42 + f32 * s43); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23); + output.set(3, 3, f03 * s30 + f13 * s31 + f23 * s32 + f33 * s33); + output.set(4, 3, f03 * s40 + f13 * s41 + f23 * s42 + f33 * s43); + return output; + } + + private static IMatrixSetterDouble multiplyMatrix5x4x1(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double f30 = matrix1.get(3, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f21 = matrix1.get(2, 1); + final double f31 = matrix1.get(3, 1); + final double f02 = matrix1.get(0, 2); + final double f12 = matrix1.get(1, 2); + final double f22 = matrix1.get(2, 2); + final double f32 = matrix1.get(3, 2); + final double f03 = matrix1.get(0, 3); + final double f13 = matrix1.get(1, 3); + final double f23 = matrix1.get(2, 3); + final double f33 = matrix1.get(3, 3); + final double f04 = matrix1.get(0, 4); + final double f14 = matrix1.get(1, 4); + final double f24 = matrix1.get(2, 4); + final double f34 = matrix1.get(3, 4); + final double s00 = matrix2.get(0, 0); + final double s01 = matrix2.get(0, 1); + final double s02 = matrix2.get(0, 2); + final double s03 = matrix2.get(0, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03); + output.set(0, 4, f04 * s00 + f14 * s01 + f24 * s02 + f34 * s03); return output; } private static IMatrixSetterDouble multiplyMatrix5x4x2(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final double f_c00 = matrix1.get(0, 0); - final double f_c10 = matrix1.get(1, 0); - final double f_c20 = matrix1.get(2, 0); - final double f_c30 = matrix1.get(3, 0); - final double f_c01 = matrix1.get(0, 1); - final double f_c11 = matrix1.get(1, 1); - final double f_c21 = matrix1.get(2, 1); - final double f_c31 = matrix1.get(3, 1); - final double f_c02 = matrix1.get(0, 2); - final double f_c12 = matrix1.get(1, 2); - final double f_c22 = matrix1.get(2, 2); - final double f_c32 = matrix1.get(3, 2); - final double f_c03 = matrix1.get(0, 3); - final double f_c13 = matrix1.get(1, 3); - final double f_c23 = matrix1.get(2, 3); - final double f_c33 = matrix1.get(3, 3); - final double f_c04 = matrix1.get(0, 4); - final double f_c14 = matrix1.get(1, 4); - final double f_c24 = matrix1.get(2, 4); - final double f_c34 = matrix1.get(3, 4); - final double s_c00 = matrix2.get(0, 0); - final double s_c10 = matrix2.get(1, 0); - final double s_c01 = matrix2.get(0, 1); - final double s_c11 = matrix2.get(1, 1); - final double s_c02 = matrix2.get(0, 2); - final double s_c12 = matrix2.get(1, 2); - final double s_c03 = matrix2.get(0, 3); - final double s_c13 = matrix2.get(1, 3); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03); - output.set(0, 4, f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02 + f_c34*s_c03); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13); - output.set(1, 4, f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12 + f_c34*s_c13); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double f30 = matrix1.get(3, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f21 = matrix1.get(2, 1); + final double f31 = matrix1.get(3, 1); + final double f02 = matrix1.get(0, 2); + final double f12 = matrix1.get(1, 2); + final double f22 = matrix1.get(2, 2); + final double f32 = matrix1.get(3, 2); + final double f03 = matrix1.get(0, 3); + final double f13 = matrix1.get(1, 3); + final double f23 = matrix1.get(2, 3); + final double f33 = matrix1.get(3, 3); + final double f04 = matrix1.get(0, 4); + final double f14 = matrix1.get(1, 4); + final double f24 = matrix1.get(2, 4); + final double f34 = matrix1.get(3, 4); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s02 = matrix2.get(0, 2); + final double s12 = matrix2.get(1, 2); + final double s03 = matrix2.get(0, 3); + final double s13 = matrix2.get(1, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13); + output.set(0, 4, f04 * s00 + f14 * s01 + f24 * s02 + f34 * s03); + output.set(1, 4, f04 * s10 + f14 * s11 + f24 * s12 + f34 * s13); return output; } private static IMatrixSetterDouble multiplyMatrix5x4x3(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final double f_c00 = matrix1.get(0, 0); - final double f_c10 = matrix1.get(1, 0); - final double f_c20 = matrix1.get(2, 0); - final double f_c30 = matrix1.get(3, 0); - final double f_c01 = matrix1.get(0, 1); - final double f_c11 = matrix1.get(1, 1); - final double f_c21 = matrix1.get(2, 1); - final double f_c31 = matrix1.get(3, 1); - final double f_c02 = matrix1.get(0, 2); - final double f_c12 = matrix1.get(1, 2); - final double f_c22 = matrix1.get(2, 2); - final double f_c32 = matrix1.get(3, 2); - final double f_c03 = matrix1.get(0, 3); - final double f_c13 = matrix1.get(1, 3); - final double f_c23 = matrix1.get(2, 3); - final double f_c33 = matrix1.get(3, 3); - final double f_c04 = matrix1.get(0, 4); - final double f_c14 = matrix1.get(1, 4); - final double f_c24 = matrix1.get(2, 4); - final double f_c34 = matrix1.get(3, 4); - final double s_c00 = matrix2.get(0, 0); - final double s_c10 = matrix2.get(1, 0); - final double s_c20 = matrix2.get(2, 0); - final double s_c01 = matrix2.get(0, 1); - final double s_c11 = matrix2.get(1, 1); - final double s_c21 = matrix2.get(2, 1); - final double s_c02 = matrix2.get(0, 2); - final double s_c12 = matrix2.get(1, 2); - final double s_c22 = matrix2.get(2, 2); - final double s_c03 = matrix2.get(0, 3); - final double s_c13 = matrix2.get(1, 3); - final double s_c23 = matrix2.get(2, 3); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03); - output.set(0, 4, f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02 + f_c34*s_c03); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13); - output.set(1, 4, f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12 + f_c34*s_c13); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23); - output.set(2, 4, f_c04*s_c20 + f_c14*s_c21 + f_c24*s_c22 + f_c34*s_c23); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double f30 = matrix1.get(3, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f21 = matrix1.get(2, 1); + final double f31 = matrix1.get(3, 1); + final double f02 = matrix1.get(0, 2); + final double f12 = matrix1.get(1, 2); + final double f22 = matrix1.get(2, 2); + final double f32 = matrix1.get(3, 2); + final double f03 = matrix1.get(0, 3); + final double f13 = matrix1.get(1, 3); + final double f23 = matrix1.get(2, 3); + final double f33 = matrix1.get(3, 3); + final double f04 = matrix1.get(0, 4); + final double f14 = matrix1.get(1, 4); + final double f24 = matrix1.get(2, 4); + final double f34 = matrix1.get(3, 4); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s21 = matrix2.get(2, 1); + final double s02 = matrix2.get(0, 2); + final double s12 = matrix2.get(1, 2); + final double s22 = matrix2.get(2, 2); + final double s03 = matrix2.get(0, 3); + final double s13 = matrix2.get(1, 3); + final double s23 = matrix2.get(2, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23); + output.set(0, 4, f04 * s00 + f14 * s01 + f24 * s02 + f34 * s03); + output.set(1, 4, f04 * s10 + f14 * s11 + f24 * s12 + f34 * s13); + output.set(2, 4, f04 * s20 + f14 * s21 + f24 * s22 + f34 * s23); return output; } private static IMatrixSetterDouble multiplyMatrix5x4x4(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final double f_c00 = matrix1.get(0, 0); - final double f_c10 = matrix1.get(1, 0); - final double f_c20 = matrix1.get(2, 0); - final double f_c30 = matrix1.get(3, 0); - final double f_c01 = matrix1.get(0, 1); - final double f_c11 = matrix1.get(1, 1); - final double f_c21 = matrix1.get(2, 1); - final double f_c31 = matrix1.get(3, 1); - final double f_c02 = matrix1.get(0, 2); - final double f_c12 = matrix1.get(1, 2); - final double f_c22 = matrix1.get(2, 2); - final double f_c32 = matrix1.get(3, 2); - final double f_c03 = matrix1.get(0, 3); - final double f_c13 = matrix1.get(1, 3); - final double f_c23 = matrix1.get(2, 3); - final double f_c33 = matrix1.get(3, 3); - final double f_c04 = matrix1.get(0, 4); - final double f_c14 = matrix1.get(1, 4); - final double f_c24 = matrix1.get(2, 4); - final double f_c34 = matrix1.get(3, 4); - final double s_c00 = matrix2.get(0, 0); - final double s_c10 = matrix2.get(1, 0); - final double s_c20 = matrix2.get(2, 0); - final double s_c30 = matrix2.get(3, 0); - final double s_c01 = matrix2.get(0, 1); - final double s_c11 = matrix2.get(1, 1); - final double s_c21 = matrix2.get(2, 1); - final double s_c31 = matrix2.get(3, 1); - final double s_c02 = matrix2.get(0, 2); - final double s_c12 = matrix2.get(1, 2); - final double s_c22 = matrix2.get(2, 2); - final double s_c32 = matrix2.get(3, 2); - final double s_c03 = matrix2.get(0, 3); - final double s_c13 = matrix2.get(1, 3); - final double s_c23 = matrix2.get(2, 3); - final double s_c33 = matrix2.get(3, 3); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03); - output.set(0, 4, f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02 + f_c34*s_c03); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13); - output.set(1, 4, f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12 + f_c34*s_c13); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23); - output.set(2, 4, f_c04*s_c20 + f_c14*s_c21 + f_c24*s_c22 + f_c34*s_c23); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33); - output.set(3, 3, f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32 + f_c33*s_c33); - output.set(3, 4, f_c04*s_c30 + f_c14*s_c31 + f_c24*s_c32 + f_c34*s_c33); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double f30 = matrix1.get(3, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f21 = matrix1.get(2, 1); + final double f31 = matrix1.get(3, 1); + final double f02 = matrix1.get(0, 2); + final double f12 = matrix1.get(1, 2); + final double f22 = matrix1.get(2, 2); + final double f32 = matrix1.get(3, 2); + final double f03 = matrix1.get(0, 3); + final double f13 = matrix1.get(1, 3); + final double f23 = matrix1.get(2, 3); + final double f33 = matrix1.get(3, 3); + final double f04 = matrix1.get(0, 4); + final double f14 = matrix1.get(1, 4); + final double f24 = matrix1.get(2, 4); + final double f34 = matrix1.get(3, 4); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + final double s30 = matrix2.get(3, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s21 = matrix2.get(2, 1); + final double s31 = matrix2.get(3, 1); + final double s02 = matrix2.get(0, 2); + final double s12 = matrix2.get(1, 2); + final double s22 = matrix2.get(2, 2); + final double s32 = matrix2.get(3, 2); + final double s03 = matrix2.get(0, 3); + final double s13 = matrix2.get(1, 3); + final double s23 = matrix2.get(2, 3); + final double s33 = matrix2.get(3, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23); + output.set(3, 3, f03 * s30 + f13 * s31 + f23 * s32 + f33 * s33); + output.set(0, 4, f04 * s00 + f14 * s01 + f24 * s02 + f34 * s03); + output.set(1, 4, f04 * s10 + f14 * s11 + f24 * s12 + f34 * s13); + output.set(2, 4, f04 * s20 + f14 * s21 + f24 * s22 + f34 * s23); + output.set(3, 4, f04 * s30 + f14 * s31 + f24 * s32 + f34 * s33); return output; } private static IMatrixSetterDouble multiplyMatrix5x4x5(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final double f_c00 = matrix1.get(0, 0); - final double f_c10 = matrix1.get(1, 0); - final double f_c20 = matrix1.get(2, 0); - final double f_c30 = matrix1.get(3, 0); - final double f_c01 = matrix1.get(0, 1); - final double f_c11 = matrix1.get(1, 1); - final double f_c21 = matrix1.get(2, 1); - final double f_c31 = matrix1.get(3, 1); - final double f_c02 = matrix1.get(0, 2); - final double f_c12 = matrix1.get(1, 2); - final double f_c22 = matrix1.get(2, 2); - final double f_c32 = matrix1.get(3, 2); - final double f_c03 = matrix1.get(0, 3); - final double f_c13 = matrix1.get(1, 3); - final double f_c23 = matrix1.get(2, 3); - final double f_c33 = matrix1.get(3, 3); - final double f_c04 = matrix1.get(0, 4); - final double f_c14 = matrix1.get(1, 4); - final double f_c24 = matrix1.get(2, 4); - final double f_c34 = matrix1.get(3, 4); - final double s_c00 = matrix2.get(0, 0); - final double s_c10 = matrix2.get(1, 0); - final double s_c20 = matrix2.get(2, 0); - final double s_c30 = matrix2.get(3, 0); - final double s_c40 = matrix2.get(4, 0); - final double s_c01 = matrix2.get(0, 1); - final double s_c11 = matrix2.get(1, 1); - final double s_c21 = matrix2.get(2, 1); - final double s_c31 = matrix2.get(3, 1); - final double s_c41 = matrix2.get(4, 1); - final double s_c02 = matrix2.get(0, 2); - final double s_c12 = matrix2.get(1, 2); - final double s_c22 = matrix2.get(2, 2); - final double s_c32 = matrix2.get(3, 2); - final double s_c42 = matrix2.get(4, 2); - final double s_c03 = matrix2.get(0, 3); - final double s_c13 = matrix2.get(1, 3); - final double s_c23 = matrix2.get(2, 3); - final double s_c33 = matrix2.get(3, 3); - final double s_c43 = matrix2.get(4, 3); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03); - output.set(0, 4, f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02 + f_c34*s_c03); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13); - output.set(1, 4, f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12 + f_c34*s_c13); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23); - output.set(2, 4, f_c04*s_c20 + f_c14*s_c21 + f_c24*s_c22 + f_c34*s_c23); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33); - output.set(3, 3, f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32 + f_c33*s_c33); - output.set(3, 4, f_c04*s_c30 + f_c14*s_c31 + f_c24*s_c32 + f_c34*s_c33); - output.set(4, 0, f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42 + f_c30*s_c43); - output.set(4, 1, f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42 + f_c31*s_c43); - output.set(4, 2, f_c02*s_c40 + f_c12*s_c41 + f_c22*s_c42 + f_c32*s_c43); - output.set(4, 3, f_c03*s_c40 + f_c13*s_c41 + f_c23*s_c42 + f_c33*s_c43); - output.set(4, 4, f_c04*s_c40 + f_c14*s_c41 + f_c24*s_c42 + f_c34*s_c43); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double f30 = matrix1.get(3, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f21 = matrix1.get(2, 1); + final double f31 = matrix1.get(3, 1); + final double f02 = matrix1.get(0, 2); + final double f12 = matrix1.get(1, 2); + final double f22 = matrix1.get(2, 2); + final double f32 = matrix1.get(3, 2); + final double f03 = matrix1.get(0, 3); + final double f13 = matrix1.get(1, 3); + final double f23 = matrix1.get(2, 3); + final double f33 = matrix1.get(3, 3); + final double f04 = matrix1.get(0, 4); + final double f14 = matrix1.get(1, 4); + final double f24 = matrix1.get(2, 4); + final double f34 = matrix1.get(3, 4); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + final double s30 = matrix2.get(3, 0); + final double s40 = matrix2.get(4, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s21 = matrix2.get(2, 1); + final double s31 = matrix2.get(3, 1); + final double s41 = matrix2.get(4, 1); + final double s02 = matrix2.get(0, 2); + final double s12 = matrix2.get(1, 2); + final double s22 = matrix2.get(2, 2); + final double s32 = matrix2.get(3, 2); + final double s42 = matrix2.get(4, 2); + final double s03 = matrix2.get(0, 3); + final double s13 = matrix2.get(1, 3); + final double s23 = matrix2.get(2, 3); + final double s33 = matrix2.get(3, 3); + final double s43 = matrix2.get(4, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33); + output.set(4, 0, f00 * s40 + f10 * s41 + f20 * s42 + f30 * s43); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33); + output.set(4, 1, f01 * s40 + f11 * s41 + f21 * s42 + f31 * s43); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33); + output.set(4, 2, f02 * s40 + f12 * s41 + f22 * s42 + f32 * s43); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23); + output.set(3, 3, f03 * s30 + f13 * s31 + f23 * s32 + f33 * s33); + output.set(4, 3, f03 * s40 + f13 * s41 + f23 * s42 + f33 * s43); + output.set(0, 4, f04 * s00 + f14 * s01 + f24 * s02 + f34 * s03); + output.set(1, 4, f04 * s10 + f14 * s11 + f24 * s12 + f34 * s13); + output.set(2, 4, f04 * s20 + f14 * s21 + f24 * s22 + f34 * s23); + output.set(3, 4, f04 * s30 + f14 * s31 + f24 * s32 + f34 * s33); + output.set(4, 4, f04 * s40 + f14 * s41 + f24 * s42 + f34 * s43); + return output; + } + + private static IMatrixSetterDouble multiplyMatrix1x5x1(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double f30 = matrix1.get(3, 0); + final double f40 = matrix1.get(4, 0); + final double s00 = matrix2.get(0, 0); + final double s01 = matrix2.get(0, 1); + final double s02 = matrix2.get(0, 2); + final double s03 = matrix2.get(0, 3); + final double s04 = matrix2.get(0, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + return output; + } + + private static IMatrixSetterDouble multiplyMatrix1x5x2(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double f30 = matrix1.get(3, 0); + final double f40 = matrix1.get(4, 0); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s02 = matrix2.get(0, 2); + final double s12 = matrix2.get(1, 2); + final double s03 = matrix2.get(0, 3); + final double s13 = matrix2.get(1, 3); + final double s04 = matrix2.get(0, 4); + final double s14 = matrix2.get(1, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + return output; + } + + private static IMatrixSetterDouble multiplyMatrix1x5x3(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double f30 = matrix1.get(3, 0); + final double f40 = matrix1.get(4, 0); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s21 = matrix2.get(2, 1); + final double s02 = matrix2.get(0, 2); + final double s12 = matrix2.get(1, 2); + final double s22 = matrix2.get(2, 2); + final double s03 = matrix2.get(0, 3); + final double s13 = matrix2.get(1, 3); + final double s23 = matrix2.get(2, 3); + final double s04 = matrix2.get(0, 4); + final double s14 = matrix2.get(1, 4); + final double s24 = matrix2.get(2, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24); + return output; + } + + private static IMatrixSetterDouble multiplyMatrix1x5x4(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double f30 = matrix1.get(3, 0); + final double f40 = matrix1.get(4, 0); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + final double s30 = matrix2.get(3, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s21 = matrix2.get(2, 1); + final double s31 = matrix2.get(3, 1); + final double s02 = matrix2.get(0, 2); + final double s12 = matrix2.get(1, 2); + final double s22 = matrix2.get(2, 2); + final double s32 = matrix2.get(3, 2); + final double s03 = matrix2.get(0, 3); + final double s13 = matrix2.get(1, 3); + final double s23 = matrix2.get(2, 3); + final double s33 = matrix2.get(3, 3); + final double s04 = matrix2.get(0, 4); + final double s14 = matrix2.get(1, 4); + final double s24 = matrix2.get(2, 4); + final double s34 = matrix2.get(3, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33 + f40 * s34); + return output; + } + + private static IMatrixSetterDouble multiplyMatrix1x5x5(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double f30 = matrix1.get(3, 0); + final double f40 = matrix1.get(4, 0); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + final double s30 = matrix2.get(3, 0); + final double s40 = matrix2.get(4, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s21 = matrix2.get(2, 1); + final double s31 = matrix2.get(3, 1); + final double s41 = matrix2.get(4, 1); + final double s02 = matrix2.get(0, 2); + final double s12 = matrix2.get(1, 2); + final double s22 = matrix2.get(2, 2); + final double s32 = matrix2.get(3, 2); + final double s42 = matrix2.get(4, 2); + final double s03 = matrix2.get(0, 3); + final double s13 = matrix2.get(1, 3); + final double s23 = matrix2.get(2, 3); + final double s33 = matrix2.get(3, 3); + final double s43 = matrix2.get(4, 3); + final double s04 = matrix2.get(0, 4); + final double s14 = matrix2.get(1, 4); + final double s24 = matrix2.get(2, 4); + final double s34 = matrix2.get(3, 4); + final double s44 = matrix2.get(4, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33 + f40 * s34); + output.set(4, 0, f00 * s40 + f10 * s41 + f20 * s42 + f30 * s43 + f40 * s44); + return output; + } + + private static IMatrixSetterDouble multiplyMatrix2x5x1(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double f30 = matrix1.get(3, 0); + final double f40 = matrix1.get(4, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f21 = matrix1.get(2, 1); + final double f31 = matrix1.get(3, 1); + final double f41 = matrix1.get(4, 1); + final double s00 = matrix2.get(0, 0); + final double s01 = matrix2.get(0, 1); + final double s02 = matrix2.get(0, 2); + final double s03 = matrix2.get(0, 3); + final double s04 = matrix2.get(0, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); return output; } private static IMatrixSetterDouble multiplyMatrix2x5x2(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final double f_c00 = matrix1.get(0, 0); - final double f_c10 = matrix1.get(1, 0); - final double f_c20 = matrix1.get(2, 0); - final double f_c30 = matrix1.get(3, 0); - final double f_c40 = matrix1.get(4, 0); - final double f_c01 = matrix1.get(0, 1); - final double f_c11 = matrix1.get(1, 1); - final double f_c21 = matrix1.get(2, 1); - final double f_c31 = matrix1.get(3, 1); - final double f_c41 = matrix1.get(4, 1); - final double s_c00 = matrix2.get(0, 0); - final double s_c10 = matrix2.get(1, 0); - final double s_c01 = matrix2.get(0, 1); - final double s_c11 = matrix2.get(1, 1); - final double s_c02 = matrix2.get(0, 2); - final double s_c12 = matrix2.get(1, 2); - final double s_c03 = matrix2.get(0, 3); - final double s_c13 = matrix2.get(1, 3); - final double s_c04 = matrix2.get(0, 4); - final double s_c14 = matrix2.get(1, 4); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double f30 = matrix1.get(3, 0); + final double f40 = matrix1.get(4, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f21 = matrix1.get(2, 1); + final double f31 = matrix1.get(3, 1); + final double f41 = matrix1.get(4, 1); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s02 = matrix2.get(0, 2); + final double s12 = matrix2.get(1, 2); + final double s03 = matrix2.get(0, 3); + final double s13 = matrix2.get(1, 3); + final double s04 = matrix2.get(0, 4); + final double s14 = matrix2.get(1, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14); return output; } private static IMatrixSetterDouble multiplyMatrix2x5x3(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final double f_c00 = matrix1.get(0, 0); - final double f_c10 = matrix1.get(1, 0); - final double f_c20 = matrix1.get(2, 0); - final double f_c30 = matrix1.get(3, 0); - final double f_c40 = matrix1.get(4, 0); - final double f_c01 = matrix1.get(0, 1); - final double f_c11 = matrix1.get(1, 1); - final double f_c21 = matrix1.get(2, 1); - final double f_c31 = matrix1.get(3, 1); - final double f_c41 = matrix1.get(4, 1); - final double s_c00 = matrix2.get(0, 0); - final double s_c10 = matrix2.get(1, 0); - final double s_c20 = matrix2.get(2, 0); - final double s_c01 = matrix2.get(0, 1); - final double s_c11 = matrix2.get(1, 1); - final double s_c21 = matrix2.get(2, 1); - final double s_c02 = matrix2.get(0, 2); - final double s_c12 = matrix2.get(1, 2); - final double s_c22 = matrix2.get(2, 2); - final double s_c03 = matrix2.get(0, 3); - final double s_c13 = matrix2.get(1, 3); - final double s_c23 = matrix2.get(2, 3); - final double s_c04 = matrix2.get(0, 4); - final double s_c14 = matrix2.get(1, 4); - final double s_c24 = matrix2.get(2, 4); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double f30 = matrix1.get(3, 0); + final double f40 = matrix1.get(4, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f21 = matrix1.get(2, 1); + final double f31 = matrix1.get(3, 1); + final double f41 = matrix1.get(4, 1); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s21 = matrix2.get(2, 1); + final double s02 = matrix2.get(0, 2); + final double s12 = matrix2.get(1, 2); + final double s22 = matrix2.get(2, 2); + final double s03 = matrix2.get(0, 3); + final double s13 = matrix2.get(1, 3); + final double s23 = matrix2.get(2, 3); + final double s04 = matrix2.get(0, 4); + final double s14 = matrix2.get(1, 4); + final double s24 = matrix2.get(2, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24); return output; } private static IMatrixSetterDouble multiplyMatrix2x5x4(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final double f_c00 = matrix1.get(0, 0); - final double f_c10 = matrix1.get(1, 0); - final double f_c20 = matrix1.get(2, 0); - final double f_c30 = matrix1.get(3, 0); - final double f_c40 = matrix1.get(4, 0); - final double f_c01 = matrix1.get(0, 1); - final double f_c11 = matrix1.get(1, 1); - final double f_c21 = matrix1.get(2, 1); - final double f_c31 = matrix1.get(3, 1); - final double f_c41 = matrix1.get(4, 1); - final double s_c00 = matrix2.get(0, 0); - final double s_c10 = matrix2.get(1, 0); - final double s_c20 = matrix2.get(2, 0); - final double s_c30 = matrix2.get(3, 0); - final double s_c01 = matrix2.get(0, 1); - final double s_c11 = matrix2.get(1, 1); - final double s_c21 = matrix2.get(2, 1); - final double s_c31 = matrix2.get(3, 1); - final double s_c02 = matrix2.get(0, 2); - final double s_c12 = matrix2.get(1, 2); - final double s_c22 = matrix2.get(2, 2); - final double s_c32 = matrix2.get(3, 2); - final double s_c03 = matrix2.get(0, 3); - final double s_c13 = matrix2.get(1, 3); - final double s_c23 = matrix2.get(2, 3); - final double s_c33 = matrix2.get(3, 3); - final double s_c04 = matrix2.get(0, 4); - final double s_c14 = matrix2.get(1, 4); - final double s_c24 = matrix2.get(2, 4); - final double s_c34 = matrix2.get(3, 4); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33 + f_c40*s_c34); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33 + f_c41*s_c34); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double f30 = matrix1.get(3, 0); + final double f40 = matrix1.get(4, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f21 = matrix1.get(2, 1); + final double f31 = matrix1.get(3, 1); + final double f41 = matrix1.get(4, 1); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + final double s30 = matrix2.get(3, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s21 = matrix2.get(2, 1); + final double s31 = matrix2.get(3, 1); + final double s02 = matrix2.get(0, 2); + final double s12 = matrix2.get(1, 2); + final double s22 = matrix2.get(2, 2); + final double s32 = matrix2.get(3, 2); + final double s03 = matrix2.get(0, 3); + final double s13 = matrix2.get(1, 3); + final double s23 = matrix2.get(2, 3); + final double s33 = matrix2.get(3, 3); + final double s04 = matrix2.get(0, 4); + final double s14 = matrix2.get(1, 4); + final double s24 = matrix2.get(2, 4); + final double s34 = matrix2.get(3, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33 + f40 * s34); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33 + f41 * s34); return output; } private static IMatrixSetterDouble multiplyMatrix2x5x5(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final double f_c00 = matrix1.get(0, 0); - final double f_c10 = matrix1.get(1, 0); - final double f_c20 = matrix1.get(2, 0); - final double f_c30 = matrix1.get(3, 0); - final double f_c40 = matrix1.get(4, 0); - final double f_c01 = matrix1.get(0, 1); - final double f_c11 = matrix1.get(1, 1); - final double f_c21 = matrix1.get(2, 1); - final double f_c31 = matrix1.get(3, 1); - final double f_c41 = matrix1.get(4, 1); - final double s_c00 = matrix2.get(0, 0); - final double s_c10 = matrix2.get(1, 0); - final double s_c20 = matrix2.get(2, 0); - final double s_c30 = matrix2.get(3, 0); - final double s_c40 = matrix2.get(4, 0); - final double s_c01 = matrix2.get(0, 1); - final double s_c11 = matrix2.get(1, 1); - final double s_c21 = matrix2.get(2, 1); - final double s_c31 = matrix2.get(3, 1); - final double s_c41 = matrix2.get(4, 1); - final double s_c02 = matrix2.get(0, 2); - final double s_c12 = matrix2.get(1, 2); - final double s_c22 = matrix2.get(2, 2); - final double s_c32 = matrix2.get(3, 2); - final double s_c42 = matrix2.get(4, 2); - final double s_c03 = matrix2.get(0, 3); - final double s_c13 = matrix2.get(1, 3); - final double s_c23 = matrix2.get(2, 3); - final double s_c33 = matrix2.get(3, 3); - final double s_c43 = matrix2.get(4, 3); - final double s_c04 = matrix2.get(0, 4); - final double s_c14 = matrix2.get(1, 4); - final double s_c24 = matrix2.get(2, 4); - final double s_c34 = matrix2.get(3, 4); - final double s_c44 = matrix2.get(4, 4); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33 + f_c40*s_c34); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33 + f_c41*s_c34); - output.set(4, 0, f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42 + f_c30*s_c43 + f_c40*s_c44); - output.set(4, 1, f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42 + f_c31*s_c43 + f_c41*s_c44); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double f30 = matrix1.get(3, 0); + final double f40 = matrix1.get(4, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f21 = matrix1.get(2, 1); + final double f31 = matrix1.get(3, 1); + final double f41 = matrix1.get(4, 1); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + final double s30 = matrix2.get(3, 0); + final double s40 = matrix2.get(4, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s21 = matrix2.get(2, 1); + final double s31 = matrix2.get(3, 1); + final double s41 = matrix2.get(4, 1); + final double s02 = matrix2.get(0, 2); + final double s12 = matrix2.get(1, 2); + final double s22 = matrix2.get(2, 2); + final double s32 = matrix2.get(3, 2); + final double s42 = matrix2.get(4, 2); + final double s03 = matrix2.get(0, 3); + final double s13 = matrix2.get(1, 3); + final double s23 = matrix2.get(2, 3); + final double s33 = matrix2.get(3, 3); + final double s43 = matrix2.get(4, 3); + final double s04 = matrix2.get(0, 4); + final double s14 = matrix2.get(1, 4); + final double s24 = matrix2.get(2, 4); + final double s34 = matrix2.get(3, 4); + final double s44 = matrix2.get(4, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33 + f40 * s34); + output.set(4, 0, f00 * s40 + f10 * s41 + f20 * s42 + f30 * s43 + f40 * s44); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33 + f41 * s34); + output.set(4, 1, f01 * s40 + f11 * s41 + f21 * s42 + f31 * s43 + f41 * s44); + return output; + } + + private static IMatrixSetterDouble multiplyMatrix3x5x1(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double f30 = matrix1.get(3, 0); + final double f40 = matrix1.get(4, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f21 = matrix1.get(2, 1); + final double f31 = matrix1.get(3, 1); + final double f41 = matrix1.get(4, 1); + final double f02 = matrix1.get(0, 2); + final double f12 = matrix1.get(1, 2); + final double f22 = matrix1.get(2, 2); + final double f32 = matrix1.get(3, 2); + final double f42 = matrix1.get(4, 2); + final double s00 = matrix2.get(0, 0); + final double s01 = matrix2.get(0, 1); + final double s02 = matrix2.get(0, 2); + final double s03 = matrix2.get(0, 3); + final double s04 = matrix2.get(0, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04); return output; } private static IMatrixSetterDouble multiplyMatrix3x5x2(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final double f_c00 = matrix1.get(0, 0); - final double f_c10 = matrix1.get(1, 0); - final double f_c20 = matrix1.get(2, 0); - final double f_c30 = matrix1.get(3, 0); - final double f_c40 = matrix1.get(4, 0); - final double f_c01 = matrix1.get(0, 1); - final double f_c11 = matrix1.get(1, 1); - final double f_c21 = matrix1.get(2, 1); - final double f_c31 = matrix1.get(3, 1); - final double f_c41 = matrix1.get(4, 1); - final double f_c02 = matrix1.get(0, 2); - final double f_c12 = matrix1.get(1, 2); - final double f_c22 = matrix1.get(2, 2); - final double f_c32 = matrix1.get(3, 2); - final double f_c42 = matrix1.get(4, 2); - final double s_c00 = matrix2.get(0, 0); - final double s_c10 = matrix2.get(1, 0); - final double s_c01 = matrix2.get(0, 1); - final double s_c11 = matrix2.get(1, 1); - final double s_c02 = matrix2.get(0, 2); - final double s_c12 = matrix2.get(1, 2); - final double s_c03 = matrix2.get(0, 3); - final double s_c13 = matrix2.get(1, 3); - final double s_c04 = matrix2.get(0, 4); - final double s_c14 = matrix2.get(1, 4); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double f30 = matrix1.get(3, 0); + final double f40 = matrix1.get(4, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f21 = matrix1.get(2, 1); + final double f31 = matrix1.get(3, 1); + final double f41 = matrix1.get(4, 1); + final double f02 = matrix1.get(0, 2); + final double f12 = matrix1.get(1, 2); + final double f22 = matrix1.get(2, 2); + final double f32 = matrix1.get(3, 2); + final double f42 = matrix1.get(4, 2); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s02 = matrix2.get(0, 2); + final double s12 = matrix2.get(1, 2); + final double s03 = matrix2.get(0, 3); + final double s13 = matrix2.get(1, 3); + final double s04 = matrix2.get(0, 4); + final double s14 = matrix2.get(1, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14); return output; } private static IMatrixSetterDouble multiplyMatrix3x5x3(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final double f_c00 = matrix1.get(0, 0); - final double f_c10 = matrix1.get(1, 0); - final double f_c20 = matrix1.get(2, 0); - final double f_c30 = matrix1.get(3, 0); - final double f_c40 = matrix1.get(4, 0); - final double f_c01 = matrix1.get(0, 1); - final double f_c11 = matrix1.get(1, 1); - final double f_c21 = matrix1.get(2, 1); - final double f_c31 = matrix1.get(3, 1); - final double f_c41 = matrix1.get(4, 1); - final double f_c02 = matrix1.get(0, 2); - final double f_c12 = matrix1.get(1, 2); - final double f_c22 = matrix1.get(2, 2); - final double f_c32 = matrix1.get(3, 2); - final double f_c42 = matrix1.get(4, 2); - final double s_c00 = matrix2.get(0, 0); - final double s_c10 = matrix2.get(1, 0); - final double s_c20 = matrix2.get(2, 0); - final double s_c01 = matrix2.get(0, 1); - final double s_c11 = matrix2.get(1, 1); - final double s_c21 = matrix2.get(2, 1); - final double s_c02 = matrix2.get(0, 2); - final double s_c12 = matrix2.get(1, 2); - final double s_c22 = matrix2.get(2, 2); - final double s_c03 = matrix2.get(0, 3); - final double s_c13 = matrix2.get(1, 3); - final double s_c23 = matrix2.get(2, 3); - final double s_c04 = matrix2.get(0, 4); - final double s_c14 = matrix2.get(1, 4); - final double s_c24 = matrix2.get(2, 4); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23 + f_c42*s_c24); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double f30 = matrix1.get(3, 0); + final double f40 = matrix1.get(4, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f21 = matrix1.get(2, 1); + final double f31 = matrix1.get(3, 1); + final double f41 = matrix1.get(4, 1); + final double f02 = matrix1.get(0, 2); + final double f12 = matrix1.get(1, 2); + final double f22 = matrix1.get(2, 2); + final double f32 = matrix1.get(3, 2); + final double f42 = matrix1.get(4, 2); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s21 = matrix2.get(2, 1); + final double s02 = matrix2.get(0, 2); + final double s12 = matrix2.get(1, 2); + final double s22 = matrix2.get(2, 2); + final double s03 = matrix2.get(0, 3); + final double s13 = matrix2.get(1, 3); + final double s23 = matrix2.get(2, 3); + final double s04 = matrix2.get(0, 4); + final double s14 = matrix2.get(1, 4); + final double s24 = matrix2.get(2, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23 + f42 * s24); return output; } private static IMatrixSetterDouble multiplyMatrix3x5x4(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final double f_c00 = matrix1.get(0, 0); - final double f_c10 = matrix1.get(1, 0); - final double f_c20 = matrix1.get(2, 0); - final double f_c30 = matrix1.get(3, 0); - final double f_c40 = matrix1.get(4, 0); - final double f_c01 = matrix1.get(0, 1); - final double f_c11 = matrix1.get(1, 1); - final double f_c21 = matrix1.get(2, 1); - final double f_c31 = matrix1.get(3, 1); - final double f_c41 = matrix1.get(4, 1); - final double f_c02 = matrix1.get(0, 2); - final double f_c12 = matrix1.get(1, 2); - final double f_c22 = matrix1.get(2, 2); - final double f_c32 = matrix1.get(3, 2); - final double f_c42 = matrix1.get(4, 2); - final double s_c00 = matrix2.get(0, 0); - final double s_c10 = matrix2.get(1, 0); - final double s_c20 = matrix2.get(2, 0); - final double s_c30 = matrix2.get(3, 0); - final double s_c01 = matrix2.get(0, 1); - final double s_c11 = matrix2.get(1, 1); - final double s_c21 = matrix2.get(2, 1); - final double s_c31 = matrix2.get(3, 1); - final double s_c02 = matrix2.get(0, 2); - final double s_c12 = matrix2.get(1, 2); - final double s_c22 = matrix2.get(2, 2); - final double s_c32 = matrix2.get(3, 2); - final double s_c03 = matrix2.get(0, 3); - final double s_c13 = matrix2.get(1, 3); - final double s_c23 = matrix2.get(2, 3); - final double s_c33 = matrix2.get(3, 3); - final double s_c04 = matrix2.get(0, 4); - final double s_c14 = matrix2.get(1, 4); - final double s_c24 = matrix2.get(2, 4); - final double s_c34 = matrix2.get(3, 4); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23 + f_c42*s_c24); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33 + f_c40*s_c34); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33 + f_c41*s_c34); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33 + f_c42*s_c34); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double f30 = matrix1.get(3, 0); + final double f40 = matrix1.get(4, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f21 = matrix1.get(2, 1); + final double f31 = matrix1.get(3, 1); + final double f41 = matrix1.get(4, 1); + final double f02 = matrix1.get(0, 2); + final double f12 = matrix1.get(1, 2); + final double f22 = matrix1.get(2, 2); + final double f32 = matrix1.get(3, 2); + final double f42 = matrix1.get(4, 2); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + final double s30 = matrix2.get(3, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s21 = matrix2.get(2, 1); + final double s31 = matrix2.get(3, 1); + final double s02 = matrix2.get(0, 2); + final double s12 = matrix2.get(1, 2); + final double s22 = matrix2.get(2, 2); + final double s32 = matrix2.get(3, 2); + final double s03 = matrix2.get(0, 3); + final double s13 = matrix2.get(1, 3); + final double s23 = matrix2.get(2, 3); + final double s33 = matrix2.get(3, 3); + final double s04 = matrix2.get(0, 4); + final double s14 = matrix2.get(1, 4); + final double s24 = matrix2.get(2, 4); + final double s34 = matrix2.get(3, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33 + f40 * s34); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33 + f41 * s34); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23 + f42 * s24); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33 + f42 * s34); return output; } private static IMatrixSetterDouble multiplyMatrix3x5x5(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final double f_c00 = matrix1.get(0, 0); - final double f_c10 = matrix1.get(1, 0); - final double f_c20 = matrix1.get(2, 0); - final double f_c30 = matrix1.get(3, 0); - final double f_c40 = matrix1.get(4, 0); - final double f_c01 = matrix1.get(0, 1); - final double f_c11 = matrix1.get(1, 1); - final double f_c21 = matrix1.get(2, 1); - final double f_c31 = matrix1.get(3, 1); - final double f_c41 = matrix1.get(4, 1); - final double f_c02 = matrix1.get(0, 2); - final double f_c12 = matrix1.get(1, 2); - final double f_c22 = matrix1.get(2, 2); - final double f_c32 = matrix1.get(3, 2); - final double f_c42 = matrix1.get(4, 2); - final double s_c00 = matrix2.get(0, 0); - final double s_c10 = matrix2.get(1, 0); - final double s_c20 = matrix2.get(2, 0); - final double s_c30 = matrix2.get(3, 0); - final double s_c40 = matrix2.get(4, 0); - final double s_c01 = matrix2.get(0, 1); - final double s_c11 = matrix2.get(1, 1); - final double s_c21 = matrix2.get(2, 1); - final double s_c31 = matrix2.get(3, 1); - final double s_c41 = matrix2.get(4, 1); - final double s_c02 = matrix2.get(0, 2); - final double s_c12 = matrix2.get(1, 2); - final double s_c22 = matrix2.get(2, 2); - final double s_c32 = matrix2.get(3, 2); - final double s_c42 = matrix2.get(4, 2); - final double s_c03 = matrix2.get(0, 3); - final double s_c13 = matrix2.get(1, 3); - final double s_c23 = matrix2.get(2, 3); - final double s_c33 = matrix2.get(3, 3); - final double s_c43 = matrix2.get(4, 3); - final double s_c04 = matrix2.get(0, 4); - final double s_c14 = matrix2.get(1, 4); - final double s_c24 = matrix2.get(2, 4); - final double s_c34 = matrix2.get(3, 4); - final double s_c44 = matrix2.get(4, 4); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23 + f_c42*s_c24); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33 + f_c40*s_c34); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33 + f_c41*s_c34); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33 + f_c42*s_c34); - output.set(4, 0, f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42 + f_c30*s_c43 + f_c40*s_c44); - output.set(4, 1, f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42 + f_c31*s_c43 + f_c41*s_c44); - output.set(4, 2, f_c02*s_c40 + f_c12*s_c41 + f_c22*s_c42 + f_c32*s_c43 + f_c42*s_c44); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double f30 = matrix1.get(3, 0); + final double f40 = matrix1.get(4, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f21 = matrix1.get(2, 1); + final double f31 = matrix1.get(3, 1); + final double f41 = matrix1.get(4, 1); + final double f02 = matrix1.get(0, 2); + final double f12 = matrix1.get(1, 2); + final double f22 = matrix1.get(2, 2); + final double f32 = matrix1.get(3, 2); + final double f42 = matrix1.get(4, 2); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + final double s30 = matrix2.get(3, 0); + final double s40 = matrix2.get(4, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s21 = matrix2.get(2, 1); + final double s31 = matrix2.get(3, 1); + final double s41 = matrix2.get(4, 1); + final double s02 = matrix2.get(0, 2); + final double s12 = matrix2.get(1, 2); + final double s22 = matrix2.get(2, 2); + final double s32 = matrix2.get(3, 2); + final double s42 = matrix2.get(4, 2); + final double s03 = matrix2.get(0, 3); + final double s13 = matrix2.get(1, 3); + final double s23 = matrix2.get(2, 3); + final double s33 = matrix2.get(3, 3); + final double s43 = matrix2.get(4, 3); + final double s04 = matrix2.get(0, 4); + final double s14 = matrix2.get(1, 4); + final double s24 = matrix2.get(2, 4); + final double s34 = matrix2.get(3, 4); + final double s44 = matrix2.get(4, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33 + f40 * s34); + output.set(4, 0, f00 * s40 + f10 * s41 + f20 * s42 + f30 * s43 + f40 * s44); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33 + f41 * s34); + output.set(4, 1, f01 * s40 + f11 * s41 + f21 * s42 + f31 * s43 + f41 * s44); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23 + f42 * s24); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33 + f42 * s34); + output.set(4, 2, f02 * s40 + f12 * s41 + f22 * s42 + f32 * s43 + f42 * s44); + return output; + } + + private static IMatrixSetterDouble multiplyMatrix4x5x1(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double f30 = matrix1.get(3, 0); + final double f40 = matrix1.get(4, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f21 = matrix1.get(2, 1); + final double f31 = matrix1.get(3, 1); + final double f41 = matrix1.get(4, 1); + final double f02 = matrix1.get(0, 2); + final double f12 = matrix1.get(1, 2); + final double f22 = matrix1.get(2, 2); + final double f32 = matrix1.get(3, 2); + final double f42 = matrix1.get(4, 2); + final double f03 = matrix1.get(0, 3); + final double f13 = matrix1.get(1, 3); + final double f23 = matrix1.get(2, 3); + final double f33 = matrix1.get(3, 3); + final double f43 = matrix1.get(4, 3); + final double s00 = matrix2.get(0, 0); + final double s01 = matrix2.get(0, 1); + final double s02 = matrix2.get(0, 2); + final double s03 = matrix2.get(0, 3); + final double s04 = matrix2.get(0, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03 + f43 * s04); return output; } private static IMatrixSetterDouble multiplyMatrix4x5x2(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final double f_c00 = matrix1.get(0, 0); - final double f_c10 = matrix1.get(1, 0); - final double f_c20 = matrix1.get(2, 0); - final double f_c30 = matrix1.get(3, 0); - final double f_c40 = matrix1.get(4, 0); - final double f_c01 = matrix1.get(0, 1); - final double f_c11 = matrix1.get(1, 1); - final double f_c21 = matrix1.get(2, 1); - final double f_c31 = matrix1.get(3, 1); - final double f_c41 = matrix1.get(4, 1); - final double f_c02 = matrix1.get(0, 2); - final double f_c12 = matrix1.get(1, 2); - final double f_c22 = matrix1.get(2, 2); - final double f_c32 = matrix1.get(3, 2); - final double f_c42 = matrix1.get(4, 2); - final double f_c03 = matrix1.get(0, 3); - final double f_c13 = matrix1.get(1, 3); - final double f_c23 = matrix1.get(2, 3); - final double f_c33 = matrix1.get(3, 3); - final double f_c43 = matrix1.get(4, 3); - final double s_c00 = matrix2.get(0, 0); - final double s_c10 = matrix2.get(1, 0); - final double s_c01 = matrix2.get(0, 1); - final double s_c11 = matrix2.get(1, 1); - final double s_c02 = matrix2.get(0, 2); - final double s_c12 = matrix2.get(1, 2); - final double s_c03 = matrix2.get(0, 3); - final double s_c13 = matrix2.get(1, 3); - final double s_c04 = matrix2.get(0, 4); - final double s_c14 = matrix2.get(1, 4); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03 + f_c43*s_c04); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13 + f_c43*s_c14); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double f30 = matrix1.get(3, 0); + final double f40 = matrix1.get(4, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f21 = matrix1.get(2, 1); + final double f31 = matrix1.get(3, 1); + final double f41 = matrix1.get(4, 1); + final double f02 = matrix1.get(0, 2); + final double f12 = matrix1.get(1, 2); + final double f22 = matrix1.get(2, 2); + final double f32 = matrix1.get(3, 2); + final double f42 = matrix1.get(4, 2); + final double f03 = matrix1.get(0, 3); + final double f13 = matrix1.get(1, 3); + final double f23 = matrix1.get(2, 3); + final double f33 = matrix1.get(3, 3); + final double f43 = matrix1.get(4, 3); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s02 = matrix2.get(0, 2); + final double s12 = matrix2.get(1, 2); + final double s03 = matrix2.get(0, 3); + final double s13 = matrix2.get(1, 3); + final double s04 = matrix2.get(0, 4); + final double s14 = matrix2.get(1, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03 + f43 * s04); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13 + f43 * s14); return output; } private static IMatrixSetterDouble multiplyMatrix4x5x3(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final double f_c00 = matrix1.get(0, 0); - final double f_c10 = matrix1.get(1, 0); - final double f_c20 = matrix1.get(2, 0); - final double f_c30 = matrix1.get(3, 0); - final double f_c40 = matrix1.get(4, 0); - final double f_c01 = matrix1.get(0, 1); - final double f_c11 = matrix1.get(1, 1); - final double f_c21 = matrix1.get(2, 1); - final double f_c31 = matrix1.get(3, 1); - final double f_c41 = matrix1.get(4, 1); - final double f_c02 = matrix1.get(0, 2); - final double f_c12 = matrix1.get(1, 2); - final double f_c22 = matrix1.get(2, 2); - final double f_c32 = matrix1.get(3, 2); - final double f_c42 = matrix1.get(4, 2); - final double f_c03 = matrix1.get(0, 3); - final double f_c13 = matrix1.get(1, 3); - final double f_c23 = matrix1.get(2, 3); - final double f_c33 = matrix1.get(3, 3); - final double f_c43 = matrix1.get(4, 3); - final double s_c00 = matrix2.get(0, 0); - final double s_c10 = matrix2.get(1, 0); - final double s_c20 = matrix2.get(2, 0); - final double s_c01 = matrix2.get(0, 1); - final double s_c11 = matrix2.get(1, 1); - final double s_c21 = matrix2.get(2, 1); - final double s_c02 = matrix2.get(0, 2); - final double s_c12 = matrix2.get(1, 2); - final double s_c22 = matrix2.get(2, 2); - final double s_c03 = matrix2.get(0, 3); - final double s_c13 = matrix2.get(1, 3); - final double s_c23 = matrix2.get(2, 3); - final double s_c04 = matrix2.get(0, 4); - final double s_c14 = matrix2.get(1, 4); - final double s_c24 = matrix2.get(2, 4); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03 + f_c43*s_c04); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13 + f_c43*s_c14); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23 + f_c42*s_c24); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23 + f_c43*s_c24); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double f30 = matrix1.get(3, 0); + final double f40 = matrix1.get(4, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f21 = matrix1.get(2, 1); + final double f31 = matrix1.get(3, 1); + final double f41 = matrix1.get(4, 1); + final double f02 = matrix1.get(0, 2); + final double f12 = matrix1.get(1, 2); + final double f22 = matrix1.get(2, 2); + final double f32 = matrix1.get(3, 2); + final double f42 = matrix1.get(4, 2); + final double f03 = matrix1.get(0, 3); + final double f13 = matrix1.get(1, 3); + final double f23 = matrix1.get(2, 3); + final double f33 = matrix1.get(3, 3); + final double f43 = matrix1.get(4, 3); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s21 = matrix2.get(2, 1); + final double s02 = matrix2.get(0, 2); + final double s12 = matrix2.get(1, 2); + final double s22 = matrix2.get(2, 2); + final double s03 = matrix2.get(0, 3); + final double s13 = matrix2.get(1, 3); + final double s23 = matrix2.get(2, 3); + final double s04 = matrix2.get(0, 4); + final double s14 = matrix2.get(1, 4); + final double s24 = matrix2.get(2, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23 + f42 * s24); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03 + f43 * s04); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13 + f43 * s14); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23 + f43 * s24); return output; } private static IMatrixSetterDouble multiplyMatrix4x5x4(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final double f_c00 = matrix1.get(0, 0); - final double f_c10 = matrix1.get(1, 0); - final double f_c20 = matrix1.get(2, 0); - final double f_c30 = matrix1.get(3, 0); - final double f_c40 = matrix1.get(4, 0); - final double f_c01 = matrix1.get(0, 1); - final double f_c11 = matrix1.get(1, 1); - final double f_c21 = matrix1.get(2, 1); - final double f_c31 = matrix1.get(3, 1); - final double f_c41 = matrix1.get(4, 1); - final double f_c02 = matrix1.get(0, 2); - final double f_c12 = matrix1.get(1, 2); - final double f_c22 = matrix1.get(2, 2); - final double f_c32 = matrix1.get(3, 2); - final double f_c42 = matrix1.get(4, 2); - final double f_c03 = matrix1.get(0, 3); - final double f_c13 = matrix1.get(1, 3); - final double f_c23 = matrix1.get(2, 3); - final double f_c33 = matrix1.get(3, 3); - final double f_c43 = matrix1.get(4, 3); - final double s_c00 = matrix2.get(0, 0); - final double s_c10 = matrix2.get(1, 0); - final double s_c20 = matrix2.get(2, 0); - final double s_c30 = matrix2.get(3, 0); - final double s_c01 = matrix2.get(0, 1); - final double s_c11 = matrix2.get(1, 1); - final double s_c21 = matrix2.get(2, 1); - final double s_c31 = matrix2.get(3, 1); - final double s_c02 = matrix2.get(0, 2); - final double s_c12 = matrix2.get(1, 2); - final double s_c22 = matrix2.get(2, 2); - final double s_c32 = matrix2.get(3, 2); - final double s_c03 = matrix2.get(0, 3); - final double s_c13 = matrix2.get(1, 3); - final double s_c23 = matrix2.get(2, 3); - final double s_c33 = matrix2.get(3, 3); - final double s_c04 = matrix2.get(0, 4); - final double s_c14 = matrix2.get(1, 4); - final double s_c24 = matrix2.get(2, 4); - final double s_c34 = matrix2.get(3, 4); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03 + f_c43*s_c04); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13 + f_c43*s_c14); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23 + f_c42*s_c24); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23 + f_c43*s_c24); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33 + f_c40*s_c34); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33 + f_c41*s_c34); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33 + f_c42*s_c34); - output.set(3, 3, f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32 + f_c33*s_c33 + f_c43*s_c34); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double f30 = matrix1.get(3, 0); + final double f40 = matrix1.get(4, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f21 = matrix1.get(2, 1); + final double f31 = matrix1.get(3, 1); + final double f41 = matrix1.get(4, 1); + final double f02 = matrix1.get(0, 2); + final double f12 = matrix1.get(1, 2); + final double f22 = matrix1.get(2, 2); + final double f32 = matrix1.get(3, 2); + final double f42 = matrix1.get(4, 2); + final double f03 = matrix1.get(0, 3); + final double f13 = matrix1.get(1, 3); + final double f23 = matrix1.get(2, 3); + final double f33 = matrix1.get(3, 3); + final double f43 = matrix1.get(4, 3); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + final double s30 = matrix2.get(3, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s21 = matrix2.get(2, 1); + final double s31 = matrix2.get(3, 1); + final double s02 = matrix2.get(0, 2); + final double s12 = matrix2.get(1, 2); + final double s22 = matrix2.get(2, 2); + final double s32 = matrix2.get(3, 2); + final double s03 = matrix2.get(0, 3); + final double s13 = matrix2.get(1, 3); + final double s23 = matrix2.get(2, 3); + final double s33 = matrix2.get(3, 3); + final double s04 = matrix2.get(0, 4); + final double s14 = matrix2.get(1, 4); + final double s24 = matrix2.get(2, 4); + final double s34 = matrix2.get(3, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33 + f40 * s34); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33 + f41 * s34); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23 + f42 * s24); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33 + f42 * s34); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03 + f43 * s04); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13 + f43 * s14); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23 + f43 * s24); + output.set(3, 3, f03 * s30 + f13 * s31 + f23 * s32 + f33 * s33 + f43 * s34); return output; } private static IMatrixSetterDouble multiplyMatrix4x5x5(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final double f_c00 = matrix1.get(0, 0); - final double f_c10 = matrix1.get(1, 0); - final double f_c20 = matrix1.get(2, 0); - final double f_c30 = matrix1.get(3, 0); - final double f_c40 = matrix1.get(4, 0); - final double f_c01 = matrix1.get(0, 1); - final double f_c11 = matrix1.get(1, 1); - final double f_c21 = matrix1.get(2, 1); - final double f_c31 = matrix1.get(3, 1); - final double f_c41 = matrix1.get(4, 1); - final double f_c02 = matrix1.get(0, 2); - final double f_c12 = matrix1.get(1, 2); - final double f_c22 = matrix1.get(2, 2); - final double f_c32 = matrix1.get(3, 2); - final double f_c42 = matrix1.get(4, 2); - final double f_c03 = matrix1.get(0, 3); - final double f_c13 = matrix1.get(1, 3); - final double f_c23 = matrix1.get(2, 3); - final double f_c33 = matrix1.get(3, 3); - final double f_c43 = matrix1.get(4, 3); - final double s_c00 = matrix2.get(0, 0); - final double s_c10 = matrix2.get(1, 0); - final double s_c20 = matrix2.get(2, 0); - final double s_c30 = matrix2.get(3, 0); - final double s_c40 = matrix2.get(4, 0); - final double s_c01 = matrix2.get(0, 1); - final double s_c11 = matrix2.get(1, 1); - final double s_c21 = matrix2.get(2, 1); - final double s_c31 = matrix2.get(3, 1); - final double s_c41 = matrix2.get(4, 1); - final double s_c02 = matrix2.get(0, 2); - final double s_c12 = matrix2.get(1, 2); - final double s_c22 = matrix2.get(2, 2); - final double s_c32 = matrix2.get(3, 2); - final double s_c42 = matrix2.get(4, 2); - final double s_c03 = matrix2.get(0, 3); - final double s_c13 = matrix2.get(1, 3); - final double s_c23 = matrix2.get(2, 3); - final double s_c33 = matrix2.get(3, 3); - final double s_c43 = matrix2.get(4, 3); - final double s_c04 = matrix2.get(0, 4); - final double s_c14 = matrix2.get(1, 4); - final double s_c24 = matrix2.get(2, 4); - final double s_c34 = matrix2.get(3, 4); - final double s_c44 = matrix2.get(4, 4); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03 + f_c43*s_c04); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13 + f_c43*s_c14); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23 + f_c42*s_c24); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23 + f_c43*s_c24); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33 + f_c40*s_c34); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33 + f_c41*s_c34); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33 + f_c42*s_c34); - output.set(3, 3, f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32 + f_c33*s_c33 + f_c43*s_c34); - output.set(4, 0, f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42 + f_c30*s_c43 + f_c40*s_c44); - output.set(4, 1, f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42 + f_c31*s_c43 + f_c41*s_c44); - output.set(4, 2, f_c02*s_c40 + f_c12*s_c41 + f_c22*s_c42 + f_c32*s_c43 + f_c42*s_c44); - output.set(4, 3, f_c03*s_c40 + f_c13*s_c41 + f_c23*s_c42 + f_c33*s_c43 + f_c43*s_c44); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double f30 = matrix1.get(3, 0); + final double f40 = matrix1.get(4, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f21 = matrix1.get(2, 1); + final double f31 = matrix1.get(3, 1); + final double f41 = matrix1.get(4, 1); + final double f02 = matrix1.get(0, 2); + final double f12 = matrix1.get(1, 2); + final double f22 = matrix1.get(2, 2); + final double f32 = matrix1.get(3, 2); + final double f42 = matrix1.get(4, 2); + final double f03 = matrix1.get(0, 3); + final double f13 = matrix1.get(1, 3); + final double f23 = matrix1.get(2, 3); + final double f33 = matrix1.get(3, 3); + final double f43 = matrix1.get(4, 3); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + final double s30 = matrix2.get(3, 0); + final double s40 = matrix2.get(4, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s21 = matrix2.get(2, 1); + final double s31 = matrix2.get(3, 1); + final double s41 = matrix2.get(4, 1); + final double s02 = matrix2.get(0, 2); + final double s12 = matrix2.get(1, 2); + final double s22 = matrix2.get(2, 2); + final double s32 = matrix2.get(3, 2); + final double s42 = matrix2.get(4, 2); + final double s03 = matrix2.get(0, 3); + final double s13 = matrix2.get(1, 3); + final double s23 = matrix2.get(2, 3); + final double s33 = matrix2.get(3, 3); + final double s43 = matrix2.get(4, 3); + final double s04 = matrix2.get(0, 4); + final double s14 = matrix2.get(1, 4); + final double s24 = matrix2.get(2, 4); + final double s34 = matrix2.get(3, 4); + final double s44 = matrix2.get(4, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33 + f40 * s34); + output.set(4, 0, f00 * s40 + f10 * s41 + f20 * s42 + f30 * s43 + f40 * s44); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33 + f41 * s34); + output.set(4, 1, f01 * s40 + f11 * s41 + f21 * s42 + f31 * s43 + f41 * s44); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23 + f42 * s24); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33 + f42 * s34); + output.set(4, 2, f02 * s40 + f12 * s41 + f22 * s42 + f32 * s43 + f42 * s44); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03 + f43 * s04); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13 + f43 * s14); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23 + f43 * s24); + output.set(3, 3, f03 * s30 + f13 * s31 + f23 * s32 + f33 * s33 + f43 * s34); + output.set(4, 3, f03 * s40 + f13 * s41 + f23 * s42 + f33 * s43 + f43 * s44); + return output; + } + + private static IMatrixSetterDouble multiplyMatrix5x5x1(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double f30 = matrix1.get(3, 0); + final double f40 = matrix1.get(4, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f21 = matrix1.get(2, 1); + final double f31 = matrix1.get(3, 1); + final double f41 = matrix1.get(4, 1); + final double f02 = matrix1.get(0, 2); + final double f12 = matrix1.get(1, 2); + final double f22 = matrix1.get(2, 2); + final double f32 = matrix1.get(3, 2); + final double f42 = matrix1.get(4, 2); + final double f03 = matrix1.get(0, 3); + final double f13 = matrix1.get(1, 3); + final double f23 = matrix1.get(2, 3); + final double f33 = matrix1.get(3, 3); + final double f43 = matrix1.get(4, 3); + final double f04 = matrix1.get(0, 4); + final double f14 = matrix1.get(1, 4); + final double f24 = matrix1.get(2, 4); + final double f34 = matrix1.get(3, 4); + final double f44 = matrix1.get(4, 4); + final double s00 = matrix2.get(0, 0); + final double s01 = matrix2.get(0, 1); + final double s02 = matrix2.get(0, 2); + final double s03 = matrix2.get(0, 3); + final double s04 = matrix2.get(0, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03 + f43 * s04); + output.set(0, 4, f04 * s00 + f14 * s01 + f24 * s02 + f34 * s03 + f44 * s04); return output; } private static IMatrixSetterDouble multiplyMatrix5x5x2(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final double f_c00 = matrix1.get(0, 0); - final double f_c10 = matrix1.get(1, 0); - final double f_c20 = matrix1.get(2, 0); - final double f_c30 = matrix1.get(3, 0); - final double f_c40 = matrix1.get(4, 0); - final double f_c01 = matrix1.get(0, 1); - final double f_c11 = matrix1.get(1, 1); - final double f_c21 = matrix1.get(2, 1); - final double f_c31 = matrix1.get(3, 1); - final double f_c41 = matrix1.get(4, 1); - final double f_c02 = matrix1.get(0, 2); - final double f_c12 = matrix1.get(1, 2); - final double f_c22 = matrix1.get(2, 2); - final double f_c32 = matrix1.get(3, 2); - final double f_c42 = matrix1.get(4, 2); - final double f_c03 = matrix1.get(0, 3); - final double f_c13 = matrix1.get(1, 3); - final double f_c23 = matrix1.get(2, 3); - final double f_c33 = matrix1.get(3, 3); - final double f_c43 = matrix1.get(4, 3); - final double f_c04 = matrix1.get(0, 4); - final double f_c14 = matrix1.get(1, 4); - final double f_c24 = matrix1.get(2, 4); - final double f_c34 = matrix1.get(3, 4); - final double f_c44 = matrix1.get(4, 4); - final double s_c00 = matrix2.get(0, 0); - final double s_c10 = matrix2.get(1, 0); - final double s_c01 = matrix2.get(0, 1); - final double s_c11 = matrix2.get(1, 1); - final double s_c02 = matrix2.get(0, 2); - final double s_c12 = matrix2.get(1, 2); - final double s_c03 = matrix2.get(0, 3); - final double s_c13 = matrix2.get(1, 3); - final double s_c04 = matrix2.get(0, 4); - final double s_c14 = matrix2.get(1, 4); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03 + f_c43*s_c04); - output.set(0, 4, f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02 + f_c34*s_c03 + f_c44*s_c04); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13 + f_c43*s_c14); - output.set(1, 4, f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12 + f_c34*s_c13 + f_c44*s_c14); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double f30 = matrix1.get(3, 0); + final double f40 = matrix1.get(4, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f21 = matrix1.get(2, 1); + final double f31 = matrix1.get(3, 1); + final double f41 = matrix1.get(4, 1); + final double f02 = matrix1.get(0, 2); + final double f12 = matrix1.get(1, 2); + final double f22 = matrix1.get(2, 2); + final double f32 = matrix1.get(3, 2); + final double f42 = matrix1.get(4, 2); + final double f03 = matrix1.get(0, 3); + final double f13 = matrix1.get(1, 3); + final double f23 = matrix1.get(2, 3); + final double f33 = matrix1.get(3, 3); + final double f43 = matrix1.get(4, 3); + final double f04 = matrix1.get(0, 4); + final double f14 = matrix1.get(1, 4); + final double f24 = matrix1.get(2, 4); + final double f34 = matrix1.get(3, 4); + final double f44 = matrix1.get(4, 4); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s02 = matrix2.get(0, 2); + final double s12 = matrix2.get(1, 2); + final double s03 = matrix2.get(0, 3); + final double s13 = matrix2.get(1, 3); + final double s04 = matrix2.get(0, 4); + final double s14 = matrix2.get(1, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03 + f43 * s04); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13 + f43 * s14); + output.set(0, 4, f04 * s00 + f14 * s01 + f24 * s02 + f34 * s03 + f44 * s04); + output.set(1, 4, f04 * s10 + f14 * s11 + f24 * s12 + f34 * s13 + f44 * s14); return output; } private static IMatrixSetterDouble multiplyMatrix5x5x3(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final double f_c00 = matrix1.get(0, 0); - final double f_c10 = matrix1.get(1, 0); - final double f_c20 = matrix1.get(2, 0); - final double f_c30 = matrix1.get(3, 0); - final double f_c40 = matrix1.get(4, 0); - final double f_c01 = matrix1.get(0, 1); - final double f_c11 = matrix1.get(1, 1); - final double f_c21 = matrix1.get(2, 1); - final double f_c31 = matrix1.get(3, 1); - final double f_c41 = matrix1.get(4, 1); - final double f_c02 = matrix1.get(0, 2); - final double f_c12 = matrix1.get(1, 2); - final double f_c22 = matrix1.get(2, 2); - final double f_c32 = matrix1.get(3, 2); - final double f_c42 = matrix1.get(4, 2); - final double f_c03 = matrix1.get(0, 3); - final double f_c13 = matrix1.get(1, 3); - final double f_c23 = matrix1.get(2, 3); - final double f_c33 = matrix1.get(3, 3); - final double f_c43 = matrix1.get(4, 3); - final double f_c04 = matrix1.get(0, 4); - final double f_c14 = matrix1.get(1, 4); - final double f_c24 = matrix1.get(2, 4); - final double f_c34 = matrix1.get(3, 4); - final double f_c44 = matrix1.get(4, 4); - final double s_c00 = matrix2.get(0, 0); - final double s_c10 = matrix2.get(1, 0); - final double s_c20 = matrix2.get(2, 0); - final double s_c01 = matrix2.get(0, 1); - final double s_c11 = matrix2.get(1, 1); - final double s_c21 = matrix2.get(2, 1); - final double s_c02 = matrix2.get(0, 2); - final double s_c12 = matrix2.get(1, 2); - final double s_c22 = matrix2.get(2, 2); - final double s_c03 = matrix2.get(0, 3); - final double s_c13 = matrix2.get(1, 3); - final double s_c23 = matrix2.get(2, 3); - final double s_c04 = matrix2.get(0, 4); - final double s_c14 = matrix2.get(1, 4); - final double s_c24 = matrix2.get(2, 4); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03 + f_c43*s_c04); - output.set(0, 4, f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02 + f_c34*s_c03 + f_c44*s_c04); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13 + f_c43*s_c14); - output.set(1, 4, f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12 + f_c34*s_c13 + f_c44*s_c14); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23 + f_c42*s_c24); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23 + f_c43*s_c24); - output.set(2, 4, f_c04*s_c20 + f_c14*s_c21 + f_c24*s_c22 + f_c34*s_c23 + f_c44*s_c24); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double f30 = matrix1.get(3, 0); + final double f40 = matrix1.get(4, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f21 = matrix1.get(2, 1); + final double f31 = matrix1.get(3, 1); + final double f41 = matrix1.get(4, 1); + final double f02 = matrix1.get(0, 2); + final double f12 = matrix1.get(1, 2); + final double f22 = matrix1.get(2, 2); + final double f32 = matrix1.get(3, 2); + final double f42 = matrix1.get(4, 2); + final double f03 = matrix1.get(0, 3); + final double f13 = matrix1.get(1, 3); + final double f23 = matrix1.get(2, 3); + final double f33 = matrix1.get(3, 3); + final double f43 = matrix1.get(4, 3); + final double f04 = matrix1.get(0, 4); + final double f14 = matrix1.get(1, 4); + final double f24 = matrix1.get(2, 4); + final double f34 = matrix1.get(3, 4); + final double f44 = matrix1.get(4, 4); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s21 = matrix2.get(2, 1); + final double s02 = matrix2.get(0, 2); + final double s12 = matrix2.get(1, 2); + final double s22 = matrix2.get(2, 2); + final double s03 = matrix2.get(0, 3); + final double s13 = matrix2.get(1, 3); + final double s23 = matrix2.get(2, 3); + final double s04 = matrix2.get(0, 4); + final double s14 = matrix2.get(1, 4); + final double s24 = matrix2.get(2, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23 + f42 * s24); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03 + f43 * s04); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13 + f43 * s14); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23 + f43 * s24); + output.set(0, 4, f04 * s00 + f14 * s01 + f24 * s02 + f34 * s03 + f44 * s04); + output.set(1, 4, f04 * s10 + f14 * s11 + f24 * s12 + f34 * s13 + f44 * s14); + output.set(2, 4, f04 * s20 + f14 * s21 + f24 * s22 + f34 * s23 + f44 * s24); return output; } private static IMatrixSetterDouble multiplyMatrix5x5x4(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final double f_c00 = matrix1.get(0, 0); - final double f_c10 = matrix1.get(1, 0); - final double f_c20 = matrix1.get(2, 0); - final double f_c30 = matrix1.get(3, 0); - final double f_c40 = matrix1.get(4, 0); - final double f_c01 = matrix1.get(0, 1); - final double f_c11 = matrix1.get(1, 1); - final double f_c21 = matrix1.get(2, 1); - final double f_c31 = matrix1.get(3, 1); - final double f_c41 = matrix1.get(4, 1); - final double f_c02 = matrix1.get(0, 2); - final double f_c12 = matrix1.get(1, 2); - final double f_c22 = matrix1.get(2, 2); - final double f_c32 = matrix1.get(3, 2); - final double f_c42 = matrix1.get(4, 2); - final double f_c03 = matrix1.get(0, 3); - final double f_c13 = matrix1.get(1, 3); - final double f_c23 = matrix1.get(2, 3); - final double f_c33 = matrix1.get(3, 3); - final double f_c43 = matrix1.get(4, 3); - final double f_c04 = matrix1.get(0, 4); - final double f_c14 = matrix1.get(1, 4); - final double f_c24 = matrix1.get(2, 4); - final double f_c34 = matrix1.get(3, 4); - final double f_c44 = matrix1.get(4, 4); - final double s_c00 = matrix2.get(0, 0); - final double s_c10 = matrix2.get(1, 0); - final double s_c20 = matrix2.get(2, 0); - final double s_c30 = matrix2.get(3, 0); - final double s_c01 = matrix2.get(0, 1); - final double s_c11 = matrix2.get(1, 1); - final double s_c21 = matrix2.get(2, 1); - final double s_c31 = matrix2.get(3, 1); - final double s_c02 = matrix2.get(0, 2); - final double s_c12 = matrix2.get(1, 2); - final double s_c22 = matrix2.get(2, 2); - final double s_c32 = matrix2.get(3, 2); - final double s_c03 = matrix2.get(0, 3); - final double s_c13 = matrix2.get(1, 3); - final double s_c23 = matrix2.get(2, 3); - final double s_c33 = matrix2.get(3, 3); - final double s_c04 = matrix2.get(0, 4); - final double s_c14 = matrix2.get(1, 4); - final double s_c24 = matrix2.get(2, 4); - final double s_c34 = matrix2.get(3, 4); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03 + f_c43*s_c04); - output.set(0, 4, f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02 + f_c34*s_c03 + f_c44*s_c04); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13 + f_c43*s_c14); - output.set(1, 4, f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12 + f_c34*s_c13 + f_c44*s_c14); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23 + f_c42*s_c24); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23 + f_c43*s_c24); - output.set(2, 4, f_c04*s_c20 + f_c14*s_c21 + f_c24*s_c22 + f_c34*s_c23 + f_c44*s_c24); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33 + f_c40*s_c34); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33 + f_c41*s_c34); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33 + f_c42*s_c34); - output.set(3, 3, f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32 + f_c33*s_c33 + f_c43*s_c34); - output.set(3, 4, f_c04*s_c30 + f_c14*s_c31 + f_c24*s_c32 + f_c34*s_c33 + f_c44*s_c34); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double f30 = matrix1.get(3, 0); + final double f40 = matrix1.get(4, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f21 = matrix1.get(2, 1); + final double f31 = matrix1.get(3, 1); + final double f41 = matrix1.get(4, 1); + final double f02 = matrix1.get(0, 2); + final double f12 = matrix1.get(1, 2); + final double f22 = matrix1.get(2, 2); + final double f32 = matrix1.get(3, 2); + final double f42 = matrix1.get(4, 2); + final double f03 = matrix1.get(0, 3); + final double f13 = matrix1.get(1, 3); + final double f23 = matrix1.get(2, 3); + final double f33 = matrix1.get(3, 3); + final double f43 = matrix1.get(4, 3); + final double f04 = matrix1.get(0, 4); + final double f14 = matrix1.get(1, 4); + final double f24 = matrix1.get(2, 4); + final double f34 = matrix1.get(3, 4); + final double f44 = matrix1.get(4, 4); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + final double s30 = matrix2.get(3, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s21 = matrix2.get(2, 1); + final double s31 = matrix2.get(3, 1); + final double s02 = matrix2.get(0, 2); + final double s12 = matrix2.get(1, 2); + final double s22 = matrix2.get(2, 2); + final double s32 = matrix2.get(3, 2); + final double s03 = matrix2.get(0, 3); + final double s13 = matrix2.get(1, 3); + final double s23 = matrix2.get(2, 3); + final double s33 = matrix2.get(3, 3); + final double s04 = matrix2.get(0, 4); + final double s14 = matrix2.get(1, 4); + final double s24 = matrix2.get(2, 4); + final double s34 = matrix2.get(3, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33 + f40 * s34); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33 + f41 * s34); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23 + f42 * s24); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33 + f42 * s34); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03 + f43 * s04); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13 + f43 * s14); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23 + f43 * s24); + output.set(3, 3, f03 * s30 + f13 * s31 + f23 * s32 + f33 * s33 + f43 * s34); + output.set(0, 4, f04 * s00 + f14 * s01 + f24 * s02 + f34 * s03 + f44 * s04); + output.set(1, 4, f04 * s10 + f14 * s11 + f24 * s12 + f34 * s13 + f44 * s14); + output.set(2, 4, f04 * s20 + f14 * s21 + f24 * s22 + f34 * s23 + f44 * s24); + output.set(3, 4, f04 * s30 + f14 * s31 + f24 * s32 + f34 * s33 + f44 * s34); return output; } private static IMatrixSetterDouble multiplyMatrix5x5x5(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final double f_c00 = matrix1.get(0, 0); - final double f_c10 = matrix1.get(1, 0); - final double f_c20 = matrix1.get(2, 0); - final double f_c30 = matrix1.get(3, 0); - final double f_c40 = matrix1.get(4, 0); - final double f_c01 = matrix1.get(0, 1); - final double f_c11 = matrix1.get(1, 1); - final double f_c21 = matrix1.get(2, 1); - final double f_c31 = matrix1.get(3, 1); - final double f_c41 = matrix1.get(4, 1); - final double f_c02 = matrix1.get(0, 2); - final double f_c12 = matrix1.get(1, 2); - final double f_c22 = matrix1.get(2, 2); - final double f_c32 = matrix1.get(3, 2); - final double f_c42 = matrix1.get(4, 2); - final double f_c03 = matrix1.get(0, 3); - final double f_c13 = matrix1.get(1, 3); - final double f_c23 = matrix1.get(2, 3); - final double f_c33 = matrix1.get(3, 3); - final double f_c43 = matrix1.get(4, 3); - final double f_c04 = matrix1.get(0, 4); - final double f_c14 = matrix1.get(1, 4); - final double f_c24 = matrix1.get(2, 4); - final double f_c34 = matrix1.get(3, 4); - final double f_c44 = matrix1.get(4, 4); - final double s_c00 = matrix2.get(0, 0); - final double s_c10 = matrix2.get(1, 0); - final double s_c20 = matrix2.get(2, 0); - final double s_c30 = matrix2.get(3, 0); - final double s_c40 = matrix2.get(4, 0); - final double s_c01 = matrix2.get(0, 1); - final double s_c11 = matrix2.get(1, 1); - final double s_c21 = matrix2.get(2, 1); - final double s_c31 = matrix2.get(3, 1); - final double s_c41 = matrix2.get(4, 1); - final double s_c02 = matrix2.get(0, 2); - final double s_c12 = matrix2.get(1, 2); - final double s_c22 = matrix2.get(2, 2); - final double s_c32 = matrix2.get(3, 2); - final double s_c42 = matrix2.get(4, 2); - final double s_c03 = matrix2.get(0, 3); - final double s_c13 = matrix2.get(1, 3); - final double s_c23 = matrix2.get(2, 3); - final double s_c33 = matrix2.get(3, 3); - final double s_c43 = matrix2.get(4, 3); - final double s_c04 = matrix2.get(0, 4); - final double s_c14 = matrix2.get(1, 4); - final double s_c24 = matrix2.get(2, 4); - final double s_c34 = matrix2.get(3, 4); - final double s_c44 = matrix2.get(4, 4); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03 + f_c43*s_c04); - output.set(0, 4, f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02 + f_c34*s_c03 + f_c44*s_c04); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13 + f_c43*s_c14); - output.set(1, 4, f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12 + f_c34*s_c13 + f_c44*s_c14); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23 + f_c42*s_c24); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23 + f_c43*s_c24); - output.set(2, 4, f_c04*s_c20 + f_c14*s_c21 + f_c24*s_c22 + f_c34*s_c23 + f_c44*s_c24); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33 + f_c40*s_c34); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33 + f_c41*s_c34); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33 + f_c42*s_c34); - output.set(3, 3, f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32 + f_c33*s_c33 + f_c43*s_c34); - output.set(3, 4, f_c04*s_c30 + f_c14*s_c31 + f_c24*s_c32 + f_c34*s_c33 + f_c44*s_c34); - output.set(4, 0, f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42 + f_c30*s_c43 + f_c40*s_c44); - output.set(4, 1, f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42 + f_c31*s_c43 + f_c41*s_c44); - output.set(4, 2, f_c02*s_c40 + f_c12*s_c41 + f_c22*s_c42 + f_c32*s_c43 + f_c42*s_c44); - output.set(4, 3, f_c03*s_c40 + f_c13*s_c41 + f_c23*s_c42 + f_c33*s_c43 + f_c43*s_c44); - output.set(4, 4, f_c04*s_c40 + f_c14*s_c41 + f_c24*s_c42 + f_c34*s_c43 + f_c44*s_c44); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final double f00 = matrix1.get(0, 0); + final double f10 = matrix1.get(1, 0); + final double f20 = matrix1.get(2, 0); + final double f30 = matrix1.get(3, 0); + final double f40 = matrix1.get(4, 0); + final double f01 = matrix1.get(0, 1); + final double f11 = matrix1.get(1, 1); + final double f21 = matrix1.get(2, 1); + final double f31 = matrix1.get(3, 1); + final double f41 = matrix1.get(4, 1); + final double f02 = matrix1.get(0, 2); + final double f12 = matrix1.get(1, 2); + final double f22 = matrix1.get(2, 2); + final double f32 = matrix1.get(3, 2); + final double f42 = matrix1.get(4, 2); + final double f03 = matrix1.get(0, 3); + final double f13 = matrix1.get(1, 3); + final double f23 = matrix1.get(2, 3); + final double f33 = matrix1.get(3, 3); + final double f43 = matrix1.get(4, 3); + final double f04 = matrix1.get(0, 4); + final double f14 = matrix1.get(1, 4); + final double f24 = matrix1.get(2, 4); + final double f34 = matrix1.get(3, 4); + final double f44 = matrix1.get(4, 4); + final double s00 = matrix2.get(0, 0); + final double s10 = matrix2.get(1, 0); + final double s20 = matrix2.get(2, 0); + final double s30 = matrix2.get(3, 0); + final double s40 = matrix2.get(4, 0); + final double s01 = matrix2.get(0, 1); + final double s11 = matrix2.get(1, 1); + final double s21 = matrix2.get(2, 1); + final double s31 = matrix2.get(3, 1); + final double s41 = matrix2.get(4, 1); + final double s02 = matrix2.get(0, 2); + final double s12 = matrix2.get(1, 2); + final double s22 = matrix2.get(2, 2); + final double s32 = matrix2.get(3, 2); + final double s42 = matrix2.get(4, 2); + final double s03 = matrix2.get(0, 3); + final double s13 = matrix2.get(1, 3); + final double s23 = matrix2.get(2, 3); + final double s33 = matrix2.get(3, 3); + final double s43 = matrix2.get(4, 3); + final double s04 = matrix2.get(0, 4); + final double s14 = matrix2.get(1, 4); + final double s24 = matrix2.get(2, 4); + final double s34 = matrix2.get(3, 4); + final double s44 = matrix2.get(4, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33 + f40 * s34); + output.set(4, 0, f00 * s40 + f10 * s41 + f20 * s42 + f30 * s43 + f40 * s44); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33 + f41 * s34); + output.set(4, 1, f01 * s40 + f11 * s41 + f21 * s42 + f31 * s43 + f41 * s44); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23 + f42 * s24); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33 + f42 * s34); + output.set(4, 2, f02 * s40 + f12 * s41 + f22 * s42 + f32 * s43 + f42 * s44); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03 + f43 * s04); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13 + f43 * s14); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23 + f43 * s24); + output.set(3, 3, f03 * s30 + f13 * s31 + f23 * s32 + f33 * s33 + f43 * s34); + output.set(4, 3, f03 * s40 + f13 * s41 + f23 * s42 + f33 * s43 + f43 * s44); + output.set(0, 4, f04 * s00 + f14 * s01 + f24 * s02 + f34 * s03 + f44 * s04); + output.set(1, 4, f04 * s10 + f14 * s11 + f24 * s12 + f34 * s13 + f44 * s14); + output.set(2, 4, f04 * s20 + f14 * s21 + f24 * s22 + f34 * s23 + f44 * s24); + output.set(3, 4, f04 * s30 + f14 * s31 + f24 * s32 + f34 * s33 + f44 * s34); + output.set(4, 4, f04 * s40 + f14 * s41 + f24 * s42 + f34 * s43 + f44 * s44); return output; } /** * Automatically generated concrete matrix multiplication. If no mapping exist, this method returns null. * - * @return new Double2Dimensional + * @return new Double2Dimensional */ - @org.jetbrains.annotations.Nullable - public static Double2Dimensional multiplyMatrix(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2) { + @org.jetbrains.annotations.Nullable + public static Double2Dimensional multiplyMatrix(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2) { if (matrix1.getColumns() != matrix2.getRows()) return null; - switch (matrix1.getColumns()) { - case 2: switch (matrix1.getRows()) { - case 2: switch (matrix2.getColumns()) { + switch(matrix1.getColumns()) { + case 1: switch(matrix1.getRows()) { + case 1: switch(matrix2.getColumns()) { + case 1: return (Double2Dimensional) multiplyMatrix1x1x1(matrix1, matrix2, new Double2Dimensional(1, 1)); + case 2: return (Double2Dimensional) multiplyMatrix1x1x2(matrix1, matrix2, new Double2Dimensional(2, 1)); + case 3: return (Double2Dimensional) multiplyMatrix1x1x3(matrix1, matrix2, new Double2Dimensional(3, 1)); + case 4: return (Double2Dimensional) multiplyMatrix1x1x4(matrix1, matrix2, new Double2Dimensional(4, 1)); + case 5: return (Double2Dimensional) multiplyMatrix1x1x5(matrix1, matrix2, new Double2Dimensional(5, 1)); + default: return null; + } + case 2: switch(matrix2.getColumns()) { + case 1: return (Double2Dimensional) multiplyMatrix2x1x1(matrix1, matrix2, new Double2Dimensional(1, 2)); + case 2: return (Double2Dimensional) multiplyMatrix2x1x2(matrix1, matrix2, new Double2Dimensional(2, 2)); + case 3: return (Double2Dimensional) multiplyMatrix2x1x3(matrix1, matrix2, new Double2Dimensional(3, 2)); + case 4: return (Double2Dimensional) multiplyMatrix2x1x4(matrix1, matrix2, new Double2Dimensional(4, 2)); + case 5: return (Double2Dimensional) multiplyMatrix2x1x5(matrix1, matrix2, new Double2Dimensional(5, 2)); + default: return null; + } + case 3: switch(matrix2.getColumns()) { + case 1: return (Double2Dimensional) multiplyMatrix3x1x1(matrix1, matrix2, new Double2Dimensional(1, 3)); + case 2: return (Double2Dimensional) multiplyMatrix3x1x2(matrix1, matrix2, new Double2Dimensional(2, 3)); + case 3: return (Double2Dimensional) multiplyMatrix3x1x3(matrix1, matrix2, new Double2Dimensional(3, 3)); + case 4: return (Double2Dimensional) multiplyMatrix3x1x4(matrix1, matrix2, new Double2Dimensional(4, 3)); + case 5: return (Double2Dimensional) multiplyMatrix3x1x5(matrix1, matrix2, new Double2Dimensional(5, 3)); + default: return null; + } + case 4: switch(matrix2.getColumns()) { + case 1: return (Double2Dimensional) multiplyMatrix4x1x1(matrix1, matrix2, new Double2Dimensional(1, 4)); + case 2: return (Double2Dimensional) multiplyMatrix4x1x2(matrix1, matrix2, new Double2Dimensional(2, 4)); + case 3: return (Double2Dimensional) multiplyMatrix4x1x3(matrix1, matrix2, new Double2Dimensional(3, 4)); + case 4: return (Double2Dimensional) multiplyMatrix4x1x4(matrix1, matrix2, new Double2Dimensional(4, 4)); + case 5: return (Double2Dimensional) multiplyMatrix4x1x5(matrix1, matrix2, new Double2Dimensional(5, 4)); + default: return null; + } + case 5: switch(matrix2.getColumns()) { + case 1: return (Double2Dimensional) multiplyMatrix5x1x1(matrix1, matrix2, new Double2Dimensional(1, 5)); + case 2: return (Double2Dimensional) multiplyMatrix5x1x2(matrix1, matrix2, new Double2Dimensional(2, 5)); + case 3: return (Double2Dimensional) multiplyMatrix5x1x3(matrix1, matrix2, new Double2Dimensional(3, 5)); + case 4: return (Double2Dimensional) multiplyMatrix5x1x4(matrix1, matrix2, new Double2Dimensional(4, 5)); + case 5: return (Double2Dimensional) multiplyMatrix5x1x5(matrix1, matrix2, new Double2Dimensional(5, 5)); + default: return null; + } + default: return null; + } + case 2: switch(matrix1.getRows()) { + case 1: switch(matrix2.getColumns()) { + case 1: return (Double2Dimensional) multiplyMatrix1x2x1(matrix1, matrix2, new Double2Dimensional(1, 1)); + case 2: return (Double2Dimensional) multiplyMatrix1x2x2(matrix1, matrix2, new Double2Dimensional(2, 1)); + case 3: return (Double2Dimensional) multiplyMatrix1x2x3(matrix1, matrix2, new Double2Dimensional(3, 1)); + case 4: return (Double2Dimensional) multiplyMatrix1x2x4(matrix1, matrix2, new Double2Dimensional(4, 1)); + case 5: return (Double2Dimensional) multiplyMatrix1x2x5(matrix1, matrix2, new Double2Dimensional(5, 1)); + default: return null; + } + case 2: switch(matrix2.getColumns()) { + case 1: return (Double2Dimensional) multiplyMatrix2x2x1(matrix1, matrix2, new Double2Dimensional(1, 2)); case 2: return (Double2Dimensional) multiplyMatrix2x2x2(matrix1, matrix2, new Double2Dimensional(2, 2)); case 3: return (Double2Dimensional) multiplyMatrix2x2x3(matrix1, matrix2, new Double2Dimensional(3, 2)); case 4: return (Double2Dimensional) multiplyMatrix2x2x4(matrix1, matrix2, new Double2Dimensional(4, 2)); case 5: return (Double2Dimensional) multiplyMatrix2x2x5(matrix1, matrix2, new Double2Dimensional(5, 2)); default: return null; } - case 3: switch (matrix2.getColumns()) { + case 3: switch(matrix2.getColumns()) { + case 1: return (Double2Dimensional) multiplyMatrix3x2x1(matrix1, matrix2, new Double2Dimensional(1, 3)); case 2: return (Double2Dimensional) multiplyMatrix3x2x2(matrix1, matrix2, new Double2Dimensional(2, 3)); case 3: return (Double2Dimensional) multiplyMatrix3x2x3(matrix1, matrix2, new Double2Dimensional(3, 3)); case 4: return (Double2Dimensional) multiplyMatrix3x2x4(matrix1, matrix2, new Double2Dimensional(4, 3)); case 5: return (Double2Dimensional) multiplyMatrix3x2x5(matrix1, matrix2, new Double2Dimensional(5, 3)); default: return null; } - case 4: switch (matrix2.getColumns()) { + case 4: switch(matrix2.getColumns()) { + case 1: return (Double2Dimensional) multiplyMatrix4x2x1(matrix1, matrix2, new Double2Dimensional(1, 4)); case 2: return (Double2Dimensional) multiplyMatrix4x2x2(matrix1, matrix2, new Double2Dimensional(2, 4)); case 3: return (Double2Dimensional) multiplyMatrix4x2x3(matrix1, matrix2, new Double2Dimensional(3, 4)); case 4: return (Double2Dimensional) multiplyMatrix4x2x4(matrix1, matrix2, new Double2Dimensional(4, 4)); case 5: return (Double2Dimensional) multiplyMatrix4x2x5(matrix1, matrix2, new Double2Dimensional(5, 4)); default: return null; } - case 5: switch (matrix2.getColumns()) { + case 5: switch(matrix2.getColumns()) { + case 1: return (Double2Dimensional) multiplyMatrix5x2x1(matrix1, matrix2, new Double2Dimensional(1, 5)); case 2: return (Double2Dimensional) multiplyMatrix5x2x2(matrix1, matrix2, new Double2Dimensional(2, 5)); case 3: return (Double2Dimensional) multiplyMatrix5x2x3(matrix1, matrix2, new Double2Dimensional(3, 5)); case 4: return (Double2Dimensional) multiplyMatrix5x2x4(matrix1, matrix2, new Double2Dimensional(4, 5)); @@ -2788,29 +4230,41 @@ public final class MultiplicationsDouble { } default: return null; } - case 3: switch (matrix1.getRows()) { - case 2: switch (matrix2.getColumns()) { + case 3: switch(matrix1.getRows()) { + case 1: switch(matrix2.getColumns()) { + case 1: return (Double2Dimensional) multiplyMatrix1x3x1(matrix1, matrix2, new Double2Dimensional(1, 1)); + case 2: return (Double2Dimensional) multiplyMatrix1x3x2(matrix1, matrix2, new Double2Dimensional(2, 1)); + case 3: return (Double2Dimensional) multiplyMatrix1x3x3(matrix1, matrix2, new Double2Dimensional(3, 1)); + case 4: return (Double2Dimensional) multiplyMatrix1x3x4(matrix1, matrix2, new Double2Dimensional(4, 1)); + case 5: return (Double2Dimensional) multiplyMatrix1x3x5(matrix1, matrix2, new Double2Dimensional(5, 1)); + default: return null; + } + case 2: switch(matrix2.getColumns()) { + case 1: return (Double2Dimensional) multiplyMatrix2x3x1(matrix1, matrix2, new Double2Dimensional(1, 2)); case 2: return (Double2Dimensional) multiplyMatrix2x3x2(matrix1, matrix2, new Double2Dimensional(2, 2)); case 3: return (Double2Dimensional) multiplyMatrix2x3x3(matrix1, matrix2, new Double2Dimensional(3, 2)); case 4: return (Double2Dimensional) multiplyMatrix2x3x4(matrix1, matrix2, new Double2Dimensional(4, 2)); case 5: return (Double2Dimensional) multiplyMatrix2x3x5(matrix1, matrix2, new Double2Dimensional(5, 2)); default: return null; } - case 3: switch (matrix2.getColumns()) { + case 3: switch(matrix2.getColumns()) { + case 1: return (Double2Dimensional) multiplyMatrix3x3x1(matrix1, matrix2, new Double2Dimensional(1, 3)); case 2: return (Double2Dimensional) multiplyMatrix3x3x2(matrix1, matrix2, new Double2Dimensional(2, 3)); case 3: return (Double2Dimensional) multiplyMatrix3x3x3(matrix1, matrix2, new Double2Dimensional(3, 3)); case 4: return (Double2Dimensional) multiplyMatrix3x3x4(matrix1, matrix2, new Double2Dimensional(4, 3)); case 5: return (Double2Dimensional) multiplyMatrix3x3x5(matrix1, matrix2, new Double2Dimensional(5, 3)); default: return null; } - case 4: switch (matrix2.getColumns()) { + case 4: switch(matrix2.getColumns()) { + case 1: return (Double2Dimensional) multiplyMatrix4x3x1(matrix1, matrix2, new Double2Dimensional(1, 4)); case 2: return (Double2Dimensional) multiplyMatrix4x3x2(matrix1, matrix2, new Double2Dimensional(2, 4)); case 3: return (Double2Dimensional) multiplyMatrix4x3x3(matrix1, matrix2, new Double2Dimensional(3, 4)); case 4: return (Double2Dimensional) multiplyMatrix4x3x4(matrix1, matrix2, new Double2Dimensional(4, 4)); case 5: return (Double2Dimensional) multiplyMatrix4x3x5(matrix1, matrix2, new Double2Dimensional(5, 4)); default: return null; } - case 5: switch (matrix2.getColumns()) { + case 5: switch(matrix2.getColumns()) { + case 1: return (Double2Dimensional) multiplyMatrix5x3x1(matrix1, matrix2, new Double2Dimensional(1, 5)); case 2: return (Double2Dimensional) multiplyMatrix5x3x2(matrix1, matrix2, new Double2Dimensional(2, 5)); case 3: return (Double2Dimensional) multiplyMatrix5x3x3(matrix1, matrix2, new Double2Dimensional(3, 5)); case 4: return (Double2Dimensional) multiplyMatrix5x3x4(matrix1, matrix2, new Double2Dimensional(4, 5)); @@ -2819,29 +4273,41 @@ public final class MultiplicationsDouble { } default: return null; } - case 4: switch (matrix1.getRows()) { - case 2: switch (matrix2.getColumns()) { + case 4: switch(matrix1.getRows()) { + case 1: switch(matrix2.getColumns()) { + case 1: return (Double2Dimensional) multiplyMatrix1x4x1(matrix1, matrix2, new Double2Dimensional(1, 1)); + case 2: return (Double2Dimensional) multiplyMatrix1x4x2(matrix1, matrix2, new Double2Dimensional(2, 1)); + case 3: return (Double2Dimensional) multiplyMatrix1x4x3(matrix1, matrix2, new Double2Dimensional(3, 1)); + case 4: return (Double2Dimensional) multiplyMatrix1x4x4(matrix1, matrix2, new Double2Dimensional(4, 1)); + case 5: return (Double2Dimensional) multiplyMatrix1x4x5(matrix1, matrix2, new Double2Dimensional(5, 1)); + default: return null; + } + case 2: switch(matrix2.getColumns()) { + case 1: return (Double2Dimensional) multiplyMatrix2x4x1(matrix1, matrix2, new Double2Dimensional(1, 2)); case 2: return (Double2Dimensional) multiplyMatrix2x4x2(matrix1, matrix2, new Double2Dimensional(2, 2)); case 3: return (Double2Dimensional) multiplyMatrix2x4x3(matrix1, matrix2, new Double2Dimensional(3, 2)); case 4: return (Double2Dimensional) multiplyMatrix2x4x4(matrix1, matrix2, new Double2Dimensional(4, 2)); case 5: return (Double2Dimensional) multiplyMatrix2x4x5(matrix1, matrix2, new Double2Dimensional(5, 2)); default: return null; } - case 3: switch (matrix2.getColumns()) { + case 3: switch(matrix2.getColumns()) { + case 1: return (Double2Dimensional) multiplyMatrix3x4x1(matrix1, matrix2, new Double2Dimensional(1, 3)); case 2: return (Double2Dimensional) multiplyMatrix3x4x2(matrix1, matrix2, new Double2Dimensional(2, 3)); case 3: return (Double2Dimensional) multiplyMatrix3x4x3(matrix1, matrix2, new Double2Dimensional(3, 3)); case 4: return (Double2Dimensional) multiplyMatrix3x4x4(matrix1, matrix2, new Double2Dimensional(4, 3)); case 5: return (Double2Dimensional) multiplyMatrix3x4x5(matrix1, matrix2, new Double2Dimensional(5, 3)); default: return null; } - case 4: switch (matrix2.getColumns()) { + case 4: switch(matrix2.getColumns()) { + case 1: return (Double2Dimensional) multiplyMatrix4x4x1(matrix1, matrix2, new Double2Dimensional(1, 4)); case 2: return (Double2Dimensional) multiplyMatrix4x4x2(matrix1, matrix2, new Double2Dimensional(2, 4)); case 3: return (Double2Dimensional) multiplyMatrix4x4x3(matrix1, matrix2, new Double2Dimensional(3, 4)); case 4: return (Double2Dimensional) multiplyMatrix4x4x4(matrix1, matrix2, new Double2Dimensional(4, 4)); case 5: return (Double2Dimensional) multiplyMatrix4x4x5(matrix1, matrix2, new Double2Dimensional(5, 4)); default: return null; } - case 5: switch (matrix2.getColumns()) { + case 5: switch(matrix2.getColumns()) { + case 1: return (Double2Dimensional) multiplyMatrix5x4x1(matrix1, matrix2, new Double2Dimensional(1, 5)); case 2: return (Double2Dimensional) multiplyMatrix5x4x2(matrix1, matrix2, new Double2Dimensional(2, 5)); case 3: return (Double2Dimensional) multiplyMatrix5x4x3(matrix1, matrix2, new Double2Dimensional(3, 5)); case 4: return (Double2Dimensional) multiplyMatrix5x4x4(matrix1, matrix2, new Double2Dimensional(4, 5)); @@ -2850,29 +4316,41 @@ public final class MultiplicationsDouble { } default: return null; } - case 5: switch (matrix1.getRows()) { - case 2: switch (matrix2.getColumns()) { + case 5: switch(matrix1.getRows()) { + case 1: switch(matrix2.getColumns()) { + case 1: return (Double2Dimensional) multiplyMatrix1x5x1(matrix1, matrix2, new Double2Dimensional(1, 1)); + case 2: return (Double2Dimensional) multiplyMatrix1x5x2(matrix1, matrix2, new Double2Dimensional(2, 1)); + case 3: return (Double2Dimensional) multiplyMatrix1x5x3(matrix1, matrix2, new Double2Dimensional(3, 1)); + case 4: return (Double2Dimensional) multiplyMatrix1x5x4(matrix1, matrix2, new Double2Dimensional(4, 1)); + case 5: return (Double2Dimensional) multiplyMatrix1x5x5(matrix1, matrix2, new Double2Dimensional(5, 1)); + default: return null; + } + case 2: switch(matrix2.getColumns()) { + case 1: return (Double2Dimensional) multiplyMatrix2x5x1(matrix1, matrix2, new Double2Dimensional(1, 2)); case 2: return (Double2Dimensional) multiplyMatrix2x5x2(matrix1, matrix2, new Double2Dimensional(2, 2)); case 3: return (Double2Dimensional) multiplyMatrix2x5x3(matrix1, matrix2, new Double2Dimensional(3, 2)); case 4: return (Double2Dimensional) multiplyMatrix2x5x4(matrix1, matrix2, new Double2Dimensional(4, 2)); case 5: return (Double2Dimensional) multiplyMatrix2x5x5(matrix1, matrix2, new Double2Dimensional(5, 2)); default: return null; } - case 3: switch (matrix2.getColumns()) { + case 3: switch(matrix2.getColumns()) { + case 1: return (Double2Dimensional) multiplyMatrix3x5x1(matrix1, matrix2, new Double2Dimensional(1, 3)); case 2: return (Double2Dimensional) multiplyMatrix3x5x2(matrix1, matrix2, new Double2Dimensional(2, 3)); case 3: return (Double2Dimensional) multiplyMatrix3x5x3(matrix1, matrix2, new Double2Dimensional(3, 3)); case 4: return (Double2Dimensional) multiplyMatrix3x5x4(matrix1, matrix2, new Double2Dimensional(4, 3)); case 5: return (Double2Dimensional) multiplyMatrix3x5x5(matrix1, matrix2, new Double2Dimensional(5, 3)); default: return null; } - case 4: switch (matrix2.getColumns()) { + case 4: switch(matrix2.getColumns()) { + case 1: return (Double2Dimensional) multiplyMatrix4x5x1(matrix1, matrix2, new Double2Dimensional(1, 4)); case 2: return (Double2Dimensional) multiplyMatrix4x5x2(matrix1, matrix2, new Double2Dimensional(2, 4)); case 3: return (Double2Dimensional) multiplyMatrix4x5x3(matrix1, matrix2, new Double2Dimensional(3, 4)); case 4: return (Double2Dimensional) multiplyMatrix4x5x4(matrix1, matrix2, new Double2Dimensional(4, 4)); case 5: return (Double2Dimensional) multiplyMatrix4x5x5(matrix1, matrix2, new Double2Dimensional(5, 4)); default: return null; } - case 5: switch (matrix2.getColumns()) { + case 5: switch(matrix2.getColumns()) { + case 1: return (Double2Dimensional) multiplyMatrix5x5x1(matrix1, matrix2, new Double2Dimensional(1, 5)); case 2: return (Double2Dimensional) multiplyMatrix5x5x2(matrix1, matrix2, new Double2Dimensional(2, 5)); case 3: return (Double2Dimensional) multiplyMatrix5x5x3(matrix1, matrix2, new Double2Dimensional(3, 5)); case 4: return (Double2Dimensional) multiplyMatrix5x5x4(matrix1, matrix2, new Double2Dimensional(4, 5)); @@ -2884,39 +4362,94 @@ public final class MultiplicationsDouble { default: return null; } } - /** - * Automatically generated concrete matrix multiplication. If no mapping exist, this method returns null. - * This method writes the result to specified [output] - * @return provided IMatrixSetterDouble if mapping exists and computed, or null if mapping does not exist + * Automatically generated concrete matrix multiplication. + * This function writes the result onto specified output, and returns it, if mapping exists and computed, otherwise returns null. + * + * @return provided output, or null if mapping does not exist */ - @org.jetbrains.annotations.Nullable - public static IMatrixSetterDouble multiplyMatrix(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { + @org.jetbrains.annotations.Nullable + public static IMatrixSetterDouble multiplyMatrix(final IMatrixGetterDouble matrix1, final IMatrixGetterDouble matrix2, final IMatrixSetterDouble output) { if (matrix1.getColumns() != matrix2.getRows()) return null; - switch (matrix1.getColumns()) { - case 2: switch (matrix1.getRows()) { - case 2: switch (matrix2.getColumns()) { + switch(matrix1.getColumns()) { + case 1: switch(matrix1.getRows()) { + case 1: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix1x1x1(matrix1, matrix2, output); + case 2: return multiplyMatrix1x1x2(matrix1, matrix2, output); + case 3: return multiplyMatrix1x1x3(matrix1, matrix2, output); + case 4: return multiplyMatrix1x1x4(matrix1, matrix2, output); + case 5: return multiplyMatrix1x1x5(matrix1, matrix2, output); + default: return null; + } + case 2: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix2x1x1(matrix1, matrix2, output); + case 2: return multiplyMatrix2x1x2(matrix1, matrix2, output); + case 3: return multiplyMatrix2x1x3(matrix1, matrix2, output); + case 4: return multiplyMatrix2x1x4(matrix1, matrix2, output); + case 5: return multiplyMatrix2x1x5(matrix1, matrix2, output); + default: return null; + } + case 3: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix3x1x1(matrix1, matrix2, output); + case 2: return multiplyMatrix3x1x2(matrix1, matrix2, output); + case 3: return multiplyMatrix3x1x3(matrix1, matrix2, output); + case 4: return multiplyMatrix3x1x4(matrix1, matrix2, output); + case 5: return multiplyMatrix3x1x5(matrix1, matrix2, output); + default: return null; + } + case 4: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix4x1x1(matrix1, matrix2, output); + case 2: return multiplyMatrix4x1x2(matrix1, matrix2, output); + case 3: return multiplyMatrix4x1x3(matrix1, matrix2, output); + case 4: return multiplyMatrix4x1x4(matrix1, matrix2, output); + case 5: return multiplyMatrix4x1x5(matrix1, matrix2, output); + default: return null; + } + case 5: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix5x1x1(matrix1, matrix2, output); + case 2: return multiplyMatrix5x1x2(matrix1, matrix2, output); + case 3: return multiplyMatrix5x1x3(matrix1, matrix2, output); + case 4: return multiplyMatrix5x1x4(matrix1, matrix2, output); + case 5: return multiplyMatrix5x1x5(matrix1, matrix2, output); + default: return null; + } + default: return null; + } + case 2: switch(matrix1.getRows()) { + case 1: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix1x2x1(matrix1, matrix2, output); + case 2: return multiplyMatrix1x2x2(matrix1, matrix2, output); + case 3: return multiplyMatrix1x2x3(matrix1, matrix2, output); + case 4: return multiplyMatrix1x2x4(matrix1, matrix2, output); + case 5: return multiplyMatrix1x2x5(matrix1, matrix2, output); + default: return null; + } + case 2: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix2x2x1(matrix1, matrix2, output); case 2: return multiplyMatrix2x2x2(matrix1, matrix2, output); case 3: return multiplyMatrix2x2x3(matrix1, matrix2, output); case 4: return multiplyMatrix2x2x4(matrix1, matrix2, output); case 5: return multiplyMatrix2x2x5(matrix1, matrix2, output); default: return null; } - case 3: switch (matrix2.getColumns()) { + case 3: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix3x2x1(matrix1, matrix2, output); case 2: return multiplyMatrix3x2x2(matrix1, matrix2, output); case 3: return multiplyMatrix3x2x3(matrix1, matrix2, output); case 4: return multiplyMatrix3x2x4(matrix1, matrix2, output); case 5: return multiplyMatrix3x2x5(matrix1, matrix2, output); default: return null; } - case 4: switch (matrix2.getColumns()) { + case 4: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix4x2x1(matrix1, matrix2, output); case 2: return multiplyMatrix4x2x2(matrix1, matrix2, output); case 3: return multiplyMatrix4x2x3(matrix1, matrix2, output); case 4: return multiplyMatrix4x2x4(matrix1, matrix2, output); case 5: return multiplyMatrix4x2x5(matrix1, matrix2, output); default: return null; } - case 5: switch (matrix2.getColumns()) { + case 5: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix5x2x1(matrix1, matrix2, output); case 2: return multiplyMatrix5x2x2(matrix1, matrix2, output); case 3: return multiplyMatrix5x2x3(matrix1, matrix2, output); case 4: return multiplyMatrix5x2x4(matrix1, matrix2, output); @@ -2925,29 +4458,41 @@ public final class MultiplicationsDouble { } default: return null; } - case 3: switch (matrix1.getRows()) { - case 2: switch (matrix2.getColumns()) { + case 3: switch(matrix1.getRows()) { + case 1: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix1x3x1(matrix1, matrix2, output); + case 2: return multiplyMatrix1x3x2(matrix1, matrix2, output); + case 3: return multiplyMatrix1x3x3(matrix1, matrix2, output); + case 4: return multiplyMatrix1x3x4(matrix1, matrix2, output); + case 5: return multiplyMatrix1x3x5(matrix1, matrix2, output); + default: return null; + } + case 2: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix2x3x1(matrix1, matrix2, output); case 2: return multiplyMatrix2x3x2(matrix1, matrix2, output); case 3: return multiplyMatrix2x3x3(matrix1, matrix2, output); case 4: return multiplyMatrix2x3x4(matrix1, matrix2, output); case 5: return multiplyMatrix2x3x5(matrix1, matrix2, output); default: return null; } - case 3: switch (matrix2.getColumns()) { + case 3: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix3x3x1(matrix1, matrix2, output); case 2: return multiplyMatrix3x3x2(matrix1, matrix2, output); case 3: return multiplyMatrix3x3x3(matrix1, matrix2, output); case 4: return multiplyMatrix3x3x4(matrix1, matrix2, output); case 5: return multiplyMatrix3x3x5(matrix1, matrix2, output); default: return null; } - case 4: switch (matrix2.getColumns()) { + case 4: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix4x3x1(matrix1, matrix2, output); case 2: return multiplyMatrix4x3x2(matrix1, matrix2, output); case 3: return multiplyMatrix4x3x3(matrix1, matrix2, output); case 4: return multiplyMatrix4x3x4(matrix1, matrix2, output); case 5: return multiplyMatrix4x3x5(matrix1, matrix2, output); default: return null; } - case 5: switch (matrix2.getColumns()) { + case 5: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix5x3x1(matrix1, matrix2, output); case 2: return multiplyMatrix5x3x2(matrix1, matrix2, output); case 3: return multiplyMatrix5x3x3(matrix1, matrix2, output); case 4: return multiplyMatrix5x3x4(matrix1, matrix2, output); @@ -2956,29 +4501,41 @@ public final class MultiplicationsDouble { } default: return null; } - case 4: switch (matrix1.getRows()) { - case 2: switch (matrix2.getColumns()) { + case 4: switch(matrix1.getRows()) { + case 1: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix1x4x1(matrix1, matrix2, output); + case 2: return multiplyMatrix1x4x2(matrix1, matrix2, output); + case 3: return multiplyMatrix1x4x3(matrix1, matrix2, output); + case 4: return multiplyMatrix1x4x4(matrix1, matrix2, output); + case 5: return multiplyMatrix1x4x5(matrix1, matrix2, output); + default: return null; + } + case 2: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix2x4x1(matrix1, matrix2, output); case 2: return multiplyMatrix2x4x2(matrix1, matrix2, output); case 3: return multiplyMatrix2x4x3(matrix1, matrix2, output); case 4: return multiplyMatrix2x4x4(matrix1, matrix2, output); case 5: return multiplyMatrix2x4x5(matrix1, matrix2, output); default: return null; } - case 3: switch (matrix2.getColumns()) { + case 3: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix3x4x1(matrix1, matrix2, output); case 2: return multiplyMatrix3x4x2(matrix1, matrix2, output); case 3: return multiplyMatrix3x4x3(matrix1, matrix2, output); case 4: return multiplyMatrix3x4x4(matrix1, matrix2, output); case 5: return multiplyMatrix3x4x5(matrix1, matrix2, output); default: return null; } - case 4: switch (matrix2.getColumns()) { + case 4: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix4x4x1(matrix1, matrix2, output); case 2: return multiplyMatrix4x4x2(matrix1, matrix2, output); case 3: return multiplyMatrix4x4x3(matrix1, matrix2, output); case 4: return multiplyMatrix4x4x4(matrix1, matrix2, output); case 5: return multiplyMatrix4x4x5(matrix1, matrix2, output); default: return null; } - case 5: switch (matrix2.getColumns()) { + case 5: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix5x4x1(matrix1, matrix2, output); case 2: return multiplyMatrix5x4x2(matrix1, matrix2, output); case 3: return multiplyMatrix5x4x3(matrix1, matrix2, output); case 4: return multiplyMatrix5x4x4(matrix1, matrix2, output); @@ -2987,29 +4544,41 @@ public final class MultiplicationsDouble { } default: return null; } - case 5: switch (matrix1.getRows()) { - case 2: switch (matrix2.getColumns()) { + case 5: switch(matrix1.getRows()) { + case 1: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix1x5x1(matrix1, matrix2, output); + case 2: return multiplyMatrix1x5x2(matrix1, matrix2, output); + case 3: return multiplyMatrix1x5x3(matrix1, matrix2, output); + case 4: return multiplyMatrix1x5x4(matrix1, matrix2, output); + case 5: return multiplyMatrix1x5x5(matrix1, matrix2, output); + default: return null; + } + case 2: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix2x5x1(matrix1, matrix2, output); case 2: return multiplyMatrix2x5x2(matrix1, matrix2, output); case 3: return multiplyMatrix2x5x3(matrix1, matrix2, output); case 4: return multiplyMatrix2x5x4(matrix1, matrix2, output); case 5: return multiplyMatrix2x5x5(matrix1, matrix2, output); default: return null; } - case 3: switch (matrix2.getColumns()) { + case 3: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix3x5x1(matrix1, matrix2, output); case 2: return multiplyMatrix3x5x2(matrix1, matrix2, output); case 3: return multiplyMatrix3x5x3(matrix1, matrix2, output); case 4: return multiplyMatrix3x5x4(matrix1, matrix2, output); case 5: return multiplyMatrix3x5x5(matrix1, matrix2, output); default: return null; } - case 4: switch (matrix2.getColumns()) { + case 4: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix4x5x1(matrix1, matrix2, output); case 2: return multiplyMatrix4x5x2(matrix1, matrix2, output); case 3: return multiplyMatrix4x5x3(matrix1, matrix2, output); case 4: return multiplyMatrix4x5x4(matrix1, matrix2, output); case 5: return multiplyMatrix4x5x5(matrix1, matrix2, output); default: return null; } - case 5: switch (matrix2.getColumns()) { + case 5: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix5x5x1(matrix1, matrix2, output); case 2: return multiplyMatrix5x5x2(matrix1, matrix2, output); case 3: return multiplyMatrix5x5x3(matrix1, matrix2, output); case 4: return multiplyMatrix5x5x4(matrix1, matrix2, output); diff --git a/src/kvector/java/ru/dbotthepony/kvector/matrix/generated/MultiplicationsFloat.java b/src/kvector/java/ru/dbotthepony/kvector/matrix/generated/MultiplicationsFloat.java index da618f4f..e67f1085 100644 --- a/src/kvector/java/ru/dbotthepony/kvector/matrix/generated/MultiplicationsFloat.java +++ b/src/kvector/java/ru/dbotthepony/kvector/matrix/generated/MultiplicationsFloat.java @@ -3,7 +3,6 @@ package ru.dbotthepony.kvector.matrix.generated; import ru.dbotthepony.kvector.api.*; import ru.dbotthepony.kvector.narray.*; -// Some metaprogramming ///////////////////////////////// // THIS FILE IS AUTO GENERATED // // DO NOT EDIT // @@ -11,2775 +10,4218 @@ import ru.dbotthepony.kvector.narray.*; public final class MultiplicationsFloat { private MultiplicationsFloat() {} + private static IMatrixSetterFloat multiplyMatrix1x1x1(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final float f00 = matrix1.get(0, 0); + final float s00 = matrix2.get(0, 0); + output.set(0, 0, f00 * s00); + return output; + } + + private static IMatrixSetterFloat multiplyMatrix1x1x2(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final float f00 = matrix1.get(0, 0); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + return output; + } + + private static IMatrixSetterFloat multiplyMatrix1x1x3(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final float f00 = matrix1.get(0, 0); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(2, 0, f00 * s20); + return output; + } + + private static IMatrixSetterFloat multiplyMatrix1x1x4(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final float f00 = matrix1.get(0, 0); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + final float s30 = matrix2.get(3, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(2, 0, f00 * s20); + output.set(3, 0, f00 * s30); + return output; + } + + private static IMatrixSetterFloat multiplyMatrix1x1x5(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final float f00 = matrix1.get(0, 0); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + final float s30 = matrix2.get(3, 0); + final float s40 = matrix2.get(4, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(2, 0, f00 * s20); + output.set(3, 0, f00 * s30); + output.set(4, 0, f00 * s40); + return output; + } + + private static IMatrixSetterFloat multiplyMatrix2x1x1(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final float f00 = matrix1.get(0, 0); + final float f01 = matrix1.get(0, 1); + final float s00 = matrix2.get(0, 0); + output.set(0, 0, f00 * s00); + output.set(0, 1, f01 * s00); + return output; + } + + private static IMatrixSetterFloat multiplyMatrix2x1x2(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final float f00 = matrix1.get(0, 0); + final float f01 = matrix1.get(0, 1); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(0, 1, f01 * s00); + output.set(1, 1, f01 * s10); + return output; + } + + private static IMatrixSetterFloat multiplyMatrix2x1x3(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final float f00 = matrix1.get(0, 0); + final float f01 = matrix1.get(0, 1); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(2, 0, f00 * s20); + output.set(0, 1, f01 * s00); + output.set(1, 1, f01 * s10); + output.set(2, 1, f01 * s20); + return output; + } + + private static IMatrixSetterFloat multiplyMatrix2x1x4(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final float f00 = matrix1.get(0, 0); + final float f01 = matrix1.get(0, 1); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + final float s30 = matrix2.get(3, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(2, 0, f00 * s20); + output.set(3, 0, f00 * s30); + output.set(0, 1, f01 * s00); + output.set(1, 1, f01 * s10); + output.set(2, 1, f01 * s20); + output.set(3, 1, f01 * s30); + return output; + } + + private static IMatrixSetterFloat multiplyMatrix2x1x5(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final float f00 = matrix1.get(0, 0); + final float f01 = matrix1.get(0, 1); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + final float s30 = matrix2.get(3, 0); + final float s40 = matrix2.get(4, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(2, 0, f00 * s20); + output.set(3, 0, f00 * s30); + output.set(4, 0, f00 * s40); + output.set(0, 1, f01 * s00); + output.set(1, 1, f01 * s10); + output.set(2, 1, f01 * s20); + output.set(3, 1, f01 * s30); + output.set(4, 1, f01 * s40); + return output; + } + + private static IMatrixSetterFloat multiplyMatrix3x1x1(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final float f00 = matrix1.get(0, 0); + final float f01 = matrix1.get(0, 1); + final float f02 = matrix1.get(0, 2); + final float s00 = matrix2.get(0, 0); + output.set(0, 0, f00 * s00); + output.set(0, 1, f01 * s00); + output.set(0, 2, f02 * s00); + return output; + } + + private static IMatrixSetterFloat multiplyMatrix3x1x2(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final float f00 = matrix1.get(0, 0); + final float f01 = matrix1.get(0, 1); + final float f02 = matrix1.get(0, 2); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(0, 1, f01 * s00); + output.set(1, 1, f01 * s10); + output.set(0, 2, f02 * s00); + output.set(1, 2, f02 * s10); + return output; + } + + private static IMatrixSetterFloat multiplyMatrix3x1x3(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final float f00 = matrix1.get(0, 0); + final float f01 = matrix1.get(0, 1); + final float f02 = matrix1.get(0, 2); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(2, 0, f00 * s20); + output.set(0, 1, f01 * s00); + output.set(1, 1, f01 * s10); + output.set(2, 1, f01 * s20); + output.set(0, 2, f02 * s00); + output.set(1, 2, f02 * s10); + output.set(2, 2, f02 * s20); + return output; + } + + private static IMatrixSetterFloat multiplyMatrix3x1x4(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final float f00 = matrix1.get(0, 0); + final float f01 = matrix1.get(0, 1); + final float f02 = matrix1.get(0, 2); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + final float s30 = matrix2.get(3, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(2, 0, f00 * s20); + output.set(3, 0, f00 * s30); + output.set(0, 1, f01 * s00); + output.set(1, 1, f01 * s10); + output.set(2, 1, f01 * s20); + output.set(3, 1, f01 * s30); + output.set(0, 2, f02 * s00); + output.set(1, 2, f02 * s10); + output.set(2, 2, f02 * s20); + output.set(3, 2, f02 * s30); + return output; + } + + private static IMatrixSetterFloat multiplyMatrix3x1x5(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final float f00 = matrix1.get(0, 0); + final float f01 = matrix1.get(0, 1); + final float f02 = matrix1.get(0, 2); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + final float s30 = matrix2.get(3, 0); + final float s40 = matrix2.get(4, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(2, 0, f00 * s20); + output.set(3, 0, f00 * s30); + output.set(4, 0, f00 * s40); + output.set(0, 1, f01 * s00); + output.set(1, 1, f01 * s10); + output.set(2, 1, f01 * s20); + output.set(3, 1, f01 * s30); + output.set(4, 1, f01 * s40); + output.set(0, 2, f02 * s00); + output.set(1, 2, f02 * s10); + output.set(2, 2, f02 * s20); + output.set(3, 2, f02 * s30); + output.set(4, 2, f02 * s40); + return output; + } + + private static IMatrixSetterFloat multiplyMatrix4x1x1(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final float f00 = matrix1.get(0, 0); + final float f01 = matrix1.get(0, 1); + final float f02 = matrix1.get(0, 2); + final float f03 = matrix1.get(0, 3); + final float s00 = matrix2.get(0, 0); + output.set(0, 0, f00 * s00); + output.set(0, 1, f01 * s00); + output.set(0, 2, f02 * s00); + output.set(0, 3, f03 * s00); + return output; + } + + private static IMatrixSetterFloat multiplyMatrix4x1x2(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final float f00 = matrix1.get(0, 0); + final float f01 = matrix1.get(0, 1); + final float f02 = matrix1.get(0, 2); + final float f03 = matrix1.get(0, 3); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(0, 1, f01 * s00); + output.set(1, 1, f01 * s10); + output.set(0, 2, f02 * s00); + output.set(1, 2, f02 * s10); + output.set(0, 3, f03 * s00); + output.set(1, 3, f03 * s10); + return output; + } + + private static IMatrixSetterFloat multiplyMatrix4x1x3(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final float f00 = matrix1.get(0, 0); + final float f01 = matrix1.get(0, 1); + final float f02 = matrix1.get(0, 2); + final float f03 = matrix1.get(0, 3); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(2, 0, f00 * s20); + output.set(0, 1, f01 * s00); + output.set(1, 1, f01 * s10); + output.set(2, 1, f01 * s20); + output.set(0, 2, f02 * s00); + output.set(1, 2, f02 * s10); + output.set(2, 2, f02 * s20); + output.set(0, 3, f03 * s00); + output.set(1, 3, f03 * s10); + output.set(2, 3, f03 * s20); + return output; + } + + private static IMatrixSetterFloat multiplyMatrix4x1x4(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final float f00 = matrix1.get(0, 0); + final float f01 = matrix1.get(0, 1); + final float f02 = matrix1.get(0, 2); + final float f03 = matrix1.get(0, 3); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + final float s30 = matrix2.get(3, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(2, 0, f00 * s20); + output.set(3, 0, f00 * s30); + output.set(0, 1, f01 * s00); + output.set(1, 1, f01 * s10); + output.set(2, 1, f01 * s20); + output.set(3, 1, f01 * s30); + output.set(0, 2, f02 * s00); + output.set(1, 2, f02 * s10); + output.set(2, 2, f02 * s20); + output.set(3, 2, f02 * s30); + output.set(0, 3, f03 * s00); + output.set(1, 3, f03 * s10); + output.set(2, 3, f03 * s20); + output.set(3, 3, f03 * s30); + return output; + } + + private static IMatrixSetterFloat multiplyMatrix4x1x5(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final float f00 = matrix1.get(0, 0); + final float f01 = matrix1.get(0, 1); + final float f02 = matrix1.get(0, 2); + final float f03 = matrix1.get(0, 3); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + final float s30 = matrix2.get(3, 0); + final float s40 = matrix2.get(4, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(2, 0, f00 * s20); + output.set(3, 0, f00 * s30); + output.set(4, 0, f00 * s40); + output.set(0, 1, f01 * s00); + output.set(1, 1, f01 * s10); + output.set(2, 1, f01 * s20); + output.set(3, 1, f01 * s30); + output.set(4, 1, f01 * s40); + output.set(0, 2, f02 * s00); + output.set(1, 2, f02 * s10); + output.set(2, 2, f02 * s20); + output.set(3, 2, f02 * s30); + output.set(4, 2, f02 * s40); + output.set(0, 3, f03 * s00); + output.set(1, 3, f03 * s10); + output.set(2, 3, f03 * s20); + output.set(3, 3, f03 * s30); + output.set(4, 3, f03 * s40); + return output; + } + + private static IMatrixSetterFloat multiplyMatrix5x1x1(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final float f00 = matrix1.get(0, 0); + final float f01 = matrix1.get(0, 1); + final float f02 = matrix1.get(0, 2); + final float f03 = matrix1.get(0, 3); + final float f04 = matrix1.get(0, 4); + final float s00 = matrix2.get(0, 0); + output.set(0, 0, f00 * s00); + output.set(0, 1, f01 * s00); + output.set(0, 2, f02 * s00); + output.set(0, 3, f03 * s00); + output.set(0, 4, f04 * s00); + return output; + } + + private static IMatrixSetterFloat multiplyMatrix5x1x2(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final float f00 = matrix1.get(0, 0); + final float f01 = matrix1.get(0, 1); + final float f02 = matrix1.get(0, 2); + final float f03 = matrix1.get(0, 3); + final float f04 = matrix1.get(0, 4); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(0, 1, f01 * s00); + output.set(1, 1, f01 * s10); + output.set(0, 2, f02 * s00); + output.set(1, 2, f02 * s10); + output.set(0, 3, f03 * s00); + output.set(1, 3, f03 * s10); + output.set(0, 4, f04 * s00); + output.set(1, 4, f04 * s10); + return output; + } + + private static IMatrixSetterFloat multiplyMatrix5x1x3(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final float f00 = matrix1.get(0, 0); + final float f01 = matrix1.get(0, 1); + final float f02 = matrix1.get(0, 2); + final float f03 = matrix1.get(0, 3); + final float f04 = matrix1.get(0, 4); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(2, 0, f00 * s20); + output.set(0, 1, f01 * s00); + output.set(1, 1, f01 * s10); + output.set(2, 1, f01 * s20); + output.set(0, 2, f02 * s00); + output.set(1, 2, f02 * s10); + output.set(2, 2, f02 * s20); + output.set(0, 3, f03 * s00); + output.set(1, 3, f03 * s10); + output.set(2, 3, f03 * s20); + output.set(0, 4, f04 * s00); + output.set(1, 4, f04 * s10); + output.set(2, 4, f04 * s20); + return output; + } + + private static IMatrixSetterFloat multiplyMatrix5x1x4(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final float f00 = matrix1.get(0, 0); + final float f01 = matrix1.get(0, 1); + final float f02 = matrix1.get(0, 2); + final float f03 = matrix1.get(0, 3); + final float f04 = matrix1.get(0, 4); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + final float s30 = matrix2.get(3, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(2, 0, f00 * s20); + output.set(3, 0, f00 * s30); + output.set(0, 1, f01 * s00); + output.set(1, 1, f01 * s10); + output.set(2, 1, f01 * s20); + output.set(3, 1, f01 * s30); + output.set(0, 2, f02 * s00); + output.set(1, 2, f02 * s10); + output.set(2, 2, f02 * s20); + output.set(3, 2, f02 * s30); + output.set(0, 3, f03 * s00); + output.set(1, 3, f03 * s10); + output.set(2, 3, f03 * s20); + output.set(3, 3, f03 * s30); + output.set(0, 4, f04 * s00); + output.set(1, 4, f04 * s10); + output.set(2, 4, f04 * s20); + output.set(3, 4, f04 * s30); + return output; + } + + private static IMatrixSetterFloat multiplyMatrix5x1x5(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final float f00 = matrix1.get(0, 0); + final float f01 = matrix1.get(0, 1); + final float f02 = matrix1.get(0, 2); + final float f03 = matrix1.get(0, 3); + final float f04 = matrix1.get(0, 4); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + final float s30 = matrix2.get(3, 0); + final float s40 = matrix2.get(4, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(2, 0, f00 * s20); + output.set(3, 0, f00 * s30); + output.set(4, 0, f00 * s40); + output.set(0, 1, f01 * s00); + output.set(1, 1, f01 * s10); + output.set(2, 1, f01 * s20); + output.set(3, 1, f01 * s30); + output.set(4, 1, f01 * s40); + output.set(0, 2, f02 * s00); + output.set(1, 2, f02 * s10); + output.set(2, 2, f02 * s20); + output.set(3, 2, f02 * s30); + output.set(4, 2, f02 * s40); + output.set(0, 3, f03 * s00); + output.set(1, 3, f03 * s10); + output.set(2, 3, f03 * s20); + output.set(3, 3, f03 * s30); + output.set(4, 3, f03 * s40); + output.set(0, 4, f04 * s00); + output.set(1, 4, f04 * s10); + output.set(2, 4, f04 * s20); + output.set(3, 4, f04 * s30); + output.set(4, 4, f04 * s40); + return output; + } + + private static IMatrixSetterFloat multiplyMatrix1x2x1(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float s00 = matrix2.get(0, 0); + final float s01 = matrix2.get(0, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + return output; + } + + private static IMatrixSetterFloat multiplyMatrix1x2x2(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + return output; + } + + private static IMatrixSetterFloat multiplyMatrix1x2x3(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s21 = matrix2.get(2, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(2, 0, f00 * s20 + f10 * s21); + return output; + } + + private static IMatrixSetterFloat multiplyMatrix1x2x4(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + final float s30 = matrix2.get(3, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s21 = matrix2.get(2, 1); + final float s31 = matrix2.get(3, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(2, 0, f00 * s20 + f10 * s21); + output.set(3, 0, f00 * s30 + f10 * s31); + return output; + } + + private static IMatrixSetterFloat multiplyMatrix1x2x5(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + final float s30 = matrix2.get(3, 0); + final float s40 = matrix2.get(4, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s21 = matrix2.get(2, 1); + final float s31 = matrix2.get(3, 1); + final float s41 = matrix2.get(4, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(2, 0, f00 * s20 + f10 * s21); + output.set(3, 0, f00 * s30 + f10 * s31); + output.set(4, 0, f00 * s40 + f10 * s41); + return output; + } + + private static IMatrixSetterFloat multiplyMatrix2x2x1(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float s00 = matrix2.get(0, 0); + final float s01 = matrix2.get(0, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(0, 1, f01 * s00 + f11 * s01); + return output; + } private static IMatrixSetterFloat multiplyMatrix2x2x2(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final float f_c00 = matrix1.get(0, 0); - final float f_c10 = matrix1.get(1, 0); - final float f_c01 = matrix1.get(0, 1); - final float f_c11 = matrix1.get(1, 1); - final float s_c00 = matrix2.get(0, 0); - final float s_c10 = matrix2.get(1, 0); - final float s_c01 = matrix2.get(0, 1); - final float s_c11 = matrix2.get(1, 1); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(1, 1, f01 * s10 + f11 * s11); return output; } private static IMatrixSetterFloat multiplyMatrix2x2x3(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final float f_c00 = matrix1.get(0, 0); - final float f_c10 = matrix1.get(1, 0); - final float f_c01 = matrix1.get(0, 1); - final float f_c11 = matrix1.get(1, 1); - final float s_c00 = matrix2.get(0, 0); - final float s_c10 = matrix2.get(1, 0); - final float s_c20 = matrix2.get(2, 0); - final float s_c01 = matrix2.get(0, 1); - final float s_c11 = matrix2.get(1, 1); - final float s_c21 = matrix2.get(2, 1); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s21 = matrix2.get(2, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(2, 0, f00 * s20 + f10 * s21); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(1, 1, f01 * s10 + f11 * s11); + output.set(2, 1, f01 * s20 + f11 * s21); return output; } private static IMatrixSetterFloat multiplyMatrix2x2x4(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final float f_c00 = matrix1.get(0, 0); - final float f_c10 = matrix1.get(1, 0); - final float f_c01 = matrix1.get(0, 1); - final float f_c11 = matrix1.get(1, 1); - final float s_c00 = matrix2.get(0, 0); - final float s_c10 = matrix2.get(1, 0); - final float s_c20 = matrix2.get(2, 0); - final float s_c30 = matrix2.get(3, 0); - final float s_c01 = matrix2.get(0, 1); - final float s_c11 = matrix2.get(1, 1); - final float s_c21 = matrix2.get(2, 1); - final float s_c31 = matrix2.get(3, 1); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + final float s30 = matrix2.get(3, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s21 = matrix2.get(2, 1); + final float s31 = matrix2.get(3, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(2, 0, f00 * s20 + f10 * s21); + output.set(3, 0, f00 * s30 + f10 * s31); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(1, 1, f01 * s10 + f11 * s11); + output.set(2, 1, f01 * s20 + f11 * s21); + output.set(3, 1, f01 * s30 + f11 * s31); return output; } private static IMatrixSetterFloat multiplyMatrix2x2x5(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final float f_c00 = matrix1.get(0, 0); - final float f_c10 = matrix1.get(1, 0); - final float f_c01 = matrix1.get(0, 1); - final float f_c11 = matrix1.get(1, 1); - final float s_c00 = matrix2.get(0, 0); - final float s_c10 = matrix2.get(1, 0); - final float s_c20 = matrix2.get(2, 0); - final float s_c30 = matrix2.get(3, 0); - final float s_c40 = matrix2.get(4, 0); - final float s_c01 = matrix2.get(0, 1); - final float s_c11 = matrix2.get(1, 1); - final float s_c21 = matrix2.get(2, 1); - final float s_c31 = matrix2.get(3, 1); - final float s_c41 = matrix2.get(4, 1); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31); - output.set(4, 0, f_c00*s_c40 + f_c10*s_c41); - output.set(4, 1, f_c01*s_c40 + f_c11*s_c41); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + final float s30 = matrix2.get(3, 0); + final float s40 = matrix2.get(4, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s21 = matrix2.get(2, 1); + final float s31 = matrix2.get(3, 1); + final float s41 = matrix2.get(4, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(2, 0, f00 * s20 + f10 * s21); + output.set(3, 0, f00 * s30 + f10 * s31); + output.set(4, 0, f00 * s40 + f10 * s41); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(1, 1, f01 * s10 + f11 * s11); + output.set(2, 1, f01 * s20 + f11 * s21); + output.set(3, 1, f01 * s30 + f11 * s31); + output.set(4, 1, f01 * s40 + f11 * s41); + return output; + } + + private static IMatrixSetterFloat multiplyMatrix3x2x1(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f02 = matrix1.get(0, 2); + final float f12 = matrix1.get(1, 2); + final float s00 = matrix2.get(0, 0); + final float s01 = matrix2.get(0, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(0, 2, f02 * s00 + f12 * s01); return output; } private static IMatrixSetterFloat multiplyMatrix3x2x2(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final float f_c00 = matrix1.get(0, 0); - final float f_c10 = matrix1.get(1, 0); - final float f_c01 = matrix1.get(0, 1); - final float f_c11 = matrix1.get(1, 1); - final float f_c02 = matrix1.get(0, 2); - final float f_c12 = matrix1.get(1, 2); - final float s_c00 = matrix2.get(0, 0); - final float s_c10 = matrix2.get(1, 0); - final float s_c01 = matrix2.get(0, 1); - final float s_c11 = matrix2.get(1, 1); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f02 = matrix1.get(0, 2); + final float f12 = matrix1.get(1, 2); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(1, 1, f01 * s10 + f11 * s11); + output.set(0, 2, f02 * s00 + f12 * s01); + output.set(1, 2, f02 * s10 + f12 * s11); return output; } private static IMatrixSetterFloat multiplyMatrix3x2x3(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final float f_c00 = matrix1.get(0, 0); - final float f_c10 = matrix1.get(1, 0); - final float f_c01 = matrix1.get(0, 1); - final float f_c11 = matrix1.get(1, 1); - final float f_c02 = matrix1.get(0, 2); - final float f_c12 = matrix1.get(1, 2); - final float s_c00 = matrix2.get(0, 0); - final float s_c10 = matrix2.get(1, 0); - final float s_c20 = matrix2.get(2, 0); - final float s_c01 = matrix2.get(0, 1); - final float s_c11 = matrix2.get(1, 1); - final float s_c21 = matrix2.get(2, 1); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f02 = matrix1.get(0, 2); + final float f12 = matrix1.get(1, 2); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s21 = matrix2.get(2, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(2, 0, f00 * s20 + f10 * s21); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(1, 1, f01 * s10 + f11 * s11); + output.set(2, 1, f01 * s20 + f11 * s21); + output.set(0, 2, f02 * s00 + f12 * s01); + output.set(1, 2, f02 * s10 + f12 * s11); + output.set(2, 2, f02 * s20 + f12 * s21); return output; } private static IMatrixSetterFloat multiplyMatrix3x2x4(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final float f_c00 = matrix1.get(0, 0); - final float f_c10 = matrix1.get(1, 0); - final float f_c01 = matrix1.get(0, 1); - final float f_c11 = matrix1.get(1, 1); - final float f_c02 = matrix1.get(0, 2); - final float f_c12 = matrix1.get(1, 2); - final float s_c00 = matrix2.get(0, 0); - final float s_c10 = matrix2.get(1, 0); - final float s_c20 = matrix2.get(2, 0); - final float s_c30 = matrix2.get(3, 0); - final float s_c01 = matrix2.get(0, 1); - final float s_c11 = matrix2.get(1, 1); - final float s_c21 = matrix2.get(2, 1); - final float s_c31 = matrix2.get(3, 1); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f02 = matrix1.get(0, 2); + final float f12 = matrix1.get(1, 2); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + final float s30 = matrix2.get(3, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s21 = matrix2.get(2, 1); + final float s31 = matrix2.get(3, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(2, 0, f00 * s20 + f10 * s21); + output.set(3, 0, f00 * s30 + f10 * s31); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(1, 1, f01 * s10 + f11 * s11); + output.set(2, 1, f01 * s20 + f11 * s21); + output.set(3, 1, f01 * s30 + f11 * s31); + output.set(0, 2, f02 * s00 + f12 * s01); + output.set(1, 2, f02 * s10 + f12 * s11); + output.set(2, 2, f02 * s20 + f12 * s21); + output.set(3, 2, f02 * s30 + f12 * s31); return output; } private static IMatrixSetterFloat multiplyMatrix3x2x5(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final float f_c00 = matrix1.get(0, 0); - final float f_c10 = matrix1.get(1, 0); - final float f_c01 = matrix1.get(0, 1); - final float f_c11 = matrix1.get(1, 1); - final float f_c02 = matrix1.get(0, 2); - final float f_c12 = matrix1.get(1, 2); - final float s_c00 = matrix2.get(0, 0); - final float s_c10 = matrix2.get(1, 0); - final float s_c20 = matrix2.get(2, 0); - final float s_c30 = matrix2.get(3, 0); - final float s_c40 = matrix2.get(4, 0); - final float s_c01 = matrix2.get(0, 1); - final float s_c11 = matrix2.get(1, 1); - final float s_c21 = matrix2.get(2, 1); - final float s_c31 = matrix2.get(3, 1); - final float s_c41 = matrix2.get(4, 1); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31); - output.set(4, 0, f_c00*s_c40 + f_c10*s_c41); - output.set(4, 1, f_c01*s_c40 + f_c11*s_c41); - output.set(4, 2, f_c02*s_c40 + f_c12*s_c41); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f02 = matrix1.get(0, 2); + final float f12 = matrix1.get(1, 2); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + final float s30 = matrix2.get(3, 0); + final float s40 = matrix2.get(4, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s21 = matrix2.get(2, 1); + final float s31 = matrix2.get(3, 1); + final float s41 = matrix2.get(4, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(2, 0, f00 * s20 + f10 * s21); + output.set(3, 0, f00 * s30 + f10 * s31); + output.set(4, 0, f00 * s40 + f10 * s41); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(1, 1, f01 * s10 + f11 * s11); + output.set(2, 1, f01 * s20 + f11 * s21); + output.set(3, 1, f01 * s30 + f11 * s31); + output.set(4, 1, f01 * s40 + f11 * s41); + output.set(0, 2, f02 * s00 + f12 * s01); + output.set(1, 2, f02 * s10 + f12 * s11); + output.set(2, 2, f02 * s20 + f12 * s21); + output.set(3, 2, f02 * s30 + f12 * s31); + output.set(4, 2, f02 * s40 + f12 * s41); + return output; + } + + private static IMatrixSetterFloat multiplyMatrix4x2x1(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f02 = matrix1.get(0, 2); + final float f12 = matrix1.get(1, 2); + final float f03 = matrix1.get(0, 3); + final float f13 = matrix1.get(1, 3); + final float s00 = matrix2.get(0, 0); + final float s01 = matrix2.get(0, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(0, 2, f02 * s00 + f12 * s01); + output.set(0, 3, f03 * s00 + f13 * s01); return output; } private static IMatrixSetterFloat multiplyMatrix4x2x2(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final float f_c00 = matrix1.get(0, 0); - final float f_c10 = matrix1.get(1, 0); - final float f_c01 = matrix1.get(0, 1); - final float f_c11 = matrix1.get(1, 1); - final float f_c02 = matrix1.get(0, 2); - final float f_c12 = matrix1.get(1, 2); - final float f_c03 = matrix1.get(0, 3); - final float f_c13 = matrix1.get(1, 3); - final float s_c00 = matrix2.get(0, 0); - final float s_c10 = matrix2.get(1, 0); - final float s_c01 = matrix2.get(0, 1); - final float s_c11 = matrix2.get(1, 1); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f02 = matrix1.get(0, 2); + final float f12 = matrix1.get(1, 2); + final float f03 = matrix1.get(0, 3); + final float f13 = matrix1.get(1, 3); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(1, 1, f01 * s10 + f11 * s11); + output.set(0, 2, f02 * s00 + f12 * s01); + output.set(1, 2, f02 * s10 + f12 * s11); + output.set(0, 3, f03 * s00 + f13 * s01); + output.set(1, 3, f03 * s10 + f13 * s11); return output; } private static IMatrixSetterFloat multiplyMatrix4x2x3(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final float f_c00 = matrix1.get(0, 0); - final float f_c10 = matrix1.get(1, 0); - final float f_c01 = matrix1.get(0, 1); - final float f_c11 = matrix1.get(1, 1); - final float f_c02 = matrix1.get(0, 2); - final float f_c12 = matrix1.get(1, 2); - final float f_c03 = matrix1.get(0, 3); - final float f_c13 = matrix1.get(1, 3); - final float s_c00 = matrix2.get(0, 0); - final float s_c10 = matrix2.get(1, 0); - final float s_c20 = matrix2.get(2, 0); - final float s_c01 = matrix2.get(0, 1); - final float s_c11 = matrix2.get(1, 1); - final float s_c21 = matrix2.get(2, 1); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f02 = matrix1.get(0, 2); + final float f12 = matrix1.get(1, 2); + final float f03 = matrix1.get(0, 3); + final float f13 = matrix1.get(1, 3); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s21 = matrix2.get(2, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(2, 0, f00 * s20 + f10 * s21); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(1, 1, f01 * s10 + f11 * s11); + output.set(2, 1, f01 * s20 + f11 * s21); + output.set(0, 2, f02 * s00 + f12 * s01); + output.set(1, 2, f02 * s10 + f12 * s11); + output.set(2, 2, f02 * s20 + f12 * s21); + output.set(0, 3, f03 * s00 + f13 * s01); + output.set(1, 3, f03 * s10 + f13 * s11); + output.set(2, 3, f03 * s20 + f13 * s21); return output; } private static IMatrixSetterFloat multiplyMatrix4x2x4(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final float f_c00 = matrix1.get(0, 0); - final float f_c10 = matrix1.get(1, 0); - final float f_c01 = matrix1.get(0, 1); - final float f_c11 = matrix1.get(1, 1); - final float f_c02 = matrix1.get(0, 2); - final float f_c12 = matrix1.get(1, 2); - final float f_c03 = matrix1.get(0, 3); - final float f_c13 = matrix1.get(1, 3); - final float s_c00 = matrix2.get(0, 0); - final float s_c10 = matrix2.get(1, 0); - final float s_c20 = matrix2.get(2, 0); - final float s_c30 = matrix2.get(3, 0); - final float s_c01 = matrix2.get(0, 1); - final float s_c11 = matrix2.get(1, 1); - final float s_c21 = matrix2.get(2, 1); - final float s_c31 = matrix2.get(3, 1); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31); - output.set(3, 3, f_c03*s_c30 + f_c13*s_c31); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f02 = matrix1.get(0, 2); + final float f12 = matrix1.get(1, 2); + final float f03 = matrix1.get(0, 3); + final float f13 = matrix1.get(1, 3); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + final float s30 = matrix2.get(3, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s21 = matrix2.get(2, 1); + final float s31 = matrix2.get(3, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(2, 0, f00 * s20 + f10 * s21); + output.set(3, 0, f00 * s30 + f10 * s31); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(1, 1, f01 * s10 + f11 * s11); + output.set(2, 1, f01 * s20 + f11 * s21); + output.set(3, 1, f01 * s30 + f11 * s31); + output.set(0, 2, f02 * s00 + f12 * s01); + output.set(1, 2, f02 * s10 + f12 * s11); + output.set(2, 2, f02 * s20 + f12 * s21); + output.set(3, 2, f02 * s30 + f12 * s31); + output.set(0, 3, f03 * s00 + f13 * s01); + output.set(1, 3, f03 * s10 + f13 * s11); + output.set(2, 3, f03 * s20 + f13 * s21); + output.set(3, 3, f03 * s30 + f13 * s31); return output; } private static IMatrixSetterFloat multiplyMatrix4x2x5(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final float f_c00 = matrix1.get(0, 0); - final float f_c10 = matrix1.get(1, 0); - final float f_c01 = matrix1.get(0, 1); - final float f_c11 = matrix1.get(1, 1); - final float f_c02 = matrix1.get(0, 2); - final float f_c12 = matrix1.get(1, 2); - final float f_c03 = matrix1.get(0, 3); - final float f_c13 = matrix1.get(1, 3); - final float s_c00 = matrix2.get(0, 0); - final float s_c10 = matrix2.get(1, 0); - final float s_c20 = matrix2.get(2, 0); - final float s_c30 = matrix2.get(3, 0); - final float s_c40 = matrix2.get(4, 0); - final float s_c01 = matrix2.get(0, 1); - final float s_c11 = matrix2.get(1, 1); - final float s_c21 = matrix2.get(2, 1); - final float s_c31 = matrix2.get(3, 1); - final float s_c41 = matrix2.get(4, 1); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31); - output.set(3, 3, f_c03*s_c30 + f_c13*s_c31); - output.set(4, 0, f_c00*s_c40 + f_c10*s_c41); - output.set(4, 1, f_c01*s_c40 + f_c11*s_c41); - output.set(4, 2, f_c02*s_c40 + f_c12*s_c41); - output.set(4, 3, f_c03*s_c40 + f_c13*s_c41); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f02 = matrix1.get(0, 2); + final float f12 = matrix1.get(1, 2); + final float f03 = matrix1.get(0, 3); + final float f13 = matrix1.get(1, 3); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + final float s30 = matrix2.get(3, 0); + final float s40 = matrix2.get(4, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s21 = matrix2.get(2, 1); + final float s31 = matrix2.get(3, 1); + final float s41 = matrix2.get(4, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(2, 0, f00 * s20 + f10 * s21); + output.set(3, 0, f00 * s30 + f10 * s31); + output.set(4, 0, f00 * s40 + f10 * s41); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(1, 1, f01 * s10 + f11 * s11); + output.set(2, 1, f01 * s20 + f11 * s21); + output.set(3, 1, f01 * s30 + f11 * s31); + output.set(4, 1, f01 * s40 + f11 * s41); + output.set(0, 2, f02 * s00 + f12 * s01); + output.set(1, 2, f02 * s10 + f12 * s11); + output.set(2, 2, f02 * s20 + f12 * s21); + output.set(3, 2, f02 * s30 + f12 * s31); + output.set(4, 2, f02 * s40 + f12 * s41); + output.set(0, 3, f03 * s00 + f13 * s01); + output.set(1, 3, f03 * s10 + f13 * s11); + output.set(2, 3, f03 * s20 + f13 * s21); + output.set(3, 3, f03 * s30 + f13 * s31); + output.set(4, 3, f03 * s40 + f13 * s41); + return output; + } + + private static IMatrixSetterFloat multiplyMatrix5x2x1(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f02 = matrix1.get(0, 2); + final float f12 = matrix1.get(1, 2); + final float f03 = matrix1.get(0, 3); + final float f13 = matrix1.get(1, 3); + final float f04 = matrix1.get(0, 4); + final float f14 = matrix1.get(1, 4); + final float s00 = matrix2.get(0, 0); + final float s01 = matrix2.get(0, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(0, 2, f02 * s00 + f12 * s01); + output.set(0, 3, f03 * s00 + f13 * s01); + output.set(0, 4, f04 * s00 + f14 * s01); return output; } private static IMatrixSetterFloat multiplyMatrix5x2x2(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final float f_c00 = matrix1.get(0, 0); - final float f_c10 = matrix1.get(1, 0); - final float f_c01 = matrix1.get(0, 1); - final float f_c11 = matrix1.get(1, 1); - final float f_c02 = matrix1.get(0, 2); - final float f_c12 = matrix1.get(1, 2); - final float f_c03 = matrix1.get(0, 3); - final float f_c13 = matrix1.get(1, 3); - final float f_c04 = matrix1.get(0, 4); - final float f_c14 = matrix1.get(1, 4); - final float s_c00 = matrix2.get(0, 0); - final float s_c10 = matrix2.get(1, 0); - final float s_c01 = matrix2.get(0, 1); - final float s_c11 = matrix2.get(1, 1); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01); - output.set(0, 4, f_c04*s_c00 + f_c14*s_c01); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11); - output.set(1, 4, f_c04*s_c10 + f_c14*s_c11); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f02 = matrix1.get(0, 2); + final float f12 = matrix1.get(1, 2); + final float f03 = matrix1.get(0, 3); + final float f13 = matrix1.get(1, 3); + final float f04 = matrix1.get(0, 4); + final float f14 = matrix1.get(1, 4); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(1, 1, f01 * s10 + f11 * s11); + output.set(0, 2, f02 * s00 + f12 * s01); + output.set(1, 2, f02 * s10 + f12 * s11); + output.set(0, 3, f03 * s00 + f13 * s01); + output.set(1, 3, f03 * s10 + f13 * s11); + output.set(0, 4, f04 * s00 + f14 * s01); + output.set(1, 4, f04 * s10 + f14 * s11); return output; } private static IMatrixSetterFloat multiplyMatrix5x2x3(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final float f_c00 = matrix1.get(0, 0); - final float f_c10 = matrix1.get(1, 0); - final float f_c01 = matrix1.get(0, 1); - final float f_c11 = matrix1.get(1, 1); - final float f_c02 = matrix1.get(0, 2); - final float f_c12 = matrix1.get(1, 2); - final float f_c03 = matrix1.get(0, 3); - final float f_c13 = matrix1.get(1, 3); - final float f_c04 = matrix1.get(0, 4); - final float f_c14 = matrix1.get(1, 4); - final float s_c00 = matrix2.get(0, 0); - final float s_c10 = matrix2.get(1, 0); - final float s_c20 = matrix2.get(2, 0); - final float s_c01 = matrix2.get(0, 1); - final float s_c11 = matrix2.get(1, 1); - final float s_c21 = matrix2.get(2, 1); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01); - output.set(0, 4, f_c04*s_c00 + f_c14*s_c01); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11); - output.set(1, 4, f_c04*s_c10 + f_c14*s_c11); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21); - output.set(2, 4, f_c04*s_c20 + f_c14*s_c21); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f02 = matrix1.get(0, 2); + final float f12 = matrix1.get(1, 2); + final float f03 = matrix1.get(0, 3); + final float f13 = matrix1.get(1, 3); + final float f04 = matrix1.get(0, 4); + final float f14 = matrix1.get(1, 4); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s21 = matrix2.get(2, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(2, 0, f00 * s20 + f10 * s21); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(1, 1, f01 * s10 + f11 * s11); + output.set(2, 1, f01 * s20 + f11 * s21); + output.set(0, 2, f02 * s00 + f12 * s01); + output.set(1, 2, f02 * s10 + f12 * s11); + output.set(2, 2, f02 * s20 + f12 * s21); + output.set(0, 3, f03 * s00 + f13 * s01); + output.set(1, 3, f03 * s10 + f13 * s11); + output.set(2, 3, f03 * s20 + f13 * s21); + output.set(0, 4, f04 * s00 + f14 * s01); + output.set(1, 4, f04 * s10 + f14 * s11); + output.set(2, 4, f04 * s20 + f14 * s21); return output; } private static IMatrixSetterFloat multiplyMatrix5x2x4(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final float f_c00 = matrix1.get(0, 0); - final float f_c10 = matrix1.get(1, 0); - final float f_c01 = matrix1.get(0, 1); - final float f_c11 = matrix1.get(1, 1); - final float f_c02 = matrix1.get(0, 2); - final float f_c12 = matrix1.get(1, 2); - final float f_c03 = matrix1.get(0, 3); - final float f_c13 = matrix1.get(1, 3); - final float f_c04 = matrix1.get(0, 4); - final float f_c14 = matrix1.get(1, 4); - final float s_c00 = matrix2.get(0, 0); - final float s_c10 = matrix2.get(1, 0); - final float s_c20 = matrix2.get(2, 0); - final float s_c30 = matrix2.get(3, 0); - final float s_c01 = matrix2.get(0, 1); - final float s_c11 = matrix2.get(1, 1); - final float s_c21 = matrix2.get(2, 1); - final float s_c31 = matrix2.get(3, 1); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01); - output.set(0, 4, f_c04*s_c00 + f_c14*s_c01); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11); - output.set(1, 4, f_c04*s_c10 + f_c14*s_c11); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21); - output.set(2, 4, f_c04*s_c20 + f_c14*s_c21); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31); - output.set(3, 3, f_c03*s_c30 + f_c13*s_c31); - output.set(3, 4, f_c04*s_c30 + f_c14*s_c31); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f02 = matrix1.get(0, 2); + final float f12 = matrix1.get(1, 2); + final float f03 = matrix1.get(0, 3); + final float f13 = matrix1.get(1, 3); + final float f04 = matrix1.get(0, 4); + final float f14 = matrix1.get(1, 4); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + final float s30 = matrix2.get(3, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s21 = matrix2.get(2, 1); + final float s31 = matrix2.get(3, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(2, 0, f00 * s20 + f10 * s21); + output.set(3, 0, f00 * s30 + f10 * s31); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(1, 1, f01 * s10 + f11 * s11); + output.set(2, 1, f01 * s20 + f11 * s21); + output.set(3, 1, f01 * s30 + f11 * s31); + output.set(0, 2, f02 * s00 + f12 * s01); + output.set(1, 2, f02 * s10 + f12 * s11); + output.set(2, 2, f02 * s20 + f12 * s21); + output.set(3, 2, f02 * s30 + f12 * s31); + output.set(0, 3, f03 * s00 + f13 * s01); + output.set(1, 3, f03 * s10 + f13 * s11); + output.set(2, 3, f03 * s20 + f13 * s21); + output.set(3, 3, f03 * s30 + f13 * s31); + output.set(0, 4, f04 * s00 + f14 * s01); + output.set(1, 4, f04 * s10 + f14 * s11); + output.set(2, 4, f04 * s20 + f14 * s21); + output.set(3, 4, f04 * s30 + f14 * s31); return output; } private static IMatrixSetterFloat multiplyMatrix5x2x5(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final float f_c00 = matrix1.get(0, 0); - final float f_c10 = matrix1.get(1, 0); - final float f_c01 = matrix1.get(0, 1); - final float f_c11 = matrix1.get(1, 1); - final float f_c02 = matrix1.get(0, 2); - final float f_c12 = matrix1.get(1, 2); - final float f_c03 = matrix1.get(0, 3); - final float f_c13 = matrix1.get(1, 3); - final float f_c04 = matrix1.get(0, 4); - final float f_c14 = matrix1.get(1, 4); - final float s_c00 = matrix2.get(0, 0); - final float s_c10 = matrix2.get(1, 0); - final float s_c20 = matrix2.get(2, 0); - final float s_c30 = matrix2.get(3, 0); - final float s_c40 = matrix2.get(4, 0); - final float s_c01 = matrix2.get(0, 1); - final float s_c11 = matrix2.get(1, 1); - final float s_c21 = matrix2.get(2, 1); - final float s_c31 = matrix2.get(3, 1); - final float s_c41 = matrix2.get(4, 1); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01); - output.set(0, 4, f_c04*s_c00 + f_c14*s_c01); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11); - output.set(1, 4, f_c04*s_c10 + f_c14*s_c11); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21); - output.set(2, 4, f_c04*s_c20 + f_c14*s_c21); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31); - output.set(3, 3, f_c03*s_c30 + f_c13*s_c31); - output.set(3, 4, f_c04*s_c30 + f_c14*s_c31); - output.set(4, 0, f_c00*s_c40 + f_c10*s_c41); - output.set(4, 1, f_c01*s_c40 + f_c11*s_c41); - output.set(4, 2, f_c02*s_c40 + f_c12*s_c41); - output.set(4, 3, f_c03*s_c40 + f_c13*s_c41); - output.set(4, 4, f_c04*s_c40 + f_c14*s_c41); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f02 = matrix1.get(0, 2); + final float f12 = matrix1.get(1, 2); + final float f03 = matrix1.get(0, 3); + final float f13 = matrix1.get(1, 3); + final float f04 = matrix1.get(0, 4); + final float f14 = matrix1.get(1, 4); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + final float s30 = matrix2.get(3, 0); + final float s40 = matrix2.get(4, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s21 = matrix2.get(2, 1); + final float s31 = matrix2.get(3, 1); + final float s41 = matrix2.get(4, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(2, 0, f00 * s20 + f10 * s21); + output.set(3, 0, f00 * s30 + f10 * s31); + output.set(4, 0, f00 * s40 + f10 * s41); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(1, 1, f01 * s10 + f11 * s11); + output.set(2, 1, f01 * s20 + f11 * s21); + output.set(3, 1, f01 * s30 + f11 * s31); + output.set(4, 1, f01 * s40 + f11 * s41); + output.set(0, 2, f02 * s00 + f12 * s01); + output.set(1, 2, f02 * s10 + f12 * s11); + output.set(2, 2, f02 * s20 + f12 * s21); + output.set(3, 2, f02 * s30 + f12 * s31); + output.set(4, 2, f02 * s40 + f12 * s41); + output.set(0, 3, f03 * s00 + f13 * s01); + output.set(1, 3, f03 * s10 + f13 * s11); + output.set(2, 3, f03 * s20 + f13 * s21); + output.set(3, 3, f03 * s30 + f13 * s31); + output.set(4, 3, f03 * s40 + f13 * s41); + output.set(0, 4, f04 * s00 + f14 * s01); + output.set(1, 4, f04 * s10 + f14 * s11); + output.set(2, 4, f04 * s20 + f14 * s21); + output.set(3, 4, f04 * s30 + f14 * s31); + output.set(4, 4, f04 * s40 + f14 * s41); + return output; + } + + private static IMatrixSetterFloat multiplyMatrix1x3x1(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float s00 = matrix2.get(0, 0); + final float s01 = matrix2.get(0, 1); + final float s02 = matrix2.get(0, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + return output; + } + + private static IMatrixSetterFloat multiplyMatrix1x3x2(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s02 = matrix2.get(0, 2); + final float s12 = matrix2.get(1, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + return output; + } + + private static IMatrixSetterFloat multiplyMatrix1x3x3(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s21 = matrix2.get(2, 1); + final float s02 = matrix2.get(0, 2); + final float s12 = matrix2.get(1, 2); + final float s22 = matrix2.get(2, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22); + return output; + } + + private static IMatrixSetterFloat multiplyMatrix1x3x4(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + final float s30 = matrix2.get(3, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s21 = matrix2.get(2, 1); + final float s31 = matrix2.get(3, 1); + final float s02 = matrix2.get(0, 2); + final float s12 = matrix2.get(1, 2); + final float s22 = matrix2.get(2, 2); + final float s32 = matrix2.get(3, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32); + return output; + } + + private static IMatrixSetterFloat multiplyMatrix1x3x5(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + final float s30 = matrix2.get(3, 0); + final float s40 = matrix2.get(4, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s21 = matrix2.get(2, 1); + final float s31 = matrix2.get(3, 1); + final float s41 = matrix2.get(4, 1); + final float s02 = matrix2.get(0, 2); + final float s12 = matrix2.get(1, 2); + final float s22 = matrix2.get(2, 2); + final float s32 = matrix2.get(3, 2); + final float s42 = matrix2.get(4, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32); + output.set(4, 0, f00 * s40 + f10 * s41 + f20 * s42); + return output; + } + + private static IMatrixSetterFloat multiplyMatrix2x3x1(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f21 = matrix1.get(2, 1); + final float s00 = matrix2.get(0, 0); + final float s01 = matrix2.get(0, 1); + final float s02 = matrix2.get(0, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); return output; } private static IMatrixSetterFloat multiplyMatrix2x3x2(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final float f_c00 = matrix1.get(0, 0); - final float f_c10 = matrix1.get(1, 0); - final float f_c20 = matrix1.get(2, 0); - final float f_c01 = matrix1.get(0, 1); - final float f_c11 = matrix1.get(1, 1); - final float f_c21 = matrix1.get(2, 1); - final float s_c00 = matrix2.get(0, 0); - final float s_c10 = matrix2.get(1, 0); - final float s_c01 = matrix2.get(0, 1); - final float s_c11 = matrix2.get(1, 1); - final float s_c02 = matrix2.get(0, 2); - final float s_c12 = matrix2.get(1, 2); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f21 = matrix1.get(2, 1); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s02 = matrix2.get(0, 2); + final float s12 = matrix2.get(1, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12); return output; } private static IMatrixSetterFloat multiplyMatrix2x3x3(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final float f_c00 = matrix1.get(0, 0); - final float f_c10 = matrix1.get(1, 0); - final float f_c20 = matrix1.get(2, 0); - final float f_c01 = matrix1.get(0, 1); - final float f_c11 = matrix1.get(1, 1); - final float f_c21 = matrix1.get(2, 1); - final float s_c00 = matrix2.get(0, 0); - final float s_c10 = matrix2.get(1, 0); - final float s_c20 = matrix2.get(2, 0); - final float s_c01 = matrix2.get(0, 1); - final float s_c11 = matrix2.get(1, 1); - final float s_c21 = matrix2.get(2, 1); - final float s_c02 = matrix2.get(0, 2); - final float s_c12 = matrix2.get(1, 2); - final float s_c22 = matrix2.get(2, 2); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f21 = matrix1.get(2, 1); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s21 = matrix2.get(2, 1); + final float s02 = matrix2.get(0, 2); + final float s12 = matrix2.get(1, 2); + final float s22 = matrix2.get(2, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22); return output; } private static IMatrixSetterFloat multiplyMatrix2x3x4(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final float f_c00 = matrix1.get(0, 0); - final float f_c10 = matrix1.get(1, 0); - final float f_c20 = matrix1.get(2, 0); - final float f_c01 = matrix1.get(0, 1); - final float f_c11 = matrix1.get(1, 1); - final float f_c21 = matrix1.get(2, 1); - final float s_c00 = matrix2.get(0, 0); - final float s_c10 = matrix2.get(1, 0); - final float s_c20 = matrix2.get(2, 0); - final float s_c30 = matrix2.get(3, 0); - final float s_c01 = matrix2.get(0, 1); - final float s_c11 = matrix2.get(1, 1); - final float s_c21 = matrix2.get(2, 1); - final float s_c31 = matrix2.get(3, 1); - final float s_c02 = matrix2.get(0, 2); - final float s_c12 = matrix2.get(1, 2); - final float s_c22 = matrix2.get(2, 2); - final float s_c32 = matrix2.get(3, 2); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f21 = matrix1.get(2, 1); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + final float s30 = matrix2.get(3, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s21 = matrix2.get(2, 1); + final float s31 = matrix2.get(3, 1); + final float s02 = matrix2.get(0, 2); + final float s12 = matrix2.get(1, 2); + final float s22 = matrix2.get(2, 2); + final float s32 = matrix2.get(3, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32); return output; } private static IMatrixSetterFloat multiplyMatrix2x3x5(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final float f_c00 = matrix1.get(0, 0); - final float f_c10 = matrix1.get(1, 0); - final float f_c20 = matrix1.get(2, 0); - final float f_c01 = matrix1.get(0, 1); - final float f_c11 = matrix1.get(1, 1); - final float f_c21 = matrix1.get(2, 1); - final float s_c00 = matrix2.get(0, 0); - final float s_c10 = matrix2.get(1, 0); - final float s_c20 = matrix2.get(2, 0); - final float s_c30 = matrix2.get(3, 0); - final float s_c40 = matrix2.get(4, 0); - final float s_c01 = matrix2.get(0, 1); - final float s_c11 = matrix2.get(1, 1); - final float s_c21 = matrix2.get(2, 1); - final float s_c31 = matrix2.get(3, 1); - final float s_c41 = matrix2.get(4, 1); - final float s_c02 = matrix2.get(0, 2); - final float s_c12 = matrix2.get(1, 2); - final float s_c22 = matrix2.get(2, 2); - final float s_c32 = matrix2.get(3, 2); - final float s_c42 = matrix2.get(4, 2); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32); - output.set(4, 0, f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42); - output.set(4, 1, f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f21 = matrix1.get(2, 1); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + final float s30 = matrix2.get(3, 0); + final float s40 = matrix2.get(4, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s21 = matrix2.get(2, 1); + final float s31 = matrix2.get(3, 1); + final float s41 = matrix2.get(4, 1); + final float s02 = matrix2.get(0, 2); + final float s12 = matrix2.get(1, 2); + final float s22 = matrix2.get(2, 2); + final float s32 = matrix2.get(3, 2); + final float s42 = matrix2.get(4, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32); + output.set(4, 0, f00 * s40 + f10 * s41 + f20 * s42); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32); + output.set(4, 1, f01 * s40 + f11 * s41 + f21 * s42); + return output; + } + + private static IMatrixSetterFloat multiplyMatrix3x3x1(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f21 = matrix1.get(2, 1); + final float f02 = matrix1.get(0, 2); + final float f12 = matrix1.get(1, 2); + final float f22 = matrix1.get(2, 2); + final float s00 = matrix2.get(0, 0); + final float s01 = matrix2.get(0, 1); + final float s02 = matrix2.get(0, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02); return output; } private static IMatrixSetterFloat multiplyMatrix3x3x2(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final float f_c00 = matrix1.get(0, 0); - final float f_c10 = matrix1.get(1, 0); - final float f_c20 = matrix1.get(2, 0); - final float f_c01 = matrix1.get(0, 1); - final float f_c11 = matrix1.get(1, 1); - final float f_c21 = matrix1.get(2, 1); - final float f_c02 = matrix1.get(0, 2); - final float f_c12 = matrix1.get(1, 2); - final float f_c22 = matrix1.get(2, 2); - final float s_c00 = matrix2.get(0, 0); - final float s_c10 = matrix2.get(1, 0); - final float s_c01 = matrix2.get(0, 1); - final float s_c11 = matrix2.get(1, 1); - final float s_c02 = matrix2.get(0, 2); - final float s_c12 = matrix2.get(1, 2); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f21 = matrix1.get(2, 1); + final float f02 = matrix1.get(0, 2); + final float f12 = matrix1.get(1, 2); + final float f22 = matrix1.get(2, 2); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s02 = matrix2.get(0, 2); + final float s12 = matrix2.get(1, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12); return output; } private static IMatrixSetterFloat multiplyMatrix3x3x3(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final float f_c00 = matrix1.get(0, 0); - final float f_c10 = matrix1.get(1, 0); - final float f_c20 = matrix1.get(2, 0); - final float f_c01 = matrix1.get(0, 1); - final float f_c11 = matrix1.get(1, 1); - final float f_c21 = matrix1.get(2, 1); - final float f_c02 = matrix1.get(0, 2); - final float f_c12 = matrix1.get(1, 2); - final float f_c22 = matrix1.get(2, 2); - final float s_c00 = matrix2.get(0, 0); - final float s_c10 = matrix2.get(1, 0); - final float s_c20 = matrix2.get(2, 0); - final float s_c01 = matrix2.get(0, 1); - final float s_c11 = matrix2.get(1, 1); - final float s_c21 = matrix2.get(2, 1); - final float s_c02 = matrix2.get(0, 2); - final float s_c12 = matrix2.get(1, 2); - final float s_c22 = matrix2.get(2, 2); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f21 = matrix1.get(2, 1); + final float f02 = matrix1.get(0, 2); + final float f12 = matrix1.get(1, 2); + final float f22 = matrix1.get(2, 2); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s21 = matrix2.get(2, 1); + final float s02 = matrix2.get(0, 2); + final float s12 = matrix2.get(1, 2); + final float s22 = matrix2.get(2, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22); return output; } private static IMatrixSetterFloat multiplyMatrix3x3x4(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final float f_c00 = matrix1.get(0, 0); - final float f_c10 = matrix1.get(1, 0); - final float f_c20 = matrix1.get(2, 0); - final float f_c01 = matrix1.get(0, 1); - final float f_c11 = matrix1.get(1, 1); - final float f_c21 = matrix1.get(2, 1); - final float f_c02 = matrix1.get(0, 2); - final float f_c12 = matrix1.get(1, 2); - final float f_c22 = matrix1.get(2, 2); - final float s_c00 = matrix2.get(0, 0); - final float s_c10 = matrix2.get(1, 0); - final float s_c20 = matrix2.get(2, 0); - final float s_c30 = matrix2.get(3, 0); - final float s_c01 = matrix2.get(0, 1); - final float s_c11 = matrix2.get(1, 1); - final float s_c21 = matrix2.get(2, 1); - final float s_c31 = matrix2.get(3, 1); - final float s_c02 = matrix2.get(0, 2); - final float s_c12 = matrix2.get(1, 2); - final float s_c22 = matrix2.get(2, 2); - final float s_c32 = matrix2.get(3, 2); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f21 = matrix1.get(2, 1); + final float f02 = matrix1.get(0, 2); + final float f12 = matrix1.get(1, 2); + final float f22 = matrix1.get(2, 2); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + final float s30 = matrix2.get(3, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s21 = matrix2.get(2, 1); + final float s31 = matrix2.get(3, 1); + final float s02 = matrix2.get(0, 2); + final float s12 = matrix2.get(1, 2); + final float s22 = matrix2.get(2, 2); + final float s32 = matrix2.get(3, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32); return output; } private static IMatrixSetterFloat multiplyMatrix3x3x5(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final float f_c00 = matrix1.get(0, 0); - final float f_c10 = matrix1.get(1, 0); - final float f_c20 = matrix1.get(2, 0); - final float f_c01 = matrix1.get(0, 1); - final float f_c11 = matrix1.get(1, 1); - final float f_c21 = matrix1.get(2, 1); - final float f_c02 = matrix1.get(0, 2); - final float f_c12 = matrix1.get(1, 2); - final float f_c22 = matrix1.get(2, 2); - final float s_c00 = matrix2.get(0, 0); - final float s_c10 = matrix2.get(1, 0); - final float s_c20 = matrix2.get(2, 0); - final float s_c30 = matrix2.get(3, 0); - final float s_c40 = matrix2.get(4, 0); - final float s_c01 = matrix2.get(0, 1); - final float s_c11 = matrix2.get(1, 1); - final float s_c21 = matrix2.get(2, 1); - final float s_c31 = matrix2.get(3, 1); - final float s_c41 = matrix2.get(4, 1); - final float s_c02 = matrix2.get(0, 2); - final float s_c12 = matrix2.get(1, 2); - final float s_c22 = matrix2.get(2, 2); - final float s_c32 = matrix2.get(3, 2); - final float s_c42 = matrix2.get(4, 2); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32); - output.set(4, 0, f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42); - output.set(4, 1, f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42); - output.set(4, 2, f_c02*s_c40 + f_c12*s_c41 + f_c22*s_c42); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f21 = matrix1.get(2, 1); + final float f02 = matrix1.get(0, 2); + final float f12 = matrix1.get(1, 2); + final float f22 = matrix1.get(2, 2); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + final float s30 = matrix2.get(3, 0); + final float s40 = matrix2.get(4, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s21 = matrix2.get(2, 1); + final float s31 = matrix2.get(3, 1); + final float s41 = matrix2.get(4, 1); + final float s02 = matrix2.get(0, 2); + final float s12 = matrix2.get(1, 2); + final float s22 = matrix2.get(2, 2); + final float s32 = matrix2.get(3, 2); + final float s42 = matrix2.get(4, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32); + output.set(4, 0, f00 * s40 + f10 * s41 + f20 * s42); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32); + output.set(4, 1, f01 * s40 + f11 * s41 + f21 * s42); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32); + output.set(4, 2, f02 * s40 + f12 * s41 + f22 * s42); + return output; + } + + private static IMatrixSetterFloat multiplyMatrix4x3x1(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f21 = matrix1.get(2, 1); + final float f02 = matrix1.get(0, 2); + final float f12 = matrix1.get(1, 2); + final float f22 = matrix1.get(2, 2); + final float f03 = matrix1.get(0, 3); + final float f13 = matrix1.get(1, 3); + final float f23 = matrix1.get(2, 3); + final float s00 = matrix2.get(0, 0); + final float s01 = matrix2.get(0, 1); + final float s02 = matrix2.get(0, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02); return output; } private static IMatrixSetterFloat multiplyMatrix4x3x2(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final float f_c00 = matrix1.get(0, 0); - final float f_c10 = matrix1.get(1, 0); - final float f_c20 = matrix1.get(2, 0); - final float f_c01 = matrix1.get(0, 1); - final float f_c11 = matrix1.get(1, 1); - final float f_c21 = matrix1.get(2, 1); - final float f_c02 = matrix1.get(0, 2); - final float f_c12 = matrix1.get(1, 2); - final float f_c22 = matrix1.get(2, 2); - final float f_c03 = matrix1.get(0, 3); - final float f_c13 = matrix1.get(1, 3); - final float f_c23 = matrix1.get(2, 3); - final float s_c00 = matrix2.get(0, 0); - final float s_c10 = matrix2.get(1, 0); - final float s_c01 = matrix2.get(0, 1); - final float s_c11 = matrix2.get(1, 1); - final float s_c02 = matrix2.get(0, 2); - final float s_c12 = matrix2.get(1, 2); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f21 = matrix1.get(2, 1); + final float f02 = matrix1.get(0, 2); + final float f12 = matrix1.get(1, 2); + final float f22 = matrix1.get(2, 2); + final float f03 = matrix1.get(0, 3); + final float f13 = matrix1.get(1, 3); + final float f23 = matrix1.get(2, 3); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s02 = matrix2.get(0, 2); + final float s12 = matrix2.get(1, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12); return output; } private static IMatrixSetterFloat multiplyMatrix4x3x3(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final float f_c00 = matrix1.get(0, 0); - final float f_c10 = matrix1.get(1, 0); - final float f_c20 = matrix1.get(2, 0); - final float f_c01 = matrix1.get(0, 1); - final float f_c11 = matrix1.get(1, 1); - final float f_c21 = matrix1.get(2, 1); - final float f_c02 = matrix1.get(0, 2); - final float f_c12 = matrix1.get(1, 2); - final float f_c22 = matrix1.get(2, 2); - final float f_c03 = matrix1.get(0, 3); - final float f_c13 = matrix1.get(1, 3); - final float f_c23 = matrix1.get(2, 3); - final float s_c00 = matrix2.get(0, 0); - final float s_c10 = matrix2.get(1, 0); - final float s_c20 = matrix2.get(2, 0); - final float s_c01 = matrix2.get(0, 1); - final float s_c11 = matrix2.get(1, 1); - final float s_c21 = matrix2.get(2, 1); - final float s_c02 = matrix2.get(0, 2); - final float s_c12 = matrix2.get(1, 2); - final float s_c22 = matrix2.get(2, 2); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f21 = matrix1.get(2, 1); + final float f02 = matrix1.get(0, 2); + final float f12 = matrix1.get(1, 2); + final float f22 = matrix1.get(2, 2); + final float f03 = matrix1.get(0, 3); + final float f13 = matrix1.get(1, 3); + final float f23 = matrix1.get(2, 3); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s21 = matrix2.get(2, 1); + final float s02 = matrix2.get(0, 2); + final float s12 = matrix2.get(1, 2); + final float s22 = matrix2.get(2, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22); return output; } private static IMatrixSetterFloat multiplyMatrix4x3x4(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final float f_c00 = matrix1.get(0, 0); - final float f_c10 = matrix1.get(1, 0); - final float f_c20 = matrix1.get(2, 0); - final float f_c01 = matrix1.get(0, 1); - final float f_c11 = matrix1.get(1, 1); - final float f_c21 = matrix1.get(2, 1); - final float f_c02 = matrix1.get(0, 2); - final float f_c12 = matrix1.get(1, 2); - final float f_c22 = matrix1.get(2, 2); - final float f_c03 = matrix1.get(0, 3); - final float f_c13 = matrix1.get(1, 3); - final float f_c23 = matrix1.get(2, 3); - final float s_c00 = matrix2.get(0, 0); - final float s_c10 = matrix2.get(1, 0); - final float s_c20 = matrix2.get(2, 0); - final float s_c30 = matrix2.get(3, 0); - final float s_c01 = matrix2.get(0, 1); - final float s_c11 = matrix2.get(1, 1); - final float s_c21 = matrix2.get(2, 1); - final float s_c31 = matrix2.get(3, 1); - final float s_c02 = matrix2.get(0, 2); - final float s_c12 = matrix2.get(1, 2); - final float s_c22 = matrix2.get(2, 2); - final float s_c32 = matrix2.get(3, 2); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32); - output.set(3, 3, f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f21 = matrix1.get(2, 1); + final float f02 = matrix1.get(0, 2); + final float f12 = matrix1.get(1, 2); + final float f22 = matrix1.get(2, 2); + final float f03 = matrix1.get(0, 3); + final float f13 = matrix1.get(1, 3); + final float f23 = matrix1.get(2, 3); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + final float s30 = matrix2.get(3, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s21 = matrix2.get(2, 1); + final float s31 = matrix2.get(3, 1); + final float s02 = matrix2.get(0, 2); + final float s12 = matrix2.get(1, 2); + final float s22 = matrix2.get(2, 2); + final float s32 = matrix2.get(3, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22); + output.set(3, 3, f03 * s30 + f13 * s31 + f23 * s32); return output; } private static IMatrixSetterFloat multiplyMatrix4x3x5(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final float f_c00 = matrix1.get(0, 0); - final float f_c10 = matrix1.get(1, 0); - final float f_c20 = matrix1.get(2, 0); - final float f_c01 = matrix1.get(0, 1); - final float f_c11 = matrix1.get(1, 1); - final float f_c21 = matrix1.get(2, 1); - final float f_c02 = matrix1.get(0, 2); - final float f_c12 = matrix1.get(1, 2); - final float f_c22 = matrix1.get(2, 2); - final float f_c03 = matrix1.get(0, 3); - final float f_c13 = matrix1.get(1, 3); - final float f_c23 = matrix1.get(2, 3); - final float s_c00 = matrix2.get(0, 0); - final float s_c10 = matrix2.get(1, 0); - final float s_c20 = matrix2.get(2, 0); - final float s_c30 = matrix2.get(3, 0); - final float s_c40 = matrix2.get(4, 0); - final float s_c01 = matrix2.get(0, 1); - final float s_c11 = matrix2.get(1, 1); - final float s_c21 = matrix2.get(2, 1); - final float s_c31 = matrix2.get(3, 1); - final float s_c41 = matrix2.get(4, 1); - final float s_c02 = matrix2.get(0, 2); - final float s_c12 = matrix2.get(1, 2); - final float s_c22 = matrix2.get(2, 2); - final float s_c32 = matrix2.get(3, 2); - final float s_c42 = matrix2.get(4, 2); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32); - output.set(3, 3, f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32); - output.set(4, 0, f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42); - output.set(4, 1, f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42); - output.set(4, 2, f_c02*s_c40 + f_c12*s_c41 + f_c22*s_c42); - output.set(4, 3, f_c03*s_c40 + f_c13*s_c41 + f_c23*s_c42); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f21 = matrix1.get(2, 1); + final float f02 = matrix1.get(0, 2); + final float f12 = matrix1.get(1, 2); + final float f22 = matrix1.get(2, 2); + final float f03 = matrix1.get(0, 3); + final float f13 = matrix1.get(1, 3); + final float f23 = matrix1.get(2, 3); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + final float s30 = matrix2.get(3, 0); + final float s40 = matrix2.get(4, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s21 = matrix2.get(2, 1); + final float s31 = matrix2.get(3, 1); + final float s41 = matrix2.get(4, 1); + final float s02 = matrix2.get(0, 2); + final float s12 = matrix2.get(1, 2); + final float s22 = matrix2.get(2, 2); + final float s32 = matrix2.get(3, 2); + final float s42 = matrix2.get(4, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32); + output.set(4, 0, f00 * s40 + f10 * s41 + f20 * s42); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32); + output.set(4, 1, f01 * s40 + f11 * s41 + f21 * s42); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32); + output.set(4, 2, f02 * s40 + f12 * s41 + f22 * s42); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22); + output.set(3, 3, f03 * s30 + f13 * s31 + f23 * s32); + output.set(4, 3, f03 * s40 + f13 * s41 + f23 * s42); + return output; + } + + private static IMatrixSetterFloat multiplyMatrix5x3x1(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f21 = matrix1.get(2, 1); + final float f02 = matrix1.get(0, 2); + final float f12 = matrix1.get(1, 2); + final float f22 = matrix1.get(2, 2); + final float f03 = matrix1.get(0, 3); + final float f13 = matrix1.get(1, 3); + final float f23 = matrix1.get(2, 3); + final float f04 = matrix1.get(0, 4); + final float f14 = matrix1.get(1, 4); + final float f24 = matrix1.get(2, 4); + final float s00 = matrix2.get(0, 0); + final float s01 = matrix2.get(0, 1); + final float s02 = matrix2.get(0, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02); + output.set(0, 4, f04 * s00 + f14 * s01 + f24 * s02); return output; } private static IMatrixSetterFloat multiplyMatrix5x3x2(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final float f_c00 = matrix1.get(0, 0); - final float f_c10 = matrix1.get(1, 0); - final float f_c20 = matrix1.get(2, 0); - final float f_c01 = matrix1.get(0, 1); - final float f_c11 = matrix1.get(1, 1); - final float f_c21 = matrix1.get(2, 1); - final float f_c02 = matrix1.get(0, 2); - final float f_c12 = matrix1.get(1, 2); - final float f_c22 = matrix1.get(2, 2); - final float f_c03 = matrix1.get(0, 3); - final float f_c13 = matrix1.get(1, 3); - final float f_c23 = matrix1.get(2, 3); - final float f_c04 = matrix1.get(0, 4); - final float f_c14 = matrix1.get(1, 4); - final float f_c24 = matrix1.get(2, 4); - final float s_c00 = matrix2.get(0, 0); - final float s_c10 = matrix2.get(1, 0); - final float s_c01 = matrix2.get(0, 1); - final float s_c11 = matrix2.get(1, 1); - final float s_c02 = matrix2.get(0, 2); - final float s_c12 = matrix2.get(1, 2); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02); - output.set(0, 4, f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12); - output.set(1, 4, f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f21 = matrix1.get(2, 1); + final float f02 = matrix1.get(0, 2); + final float f12 = matrix1.get(1, 2); + final float f22 = matrix1.get(2, 2); + final float f03 = matrix1.get(0, 3); + final float f13 = matrix1.get(1, 3); + final float f23 = matrix1.get(2, 3); + final float f04 = matrix1.get(0, 4); + final float f14 = matrix1.get(1, 4); + final float f24 = matrix1.get(2, 4); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s02 = matrix2.get(0, 2); + final float s12 = matrix2.get(1, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12); + output.set(0, 4, f04 * s00 + f14 * s01 + f24 * s02); + output.set(1, 4, f04 * s10 + f14 * s11 + f24 * s12); return output; } private static IMatrixSetterFloat multiplyMatrix5x3x3(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final float f_c00 = matrix1.get(0, 0); - final float f_c10 = matrix1.get(1, 0); - final float f_c20 = matrix1.get(2, 0); - final float f_c01 = matrix1.get(0, 1); - final float f_c11 = matrix1.get(1, 1); - final float f_c21 = matrix1.get(2, 1); - final float f_c02 = matrix1.get(0, 2); - final float f_c12 = matrix1.get(1, 2); - final float f_c22 = matrix1.get(2, 2); - final float f_c03 = matrix1.get(0, 3); - final float f_c13 = matrix1.get(1, 3); - final float f_c23 = matrix1.get(2, 3); - final float f_c04 = matrix1.get(0, 4); - final float f_c14 = matrix1.get(1, 4); - final float f_c24 = matrix1.get(2, 4); - final float s_c00 = matrix2.get(0, 0); - final float s_c10 = matrix2.get(1, 0); - final float s_c20 = matrix2.get(2, 0); - final float s_c01 = matrix2.get(0, 1); - final float s_c11 = matrix2.get(1, 1); - final float s_c21 = matrix2.get(2, 1); - final float s_c02 = matrix2.get(0, 2); - final float s_c12 = matrix2.get(1, 2); - final float s_c22 = matrix2.get(2, 2); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02); - output.set(0, 4, f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12); - output.set(1, 4, f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22); - output.set(2, 4, f_c04*s_c20 + f_c14*s_c21 + f_c24*s_c22); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f21 = matrix1.get(2, 1); + final float f02 = matrix1.get(0, 2); + final float f12 = matrix1.get(1, 2); + final float f22 = matrix1.get(2, 2); + final float f03 = matrix1.get(0, 3); + final float f13 = matrix1.get(1, 3); + final float f23 = matrix1.get(2, 3); + final float f04 = matrix1.get(0, 4); + final float f14 = matrix1.get(1, 4); + final float f24 = matrix1.get(2, 4); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s21 = matrix2.get(2, 1); + final float s02 = matrix2.get(0, 2); + final float s12 = matrix2.get(1, 2); + final float s22 = matrix2.get(2, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22); + output.set(0, 4, f04 * s00 + f14 * s01 + f24 * s02); + output.set(1, 4, f04 * s10 + f14 * s11 + f24 * s12); + output.set(2, 4, f04 * s20 + f14 * s21 + f24 * s22); return output; } private static IMatrixSetterFloat multiplyMatrix5x3x4(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final float f_c00 = matrix1.get(0, 0); - final float f_c10 = matrix1.get(1, 0); - final float f_c20 = matrix1.get(2, 0); - final float f_c01 = matrix1.get(0, 1); - final float f_c11 = matrix1.get(1, 1); - final float f_c21 = matrix1.get(2, 1); - final float f_c02 = matrix1.get(0, 2); - final float f_c12 = matrix1.get(1, 2); - final float f_c22 = matrix1.get(2, 2); - final float f_c03 = matrix1.get(0, 3); - final float f_c13 = matrix1.get(1, 3); - final float f_c23 = matrix1.get(2, 3); - final float f_c04 = matrix1.get(0, 4); - final float f_c14 = matrix1.get(1, 4); - final float f_c24 = matrix1.get(2, 4); - final float s_c00 = matrix2.get(0, 0); - final float s_c10 = matrix2.get(1, 0); - final float s_c20 = matrix2.get(2, 0); - final float s_c30 = matrix2.get(3, 0); - final float s_c01 = matrix2.get(0, 1); - final float s_c11 = matrix2.get(1, 1); - final float s_c21 = matrix2.get(2, 1); - final float s_c31 = matrix2.get(3, 1); - final float s_c02 = matrix2.get(0, 2); - final float s_c12 = matrix2.get(1, 2); - final float s_c22 = matrix2.get(2, 2); - final float s_c32 = matrix2.get(3, 2); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02); - output.set(0, 4, f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12); - output.set(1, 4, f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22); - output.set(2, 4, f_c04*s_c20 + f_c14*s_c21 + f_c24*s_c22); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32); - output.set(3, 3, f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32); - output.set(3, 4, f_c04*s_c30 + f_c14*s_c31 + f_c24*s_c32); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f21 = matrix1.get(2, 1); + final float f02 = matrix1.get(0, 2); + final float f12 = matrix1.get(1, 2); + final float f22 = matrix1.get(2, 2); + final float f03 = matrix1.get(0, 3); + final float f13 = matrix1.get(1, 3); + final float f23 = matrix1.get(2, 3); + final float f04 = matrix1.get(0, 4); + final float f14 = matrix1.get(1, 4); + final float f24 = matrix1.get(2, 4); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + final float s30 = matrix2.get(3, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s21 = matrix2.get(2, 1); + final float s31 = matrix2.get(3, 1); + final float s02 = matrix2.get(0, 2); + final float s12 = matrix2.get(1, 2); + final float s22 = matrix2.get(2, 2); + final float s32 = matrix2.get(3, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22); + output.set(3, 3, f03 * s30 + f13 * s31 + f23 * s32); + output.set(0, 4, f04 * s00 + f14 * s01 + f24 * s02); + output.set(1, 4, f04 * s10 + f14 * s11 + f24 * s12); + output.set(2, 4, f04 * s20 + f14 * s21 + f24 * s22); + output.set(3, 4, f04 * s30 + f14 * s31 + f24 * s32); return output; } private static IMatrixSetterFloat multiplyMatrix5x3x5(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final float f_c00 = matrix1.get(0, 0); - final float f_c10 = matrix1.get(1, 0); - final float f_c20 = matrix1.get(2, 0); - final float f_c01 = matrix1.get(0, 1); - final float f_c11 = matrix1.get(1, 1); - final float f_c21 = matrix1.get(2, 1); - final float f_c02 = matrix1.get(0, 2); - final float f_c12 = matrix1.get(1, 2); - final float f_c22 = matrix1.get(2, 2); - final float f_c03 = matrix1.get(0, 3); - final float f_c13 = matrix1.get(1, 3); - final float f_c23 = matrix1.get(2, 3); - final float f_c04 = matrix1.get(0, 4); - final float f_c14 = matrix1.get(1, 4); - final float f_c24 = matrix1.get(2, 4); - final float s_c00 = matrix2.get(0, 0); - final float s_c10 = matrix2.get(1, 0); - final float s_c20 = matrix2.get(2, 0); - final float s_c30 = matrix2.get(3, 0); - final float s_c40 = matrix2.get(4, 0); - final float s_c01 = matrix2.get(0, 1); - final float s_c11 = matrix2.get(1, 1); - final float s_c21 = matrix2.get(2, 1); - final float s_c31 = matrix2.get(3, 1); - final float s_c41 = matrix2.get(4, 1); - final float s_c02 = matrix2.get(0, 2); - final float s_c12 = matrix2.get(1, 2); - final float s_c22 = matrix2.get(2, 2); - final float s_c32 = matrix2.get(3, 2); - final float s_c42 = matrix2.get(4, 2); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02); - output.set(0, 4, f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12); - output.set(1, 4, f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22); - output.set(2, 4, f_c04*s_c20 + f_c14*s_c21 + f_c24*s_c22); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32); - output.set(3, 3, f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32); - output.set(3, 4, f_c04*s_c30 + f_c14*s_c31 + f_c24*s_c32); - output.set(4, 0, f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42); - output.set(4, 1, f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42); - output.set(4, 2, f_c02*s_c40 + f_c12*s_c41 + f_c22*s_c42); - output.set(4, 3, f_c03*s_c40 + f_c13*s_c41 + f_c23*s_c42); - output.set(4, 4, f_c04*s_c40 + f_c14*s_c41 + f_c24*s_c42); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f21 = matrix1.get(2, 1); + final float f02 = matrix1.get(0, 2); + final float f12 = matrix1.get(1, 2); + final float f22 = matrix1.get(2, 2); + final float f03 = matrix1.get(0, 3); + final float f13 = matrix1.get(1, 3); + final float f23 = matrix1.get(2, 3); + final float f04 = matrix1.get(0, 4); + final float f14 = matrix1.get(1, 4); + final float f24 = matrix1.get(2, 4); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + final float s30 = matrix2.get(3, 0); + final float s40 = matrix2.get(4, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s21 = matrix2.get(2, 1); + final float s31 = matrix2.get(3, 1); + final float s41 = matrix2.get(4, 1); + final float s02 = matrix2.get(0, 2); + final float s12 = matrix2.get(1, 2); + final float s22 = matrix2.get(2, 2); + final float s32 = matrix2.get(3, 2); + final float s42 = matrix2.get(4, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32); + output.set(4, 0, f00 * s40 + f10 * s41 + f20 * s42); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32); + output.set(4, 1, f01 * s40 + f11 * s41 + f21 * s42); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32); + output.set(4, 2, f02 * s40 + f12 * s41 + f22 * s42); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22); + output.set(3, 3, f03 * s30 + f13 * s31 + f23 * s32); + output.set(4, 3, f03 * s40 + f13 * s41 + f23 * s42); + output.set(0, 4, f04 * s00 + f14 * s01 + f24 * s02); + output.set(1, 4, f04 * s10 + f14 * s11 + f24 * s12); + output.set(2, 4, f04 * s20 + f14 * s21 + f24 * s22); + output.set(3, 4, f04 * s30 + f14 * s31 + f24 * s32); + output.set(4, 4, f04 * s40 + f14 * s41 + f24 * s42); + return output; + } + + private static IMatrixSetterFloat multiplyMatrix1x4x1(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float f30 = matrix1.get(3, 0); + final float s00 = matrix2.get(0, 0); + final float s01 = matrix2.get(0, 1); + final float s02 = matrix2.get(0, 2); + final float s03 = matrix2.get(0, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + return output; + } + + private static IMatrixSetterFloat multiplyMatrix1x4x2(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float f30 = matrix1.get(3, 0); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s02 = matrix2.get(0, 2); + final float s12 = matrix2.get(1, 2); + final float s03 = matrix2.get(0, 3); + final float s13 = matrix2.get(1, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + return output; + } + + private static IMatrixSetterFloat multiplyMatrix1x4x3(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float f30 = matrix1.get(3, 0); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s21 = matrix2.get(2, 1); + final float s02 = matrix2.get(0, 2); + final float s12 = matrix2.get(1, 2); + final float s22 = matrix2.get(2, 2); + final float s03 = matrix2.get(0, 3); + final float s13 = matrix2.get(1, 3); + final float s23 = matrix2.get(2, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23); + return output; + } + + private static IMatrixSetterFloat multiplyMatrix1x4x4(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float f30 = matrix1.get(3, 0); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + final float s30 = matrix2.get(3, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s21 = matrix2.get(2, 1); + final float s31 = matrix2.get(3, 1); + final float s02 = matrix2.get(0, 2); + final float s12 = matrix2.get(1, 2); + final float s22 = matrix2.get(2, 2); + final float s32 = matrix2.get(3, 2); + final float s03 = matrix2.get(0, 3); + final float s13 = matrix2.get(1, 3); + final float s23 = matrix2.get(2, 3); + final float s33 = matrix2.get(3, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33); + return output; + } + + private static IMatrixSetterFloat multiplyMatrix1x4x5(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float f30 = matrix1.get(3, 0); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + final float s30 = matrix2.get(3, 0); + final float s40 = matrix2.get(4, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s21 = matrix2.get(2, 1); + final float s31 = matrix2.get(3, 1); + final float s41 = matrix2.get(4, 1); + final float s02 = matrix2.get(0, 2); + final float s12 = matrix2.get(1, 2); + final float s22 = matrix2.get(2, 2); + final float s32 = matrix2.get(3, 2); + final float s42 = matrix2.get(4, 2); + final float s03 = matrix2.get(0, 3); + final float s13 = matrix2.get(1, 3); + final float s23 = matrix2.get(2, 3); + final float s33 = matrix2.get(3, 3); + final float s43 = matrix2.get(4, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33); + output.set(4, 0, f00 * s40 + f10 * s41 + f20 * s42 + f30 * s43); + return output; + } + + private static IMatrixSetterFloat multiplyMatrix2x4x1(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float f30 = matrix1.get(3, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f21 = matrix1.get(2, 1); + final float f31 = matrix1.get(3, 1); + final float s00 = matrix2.get(0, 0); + final float s01 = matrix2.get(0, 1); + final float s02 = matrix2.get(0, 2); + final float s03 = matrix2.get(0, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); return output; } private static IMatrixSetterFloat multiplyMatrix2x4x2(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final float f_c00 = matrix1.get(0, 0); - final float f_c10 = matrix1.get(1, 0); - final float f_c20 = matrix1.get(2, 0); - final float f_c30 = matrix1.get(3, 0); - final float f_c01 = matrix1.get(0, 1); - final float f_c11 = matrix1.get(1, 1); - final float f_c21 = matrix1.get(2, 1); - final float f_c31 = matrix1.get(3, 1); - final float s_c00 = matrix2.get(0, 0); - final float s_c10 = matrix2.get(1, 0); - final float s_c01 = matrix2.get(0, 1); - final float s_c11 = matrix2.get(1, 1); - final float s_c02 = matrix2.get(0, 2); - final float s_c12 = matrix2.get(1, 2); - final float s_c03 = matrix2.get(0, 3); - final float s_c13 = matrix2.get(1, 3); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float f30 = matrix1.get(3, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f21 = matrix1.get(2, 1); + final float f31 = matrix1.get(3, 1); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s02 = matrix2.get(0, 2); + final float s12 = matrix2.get(1, 2); + final float s03 = matrix2.get(0, 3); + final float s13 = matrix2.get(1, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13); return output; } private static IMatrixSetterFloat multiplyMatrix2x4x3(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final float f_c00 = matrix1.get(0, 0); - final float f_c10 = matrix1.get(1, 0); - final float f_c20 = matrix1.get(2, 0); - final float f_c30 = matrix1.get(3, 0); - final float f_c01 = matrix1.get(0, 1); - final float f_c11 = matrix1.get(1, 1); - final float f_c21 = matrix1.get(2, 1); - final float f_c31 = matrix1.get(3, 1); - final float s_c00 = matrix2.get(0, 0); - final float s_c10 = matrix2.get(1, 0); - final float s_c20 = matrix2.get(2, 0); - final float s_c01 = matrix2.get(0, 1); - final float s_c11 = matrix2.get(1, 1); - final float s_c21 = matrix2.get(2, 1); - final float s_c02 = matrix2.get(0, 2); - final float s_c12 = matrix2.get(1, 2); - final float s_c22 = matrix2.get(2, 2); - final float s_c03 = matrix2.get(0, 3); - final float s_c13 = matrix2.get(1, 3); - final float s_c23 = matrix2.get(2, 3); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float f30 = matrix1.get(3, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f21 = matrix1.get(2, 1); + final float f31 = matrix1.get(3, 1); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s21 = matrix2.get(2, 1); + final float s02 = matrix2.get(0, 2); + final float s12 = matrix2.get(1, 2); + final float s22 = matrix2.get(2, 2); + final float s03 = matrix2.get(0, 3); + final float s13 = matrix2.get(1, 3); + final float s23 = matrix2.get(2, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23); return output; } private static IMatrixSetterFloat multiplyMatrix2x4x4(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final float f_c00 = matrix1.get(0, 0); - final float f_c10 = matrix1.get(1, 0); - final float f_c20 = matrix1.get(2, 0); - final float f_c30 = matrix1.get(3, 0); - final float f_c01 = matrix1.get(0, 1); - final float f_c11 = matrix1.get(1, 1); - final float f_c21 = matrix1.get(2, 1); - final float f_c31 = matrix1.get(3, 1); - final float s_c00 = matrix2.get(0, 0); - final float s_c10 = matrix2.get(1, 0); - final float s_c20 = matrix2.get(2, 0); - final float s_c30 = matrix2.get(3, 0); - final float s_c01 = matrix2.get(0, 1); - final float s_c11 = matrix2.get(1, 1); - final float s_c21 = matrix2.get(2, 1); - final float s_c31 = matrix2.get(3, 1); - final float s_c02 = matrix2.get(0, 2); - final float s_c12 = matrix2.get(1, 2); - final float s_c22 = matrix2.get(2, 2); - final float s_c32 = matrix2.get(3, 2); - final float s_c03 = matrix2.get(0, 3); - final float s_c13 = matrix2.get(1, 3); - final float s_c23 = matrix2.get(2, 3); - final float s_c33 = matrix2.get(3, 3); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float f30 = matrix1.get(3, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f21 = matrix1.get(2, 1); + final float f31 = matrix1.get(3, 1); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + final float s30 = matrix2.get(3, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s21 = matrix2.get(2, 1); + final float s31 = matrix2.get(3, 1); + final float s02 = matrix2.get(0, 2); + final float s12 = matrix2.get(1, 2); + final float s22 = matrix2.get(2, 2); + final float s32 = matrix2.get(3, 2); + final float s03 = matrix2.get(0, 3); + final float s13 = matrix2.get(1, 3); + final float s23 = matrix2.get(2, 3); + final float s33 = matrix2.get(3, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33); return output; } private static IMatrixSetterFloat multiplyMatrix2x4x5(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final float f_c00 = matrix1.get(0, 0); - final float f_c10 = matrix1.get(1, 0); - final float f_c20 = matrix1.get(2, 0); - final float f_c30 = matrix1.get(3, 0); - final float f_c01 = matrix1.get(0, 1); - final float f_c11 = matrix1.get(1, 1); - final float f_c21 = matrix1.get(2, 1); - final float f_c31 = matrix1.get(3, 1); - final float s_c00 = matrix2.get(0, 0); - final float s_c10 = matrix2.get(1, 0); - final float s_c20 = matrix2.get(2, 0); - final float s_c30 = matrix2.get(3, 0); - final float s_c40 = matrix2.get(4, 0); - final float s_c01 = matrix2.get(0, 1); - final float s_c11 = matrix2.get(1, 1); - final float s_c21 = matrix2.get(2, 1); - final float s_c31 = matrix2.get(3, 1); - final float s_c41 = matrix2.get(4, 1); - final float s_c02 = matrix2.get(0, 2); - final float s_c12 = matrix2.get(1, 2); - final float s_c22 = matrix2.get(2, 2); - final float s_c32 = matrix2.get(3, 2); - final float s_c42 = matrix2.get(4, 2); - final float s_c03 = matrix2.get(0, 3); - final float s_c13 = matrix2.get(1, 3); - final float s_c23 = matrix2.get(2, 3); - final float s_c33 = matrix2.get(3, 3); - final float s_c43 = matrix2.get(4, 3); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33); - output.set(4, 0, f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42 + f_c30*s_c43); - output.set(4, 1, f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42 + f_c31*s_c43); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float f30 = matrix1.get(3, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f21 = matrix1.get(2, 1); + final float f31 = matrix1.get(3, 1); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + final float s30 = matrix2.get(3, 0); + final float s40 = matrix2.get(4, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s21 = matrix2.get(2, 1); + final float s31 = matrix2.get(3, 1); + final float s41 = matrix2.get(4, 1); + final float s02 = matrix2.get(0, 2); + final float s12 = matrix2.get(1, 2); + final float s22 = matrix2.get(2, 2); + final float s32 = matrix2.get(3, 2); + final float s42 = matrix2.get(4, 2); + final float s03 = matrix2.get(0, 3); + final float s13 = matrix2.get(1, 3); + final float s23 = matrix2.get(2, 3); + final float s33 = matrix2.get(3, 3); + final float s43 = matrix2.get(4, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33); + output.set(4, 0, f00 * s40 + f10 * s41 + f20 * s42 + f30 * s43); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33); + output.set(4, 1, f01 * s40 + f11 * s41 + f21 * s42 + f31 * s43); + return output; + } + + private static IMatrixSetterFloat multiplyMatrix3x4x1(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float f30 = matrix1.get(3, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f21 = matrix1.get(2, 1); + final float f31 = matrix1.get(3, 1); + final float f02 = matrix1.get(0, 2); + final float f12 = matrix1.get(1, 2); + final float f22 = matrix1.get(2, 2); + final float f32 = matrix1.get(3, 2); + final float s00 = matrix2.get(0, 0); + final float s01 = matrix2.get(0, 1); + final float s02 = matrix2.get(0, 2); + final float s03 = matrix2.get(0, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03); return output; } private static IMatrixSetterFloat multiplyMatrix3x4x2(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final float f_c00 = matrix1.get(0, 0); - final float f_c10 = matrix1.get(1, 0); - final float f_c20 = matrix1.get(2, 0); - final float f_c30 = matrix1.get(3, 0); - final float f_c01 = matrix1.get(0, 1); - final float f_c11 = matrix1.get(1, 1); - final float f_c21 = matrix1.get(2, 1); - final float f_c31 = matrix1.get(3, 1); - final float f_c02 = matrix1.get(0, 2); - final float f_c12 = matrix1.get(1, 2); - final float f_c22 = matrix1.get(2, 2); - final float f_c32 = matrix1.get(3, 2); - final float s_c00 = matrix2.get(0, 0); - final float s_c10 = matrix2.get(1, 0); - final float s_c01 = matrix2.get(0, 1); - final float s_c11 = matrix2.get(1, 1); - final float s_c02 = matrix2.get(0, 2); - final float s_c12 = matrix2.get(1, 2); - final float s_c03 = matrix2.get(0, 3); - final float s_c13 = matrix2.get(1, 3); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float f30 = matrix1.get(3, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f21 = matrix1.get(2, 1); + final float f31 = matrix1.get(3, 1); + final float f02 = matrix1.get(0, 2); + final float f12 = matrix1.get(1, 2); + final float f22 = matrix1.get(2, 2); + final float f32 = matrix1.get(3, 2); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s02 = matrix2.get(0, 2); + final float s12 = matrix2.get(1, 2); + final float s03 = matrix2.get(0, 3); + final float s13 = matrix2.get(1, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13); return output; } private static IMatrixSetterFloat multiplyMatrix3x4x3(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final float f_c00 = matrix1.get(0, 0); - final float f_c10 = matrix1.get(1, 0); - final float f_c20 = matrix1.get(2, 0); - final float f_c30 = matrix1.get(3, 0); - final float f_c01 = matrix1.get(0, 1); - final float f_c11 = matrix1.get(1, 1); - final float f_c21 = matrix1.get(2, 1); - final float f_c31 = matrix1.get(3, 1); - final float f_c02 = matrix1.get(0, 2); - final float f_c12 = matrix1.get(1, 2); - final float f_c22 = matrix1.get(2, 2); - final float f_c32 = matrix1.get(3, 2); - final float s_c00 = matrix2.get(0, 0); - final float s_c10 = matrix2.get(1, 0); - final float s_c20 = matrix2.get(2, 0); - final float s_c01 = matrix2.get(0, 1); - final float s_c11 = matrix2.get(1, 1); - final float s_c21 = matrix2.get(2, 1); - final float s_c02 = matrix2.get(0, 2); - final float s_c12 = matrix2.get(1, 2); - final float s_c22 = matrix2.get(2, 2); - final float s_c03 = matrix2.get(0, 3); - final float s_c13 = matrix2.get(1, 3); - final float s_c23 = matrix2.get(2, 3); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float f30 = matrix1.get(3, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f21 = matrix1.get(2, 1); + final float f31 = matrix1.get(3, 1); + final float f02 = matrix1.get(0, 2); + final float f12 = matrix1.get(1, 2); + final float f22 = matrix1.get(2, 2); + final float f32 = matrix1.get(3, 2); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s21 = matrix2.get(2, 1); + final float s02 = matrix2.get(0, 2); + final float s12 = matrix2.get(1, 2); + final float s22 = matrix2.get(2, 2); + final float s03 = matrix2.get(0, 3); + final float s13 = matrix2.get(1, 3); + final float s23 = matrix2.get(2, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23); return output; } private static IMatrixSetterFloat multiplyMatrix3x4x4(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final float f_c00 = matrix1.get(0, 0); - final float f_c10 = matrix1.get(1, 0); - final float f_c20 = matrix1.get(2, 0); - final float f_c30 = matrix1.get(3, 0); - final float f_c01 = matrix1.get(0, 1); - final float f_c11 = matrix1.get(1, 1); - final float f_c21 = matrix1.get(2, 1); - final float f_c31 = matrix1.get(3, 1); - final float f_c02 = matrix1.get(0, 2); - final float f_c12 = matrix1.get(1, 2); - final float f_c22 = matrix1.get(2, 2); - final float f_c32 = matrix1.get(3, 2); - final float s_c00 = matrix2.get(0, 0); - final float s_c10 = matrix2.get(1, 0); - final float s_c20 = matrix2.get(2, 0); - final float s_c30 = matrix2.get(3, 0); - final float s_c01 = matrix2.get(0, 1); - final float s_c11 = matrix2.get(1, 1); - final float s_c21 = matrix2.get(2, 1); - final float s_c31 = matrix2.get(3, 1); - final float s_c02 = matrix2.get(0, 2); - final float s_c12 = matrix2.get(1, 2); - final float s_c22 = matrix2.get(2, 2); - final float s_c32 = matrix2.get(3, 2); - final float s_c03 = matrix2.get(0, 3); - final float s_c13 = matrix2.get(1, 3); - final float s_c23 = matrix2.get(2, 3); - final float s_c33 = matrix2.get(3, 3); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float f30 = matrix1.get(3, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f21 = matrix1.get(2, 1); + final float f31 = matrix1.get(3, 1); + final float f02 = matrix1.get(0, 2); + final float f12 = matrix1.get(1, 2); + final float f22 = matrix1.get(2, 2); + final float f32 = matrix1.get(3, 2); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + final float s30 = matrix2.get(3, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s21 = matrix2.get(2, 1); + final float s31 = matrix2.get(3, 1); + final float s02 = matrix2.get(0, 2); + final float s12 = matrix2.get(1, 2); + final float s22 = matrix2.get(2, 2); + final float s32 = matrix2.get(3, 2); + final float s03 = matrix2.get(0, 3); + final float s13 = matrix2.get(1, 3); + final float s23 = matrix2.get(2, 3); + final float s33 = matrix2.get(3, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33); return output; } private static IMatrixSetterFloat multiplyMatrix3x4x5(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final float f_c00 = matrix1.get(0, 0); - final float f_c10 = matrix1.get(1, 0); - final float f_c20 = matrix1.get(2, 0); - final float f_c30 = matrix1.get(3, 0); - final float f_c01 = matrix1.get(0, 1); - final float f_c11 = matrix1.get(1, 1); - final float f_c21 = matrix1.get(2, 1); - final float f_c31 = matrix1.get(3, 1); - final float f_c02 = matrix1.get(0, 2); - final float f_c12 = matrix1.get(1, 2); - final float f_c22 = matrix1.get(2, 2); - final float f_c32 = matrix1.get(3, 2); - final float s_c00 = matrix2.get(0, 0); - final float s_c10 = matrix2.get(1, 0); - final float s_c20 = matrix2.get(2, 0); - final float s_c30 = matrix2.get(3, 0); - final float s_c40 = matrix2.get(4, 0); - final float s_c01 = matrix2.get(0, 1); - final float s_c11 = matrix2.get(1, 1); - final float s_c21 = matrix2.get(2, 1); - final float s_c31 = matrix2.get(3, 1); - final float s_c41 = matrix2.get(4, 1); - final float s_c02 = matrix2.get(0, 2); - final float s_c12 = matrix2.get(1, 2); - final float s_c22 = matrix2.get(2, 2); - final float s_c32 = matrix2.get(3, 2); - final float s_c42 = matrix2.get(4, 2); - final float s_c03 = matrix2.get(0, 3); - final float s_c13 = matrix2.get(1, 3); - final float s_c23 = matrix2.get(2, 3); - final float s_c33 = matrix2.get(3, 3); - final float s_c43 = matrix2.get(4, 3); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33); - output.set(4, 0, f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42 + f_c30*s_c43); - output.set(4, 1, f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42 + f_c31*s_c43); - output.set(4, 2, f_c02*s_c40 + f_c12*s_c41 + f_c22*s_c42 + f_c32*s_c43); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float f30 = matrix1.get(3, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f21 = matrix1.get(2, 1); + final float f31 = matrix1.get(3, 1); + final float f02 = matrix1.get(0, 2); + final float f12 = matrix1.get(1, 2); + final float f22 = matrix1.get(2, 2); + final float f32 = matrix1.get(3, 2); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + final float s30 = matrix2.get(3, 0); + final float s40 = matrix2.get(4, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s21 = matrix2.get(2, 1); + final float s31 = matrix2.get(3, 1); + final float s41 = matrix2.get(4, 1); + final float s02 = matrix2.get(0, 2); + final float s12 = matrix2.get(1, 2); + final float s22 = matrix2.get(2, 2); + final float s32 = matrix2.get(3, 2); + final float s42 = matrix2.get(4, 2); + final float s03 = matrix2.get(0, 3); + final float s13 = matrix2.get(1, 3); + final float s23 = matrix2.get(2, 3); + final float s33 = matrix2.get(3, 3); + final float s43 = matrix2.get(4, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33); + output.set(4, 0, f00 * s40 + f10 * s41 + f20 * s42 + f30 * s43); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33); + output.set(4, 1, f01 * s40 + f11 * s41 + f21 * s42 + f31 * s43); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33); + output.set(4, 2, f02 * s40 + f12 * s41 + f22 * s42 + f32 * s43); + return output; + } + + private static IMatrixSetterFloat multiplyMatrix4x4x1(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float f30 = matrix1.get(3, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f21 = matrix1.get(2, 1); + final float f31 = matrix1.get(3, 1); + final float f02 = matrix1.get(0, 2); + final float f12 = matrix1.get(1, 2); + final float f22 = matrix1.get(2, 2); + final float f32 = matrix1.get(3, 2); + final float f03 = matrix1.get(0, 3); + final float f13 = matrix1.get(1, 3); + final float f23 = matrix1.get(2, 3); + final float f33 = matrix1.get(3, 3); + final float s00 = matrix2.get(0, 0); + final float s01 = matrix2.get(0, 1); + final float s02 = matrix2.get(0, 2); + final float s03 = matrix2.get(0, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03); return output; } private static IMatrixSetterFloat multiplyMatrix4x4x2(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final float f_c00 = matrix1.get(0, 0); - final float f_c10 = matrix1.get(1, 0); - final float f_c20 = matrix1.get(2, 0); - final float f_c30 = matrix1.get(3, 0); - final float f_c01 = matrix1.get(0, 1); - final float f_c11 = matrix1.get(1, 1); - final float f_c21 = matrix1.get(2, 1); - final float f_c31 = matrix1.get(3, 1); - final float f_c02 = matrix1.get(0, 2); - final float f_c12 = matrix1.get(1, 2); - final float f_c22 = matrix1.get(2, 2); - final float f_c32 = matrix1.get(3, 2); - final float f_c03 = matrix1.get(0, 3); - final float f_c13 = matrix1.get(1, 3); - final float f_c23 = matrix1.get(2, 3); - final float f_c33 = matrix1.get(3, 3); - final float s_c00 = matrix2.get(0, 0); - final float s_c10 = matrix2.get(1, 0); - final float s_c01 = matrix2.get(0, 1); - final float s_c11 = matrix2.get(1, 1); - final float s_c02 = matrix2.get(0, 2); - final float s_c12 = matrix2.get(1, 2); - final float s_c03 = matrix2.get(0, 3); - final float s_c13 = matrix2.get(1, 3); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float f30 = matrix1.get(3, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f21 = matrix1.get(2, 1); + final float f31 = matrix1.get(3, 1); + final float f02 = matrix1.get(0, 2); + final float f12 = matrix1.get(1, 2); + final float f22 = matrix1.get(2, 2); + final float f32 = matrix1.get(3, 2); + final float f03 = matrix1.get(0, 3); + final float f13 = matrix1.get(1, 3); + final float f23 = matrix1.get(2, 3); + final float f33 = matrix1.get(3, 3); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s02 = matrix2.get(0, 2); + final float s12 = matrix2.get(1, 2); + final float s03 = matrix2.get(0, 3); + final float s13 = matrix2.get(1, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13); return output; } private static IMatrixSetterFloat multiplyMatrix4x4x3(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final float f_c00 = matrix1.get(0, 0); - final float f_c10 = matrix1.get(1, 0); - final float f_c20 = matrix1.get(2, 0); - final float f_c30 = matrix1.get(3, 0); - final float f_c01 = matrix1.get(0, 1); - final float f_c11 = matrix1.get(1, 1); - final float f_c21 = matrix1.get(2, 1); - final float f_c31 = matrix1.get(3, 1); - final float f_c02 = matrix1.get(0, 2); - final float f_c12 = matrix1.get(1, 2); - final float f_c22 = matrix1.get(2, 2); - final float f_c32 = matrix1.get(3, 2); - final float f_c03 = matrix1.get(0, 3); - final float f_c13 = matrix1.get(1, 3); - final float f_c23 = matrix1.get(2, 3); - final float f_c33 = matrix1.get(3, 3); - final float s_c00 = matrix2.get(0, 0); - final float s_c10 = matrix2.get(1, 0); - final float s_c20 = matrix2.get(2, 0); - final float s_c01 = matrix2.get(0, 1); - final float s_c11 = matrix2.get(1, 1); - final float s_c21 = matrix2.get(2, 1); - final float s_c02 = matrix2.get(0, 2); - final float s_c12 = matrix2.get(1, 2); - final float s_c22 = matrix2.get(2, 2); - final float s_c03 = matrix2.get(0, 3); - final float s_c13 = matrix2.get(1, 3); - final float s_c23 = matrix2.get(2, 3); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float f30 = matrix1.get(3, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f21 = matrix1.get(2, 1); + final float f31 = matrix1.get(3, 1); + final float f02 = matrix1.get(0, 2); + final float f12 = matrix1.get(1, 2); + final float f22 = matrix1.get(2, 2); + final float f32 = matrix1.get(3, 2); + final float f03 = matrix1.get(0, 3); + final float f13 = matrix1.get(1, 3); + final float f23 = matrix1.get(2, 3); + final float f33 = matrix1.get(3, 3); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s21 = matrix2.get(2, 1); + final float s02 = matrix2.get(0, 2); + final float s12 = matrix2.get(1, 2); + final float s22 = matrix2.get(2, 2); + final float s03 = matrix2.get(0, 3); + final float s13 = matrix2.get(1, 3); + final float s23 = matrix2.get(2, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23); return output; } private static IMatrixSetterFloat multiplyMatrix4x4x4(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final float f_c00 = matrix1.get(0, 0); - final float f_c10 = matrix1.get(1, 0); - final float f_c20 = matrix1.get(2, 0); - final float f_c30 = matrix1.get(3, 0); - final float f_c01 = matrix1.get(0, 1); - final float f_c11 = matrix1.get(1, 1); - final float f_c21 = matrix1.get(2, 1); - final float f_c31 = matrix1.get(3, 1); - final float f_c02 = matrix1.get(0, 2); - final float f_c12 = matrix1.get(1, 2); - final float f_c22 = matrix1.get(2, 2); - final float f_c32 = matrix1.get(3, 2); - final float f_c03 = matrix1.get(0, 3); - final float f_c13 = matrix1.get(1, 3); - final float f_c23 = matrix1.get(2, 3); - final float f_c33 = matrix1.get(3, 3); - final float s_c00 = matrix2.get(0, 0); - final float s_c10 = matrix2.get(1, 0); - final float s_c20 = matrix2.get(2, 0); - final float s_c30 = matrix2.get(3, 0); - final float s_c01 = matrix2.get(0, 1); - final float s_c11 = matrix2.get(1, 1); - final float s_c21 = matrix2.get(2, 1); - final float s_c31 = matrix2.get(3, 1); - final float s_c02 = matrix2.get(0, 2); - final float s_c12 = matrix2.get(1, 2); - final float s_c22 = matrix2.get(2, 2); - final float s_c32 = matrix2.get(3, 2); - final float s_c03 = matrix2.get(0, 3); - final float s_c13 = matrix2.get(1, 3); - final float s_c23 = matrix2.get(2, 3); - final float s_c33 = matrix2.get(3, 3); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33); - output.set(3, 3, f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32 + f_c33*s_c33); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float f30 = matrix1.get(3, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f21 = matrix1.get(2, 1); + final float f31 = matrix1.get(3, 1); + final float f02 = matrix1.get(0, 2); + final float f12 = matrix1.get(1, 2); + final float f22 = matrix1.get(2, 2); + final float f32 = matrix1.get(3, 2); + final float f03 = matrix1.get(0, 3); + final float f13 = matrix1.get(1, 3); + final float f23 = matrix1.get(2, 3); + final float f33 = matrix1.get(3, 3); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + final float s30 = matrix2.get(3, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s21 = matrix2.get(2, 1); + final float s31 = matrix2.get(3, 1); + final float s02 = matrix2.get(0, 2); + final float s12 = matrix2.get(1, 2); + final float s22 = matrix2.get(2, 2); + final float s32 = matrix2.get(3, 2); + final float s03 = matrix2.get(0, 3); + final float s13 = matrix2.get(1, 3); + final float s23 = matrix2.get(2, 3); + final float s33 = matrix2.get(3, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23); + output.set(3, 3, f03 * s30 + f13 * s31 + f23 * s32 + f33 * s33); return output; } private static IMatrixSetterFloat multiplyMatrix4x4x5(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final float f_c00 = matrix1.get(0, 0); - final float f_c10 = matrix1.get(1, 0); - final float f_c20 = matrix1.get(2, 0); - final float f_c30 = matrix1.get(3, 0); - final float f_c01 = matrix1.get(0, 1); - final float f_c11 = matrix1.get(1, 1); - final float f_c21 = matrix1.get(2, 1); - final float f_c31 = matrix1.get(3, 1); - final float f_c02 = matrix1.get(0, 2); - final float f_c12 = matrix1.get(1, 2); - final float f_c22 = matrix1.get(2, 2); - final float f_c32 = matrix1.get(3, 2); - final float f_c03 = matrix1.get(0, 3); - final float f_c13 = matrix1.get(1, 3); - final float f_c23 = matrix1.get(2, 3); - final float f_c33 = matrix1.get(3, 3); - final float s_c00 = matrix2.get(0, 0); - final float s_c10 = matrix2.get(1, 0); - final float s_c20 = matrix2.get(2, 0); - final float s_c30 = matrix2.get(3, 0); - final float s_c40 = matrix2.get(4, 0); - final float s_c01 = matrix2.get(0, 1); - final float s_c11 = matrix2.get(1, 1); - final float s_c21 = matrix2.get(2, 1); - final float s_c31 = matrix2.get(3, 1); - final float s_c41 = matrix2.get(4, 1); - final float s_c02 = matrix2.get(0, 2); - final float s_c12 = matrix2.get(1, 2); - final float s_c22 = matrix2.get(2, 2); - final float s_c32 = matrix2.get(3, 2); - final float s_c42 = matrix2.get(4, 2); - final float s_c03 = matrix2.get(0, 3); - final float s_c13 = matrix2.get(1, 3); - final float s_c23 = matrix2.get(2, 3); - final float s_c33 = matrix2.get(3, 3); - final float s_c43 = matrix2.get(4, 3); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33); - output.set(3, 3, f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32 + f_c33*s_c33); - output.set(4, 0, f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42 + f_c30*s_c43); - output.set(4, 1, f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42 + f_c31*s_c43); - output.set(4, 2, f_c02*s_c40 + f_c12*s_c41 + f_c22*s_c42 + f_c32*s_c43); - output.set(4, 3, f_c03*s_c40 + f_c13*s_c41 + f_c23*s_c42 + f_c33*s_c43); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float f30 = matrix1.get(3, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f21 = matrix1.get(2, 1); + final float f31 = matrix1.get(3, 1); + final float f02 = matrix1.get(0, 2); + final float f12 = matrix1.get(1, 2); + final float f22 = matrix1.get(2, 2); + final float f32 = matrix1.get(3, 2); + final float f03 = matrix1.get(0, 3); + final float f13 = matrix1.get(1, 3); + final float f23 = matrix1.get(2, 3); + final float f33 = matrix1.get(3, 3); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + final float s30 = matrix2.get(3, 0); + final float s40 = matrix2.get(4, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s21 = matrix2.get(2, 1); + final float s31 = matrix2.get(3, 1); + final float s41 = matrix2.get(4, 1); + final float s02 = matrix2.get(0, 2); + final float s12 = matrix2.get(1, 2); + final float s22 = matrix2.get(2, 2); + final float s32 = matrix2.get(3, 2); + final float s42 = matrix2.get(4, 2); + final float s03 = matrix2.get(0, 3); + final float s13 = matrix2.get(1, 3); + final float s23 = matrix2.get(2, 3); + final float s33 = matrix2.get(3, 3); + final float s43 = matrix2.get(4, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33); + output.set(4, 0, f00 * s40 + f10 * s41 + f20 * s42 + f30 * s43); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33); + output.set(4, 1, f01 * s40 + f11 * s41 + f21 * s42 + f31 * s43); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33); + output.set(4, 2, f02 * s40 + f12 * s41 + f22 * s42 + f32 * s43); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23); + output.set(3, 3, f03 * s30 + f13 * s31 + f23 * s32 + f33 * s33); + output.set(4, 3, f03 * s40 + f13 * s41 + f23 * s42 + f33 * s43); + return output; + } + + private static IMatrixSetterFloat multiplyMatrix5x4x1(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float f30 = matrix1.get(3, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f21 = matrix1.get(2, 1); + final float f31 = matrix1.get(3, 1); + final float f02 = matrix1.get(0, 2); + final float f12 = matrix1.get(1, 2); + final float f22 = matrix1.get(2, 2); + final float f32 = matrix1.get(3, 2); + final float f03 = matrix1.get(0, 3); + final float f13 = matrix1.get(1, 3); + final float f23 = matrix1.get(2, 3); + final float f33 = matrix1.get(3, 3); + final float f04 = matrix1.get(0, 4); + final float f14 = matrix1.get(1, 4); + final float f24 = matrix1.get(2, 4); + final float f34 = matrix1.get(3, 4); + final float s00 = matrix2.get(0, 0); + final float s01 = matrix2.get(0, 1); + final float s02 = matrix2.get(0, 2); + final float s03 = matrix2.get(0, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03); + output.set(0, 4, f04 * s00 + f14 * s01 + f24 * s02 + f34 * s03); return output; } private static IMatrixSetterFloat multiplyMatrix5x4x2(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final float f_c00 = matrix1.get(0, 0); - final float f_c10 = matrix1.get(1, 0); - final float f_c20 = matrix1.get(2, 0); - final float f_c30 = matrix1.get(3, 0); - final float f_c01 = matrix1.get(0, 1); - final float f_c11 = matrix1.get(1, 1); - final float f_c21 = matrix1.get(2, 1); - final float f_c31 = matrix1.get(3, 1); - final float f_c02 = matrix1.get(0, 2); - final float f_c12 = matrix1.get(1, 2); - final float f_c22 = matrix1.get(2, 2); - final float f_c32 = matrix1.get(3, 2); - final float f_c03 = matrix1.get(0, 3); - final float f_c13 = matrix1.get(1, 3); - final float f_c23 = matrix1.get(2, 3); - final float f_c33 = matrix1.get(3, 3); - final float f_c04 = matrix1.get(0, 4); - final float f_c14 = matrix1.get(1, 4); - final float f_c24 = matrix1.get(2, 4); - final float f_c34 = matrix1.get(3, 4); - final float s_c00 = matrix2.get(0, 0); - final float s_c10 = matrix2.get(1, 0); - final float s_c01 = matrix2.get(0, 1); - final float s_c11 = matrix2.get(1, 1); - final float s_c02 = matrix2.get(0, 2); - final float s_c12 = matrix2.get(1, 2); - final float s_c03 = matrix2.get(0, 3); - final float s_c13 = matrix2.get(1, 3); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03); - output.set(0, 4, f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02 + f_c34*s_c03); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13); - output.set(1, 4, f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12 + f_c34*s_c13); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float f30 = matrix1.get(3, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f21 = matrix1.get(2, 1); + final float f31 = matrix1.get(3, 1); + final float f02 = matrix1.get(0, 2); + final float f12 = matrix1.get(1, 2); + final float f22 = matrix1.get(2, 2); + final float f32 = matrix1.get(3, 2); + final float f03 = matrix1.get(0, 3); + final float f13 = matrix1.get(1, 3); + final float f23 = matrix1.get(2, 3); + final float f33 = matrix1.get(3, 3); + final float f04 = matrix1.get(0, 4); + final float f14 = matrix1.get(1, 4); + final float f24 = matrix1.get(2, 4); + final float f34 = matrix1.get(3, 4); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s02 = matrix2.get(0, 2); + final float s12 = matrix2.get(1, 2); + final float s03 = matrix2.get(0, 3); + final float s13 = matrix2.get(1, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13); + output.set(0, 4, f04 * s00 + f14 * s01 + f24 * s02 + f34 * s03); + output.set(1, 4, f04 * s10 + f14 * s11 + f24 * s12 + f34 * s13); return output; } private static IMatrixSetterFloat multiplyMatrix5x4x3(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final float f_c00 = matrix1.get(0, 0); - final float f_c10 = matrix1.get(1, 0); - final float f_c20 = matrix1.get(2, 0); - final float f_c30 = matrix1.get(3, 0); - final float f_c01 = matrix1.get(0, 1); - final float f_c11 = matrix1.get(1, 1); - final float f_c21 = matrix1.get(2, 1); - final float f_c31 = matrix1.get(3, 1); - final float f_c02 = matrix1.get(0, 2); - final float f_c12 = matrix1.get(1, 2); - final float f_c22 = matrix1.get(2, 2); - final float f_c32 = matrix1.get(3, 2); - final float f_c03 = matrix1.get(0, 3); - final float f_c13 = matrix1.get(1, 3); - final float f_c23 = matrix1.get(2, 3); - final float f_c33 = matrix1.get(3, 3); - final float f_c04 = matrix1.get(0, 4); - final float f_c14 = matrix1.get(1, 4); - final float f_c24 = matrix1.get(2, 4); - final float f_c34 = matrix1.get(3, 4); - final float s_c00 = matrix2.get(0, 0); - final float s_c10 = matrix2.get(1, 0); - final float s_c20 = matrix2.get(2, 0); - final float s_c01 = matrix2.get(0, 1); - final float s_c11 = matrix2.get(1, 1); - final float s_c21 = matrix2.get(2, 1); - final float s_c02 = matrix2.get(0, 2); - final float s_c12 = matrix2.get(1, 2); - final float s_c22 = matrix2.get(2, 2); - final float s_c03 = matrix2.get(0, 3); - final float s_c13 = matrix2.get(1, 3); - final float s_c23 = matrix2.get(2, 3); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03); - output.set(0, 4, f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02 + f_c34*s_c03); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13); - output.set(1, 4, f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12 + f_c34*s_c13); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23); - output.set(2, 4, f_c04*s_c20 + f_c14*s_c21 + f_c24*s_c22 + f_c34*s_c23); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float f30 = matrix1.get(3, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f21 = matrix1.get(2, 1); + final float f31 = matrix1.get(3, 1); + final float f02 = matrix1.get(0, 2); + final float f12 = matrix1.get(1, 2); + final float f22 = matrix1.get(2, 2); + final float f32 = matrix1.get(3, 2); + final float f03 = matrix1.get(0, 3); + final float f13 = matrix1.get(1, 3); + final float f23 = matrix1.get(2, 3); + final float f33 = matrix1.get(3, 3); + final float f04 = matrix1.get(0, 4); + final float f14 = matrix1.get(1, 4); + final float f24 = matrix1.get(2, 4); + final float f34 = matrix1.get(3, 4); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s21 = matrix2.get(2, 1); + final float s02 = matrix2.get(0, 2); + final float s12 = matrix2.get(1, 2); + final float s22 = matrix2.get(2, 2); + final float s03 = matrix2.get(0, 3); + final float s13 = matrix2.get(1, 3); + final float s23 = matrix2.get(2, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23); + output.set(0, 4, f04 * s00 + f14 * s01 + f24 * s02 + f34 * s03); + output.set(1, 4, f04 * s10 + f14 * s11 + f24 * s12 + f34 * s13); + output.set(2, 4, f04 * s20 + f14 * s21 + f24 * s22 + f34 * s23); return output; } private static IMatrixSetterFloat multiplyMatrix5x4x4(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final float f_c00 = matrix1.get(0, 0); - final float f_c10 = matrix1.get(1, 0); - final float f_c20 = matrix1.get(2, 0); - final float f_c30 = matrix1.get(3, 0); - final float f_c01 = matrix1.get(0, 1); - final float f_c11 = matrix1.get(1, 1); - final float f_c21 = matrix1.get(2, 1); - final float f_c31 = matrix1.get(3, 1); - final float f_c02 = matrix1.get(0, 2); - final float f_c12 = matrix1.get(1, 2); - final float f_c22 = matrix1.get(2, 2); - final float f_c32 = matrix1.get(3, 2); - final float f_c03 = matrix1.get(0, 3); - final float f_c13 = matrix1.get(1, 3); - final float f_c23 = matrix1.get(2, 3); - final float f_c33 = matrix1.get(3, 3); - final float f_c04 = matrix1.get(0, 4); - final float f_c14 = matrix1.get(1, 4); - final float f_c24 = matrix1.get(2, 4); - final float f_c34 = matrix1.get(3, 4); - final float s_c00 = matrix2.get(0, 0); - final float s_c10 = matrix2.get(1, 0); - final float s_c20 = matrix2.get(2, 0); - final float s_c30 = matrix2.get(3, 0); - final float s_c01 = matrix2.get(0, 1); - final float s_c11 = matrix2.get(1, 1); - final float s_c21 = matrix2.get(2, 1); - final float s_c31 = matrix2.get(3, 1); - final float s_c02 = matrix2.get(0, 2); - final float s_c12 = matrix2.get(1, 2); - final float s_c22 = matrix2.get(2, 2); - final float s_c32 = matrix2.get(3, 2); - final float s_c03 = matrix2.get(0, 3); - final float s_c13 = matrix2.get(1, 3); - final float s_c23 = matrix2.get(2, 3); - final float s_c33 = matrix2.get(3, 3); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03); - output.set(0, 4, f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02 + f_c34*s_c03); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13); - output.set(1, 4, f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12 + f_c34*s_c13); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23); - output.set(2, 4, f_c04*s_c20 + f_c14*s_c21 + f_c24*s_c22 + f_c34*s_c23); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33); - output.set(3, 3, f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32 + f_c33*s_c33); - output.set(3, 4, f_c04*s_c30 + f_c14*s_c31 + f_c24*s_c32 + f_c34*s_c33); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float f30 = matrix1.get(3, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f21 = matrix1.get(2, 1); + final float f31 = matrix1.get(3, 1); + final float f02 = matrix1.get(0, 2); + final float f12 = matrix1.get(1, 2); + final float f22 = matrix1.get(2, 2); + final float f32 = matrix1.get(3, 2); + final float f03 = matrix1.get(0, 3); + final float f13 = matrix1.get(1, 3); + final float f23 = matrix1.get(2, 3); + final float f33 = matrix1.get(3, 3); + final float f04 = matrix1.get(0, 4); + final float f14 = matrix1.get(1, 4); + final float f24 = matrix1.get(2, 4); + final float f34 = matrix1.get(3, 4); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + final float s30 = matrix2.get(3, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s21 = matrix2.get(2, 1); + final float s31 = matrix2.get(3, 1); + final float s02 = matrix2.get(0, 2); + final float s12 = matrix2.get(1, 2); + final float s22 = matrix2.get(2, 2); + final float s32 = matrix2.get(3, 2); + final float s03 = matrix2.get(0, 3); + final float s13 = matrix2.get(1, 3); + final float s23 = matrix2.get(2, 3); + final float s33 = matrix2.get(3, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23); + output.set(3, 3, f03 * s30 + f13 * s31 + f23 * s32 + f33 * s33); + output.set(0, 4, f04 * s00 + f14 * s01 + f24 * s02 + f34 * s03); + output.set(1, 4, f04 * s10 + f14 * s11 + f24 * s12 + f34 * s13); + output.set(2, 4, f04 * s20 + f14 * s21 + f24 * s22 + f34 * s23); + output.set(3, 4, f04 * s30 + f14 * s31 + f24 * s32 + f34 * s33); return output; } private static IMatrixSetterFloat multiplyMatrix5x4x5(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final float f_c00 = matrix1.get(0, 0); - final float f_c10 = matrix1.get(1, 0); - final float f_c20 = matrix1.get(2, 0); - final float f_c30 = matrix1.get(3, 0); - final float f_c01 = matrix1.get(0, 1); - final float f_c11 = matrix1.get(1, 1); - final float f_c21 = matrix1.get(2, 1); - final float f_c31 = matrix1.get(3, 1); - final float f_c02 = matrix1.get(0, 2); - final float f_c12 = matrix1.get(1, 2); - final float f_c22 = matrix1.get(2, 2); - final float f_c32 = matrix1.get(3, 2); - final float f_c03 = matrix1.get(0, 3); - final float f_c13 = matrix1.get(1, 3); - final float f_c23 = matrix1.get(2, 3); - final float f_c33 = matrix1.get(3, 3); - final float f_c04 = matrix1.get(0, 4); - final float f_c14 = matrix1.get(1, 4); - final float f_c24 = matrix1.get(2, 4); - final float f_c34 = matrix1.get(3, 4); - final float s_c00 = matrix2.get(0, 0); - final float s_c10 = matrix2.get(1, 0); - final float s_c20 = matrix2.get(2, 0); - final float s_c30 = matrix2.get(3, 0); - final float s_c40 = matrix2.get(4, 0); - final float s_c01 = matrix2.get(0, 1); - final float s_c11 = matrix2.get(1, 1); - final float s_c21 = matrix2.get(2, 1); - final float s_c31 = matrix2.get(3, 1); - final float s_c41 = matrix2.get(4, 1); - final float s_c02 = matrix2.get(0, 2); - final float s_c12 = matrix2.get(1, 2); - final float s_c22 = matrix2.get(2, 2); - final float s_c32 = matrix2.get(3, 2); - final float s_c42 = matrix2.get(4, 2); - final float s_c03 = matrix2.get(0, 3); - final float s_c13 = matrix2.get(1, 3); - final float s_c23 = matrix2.get(2, 3); - final float s_c33 = matrix2.get(3, 3); - final float s_c43 = matrix2.get(4, 3); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03); - output.set(0, 4, f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02 + f_c34*s_c03); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13); - output.set(1, 4, f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12 + f_c34*s_c13); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23); - output.set(2, 4, f_c04*s_c20 + f_c14*s_c21 + f_c24*s_c22 + f_c34*s_c23); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33); - output.set(3, 3, f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32 + f_c33*s_c33); - output.set(3, 4, f_c04*s_c30 + f_c14*s_c31 + f_c24*s_c32 + f_c34*s_c33); - output.set(4, 0, f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42 + f_c30*s_c43); - output.set(4, 1, f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42 + f_c31*s_c43); - output.set(4, 2, f_c02*s_c40 + f_c12*s_c41 + f_c22*s_c42 + f_c32*s_c43); - output.set(4, 3, f_c03*s_c40 + f_c13*s_c41 + f_c23*s_c42 + f_c33*s_c43); - output.set(4, 4, f_c04*s_c40 + f_c14*s_c41 + f_c24*s_c42 + f_c34*s_c43); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float f30 = matrix1.get(3, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f21 = matrix1.get(2, 1); + final float f31 = matrix1.get(3, 1); + final float f02 = matrix1.get(0, 2); + final float f12 = matrix1.get(1, 2); + final float f22 = matrix1.get(2, 2); + final float f32 = matrix1.get(3, 2); + final float f03 = matrix1.get(0, 3); + final float f13 = matrix1.get(1, 3); + final float f23 = matrix1.get(2, 3); + final float f33 = matrix1.get(3, 3); + final float f04 = matrix1.get(0, 4); + final float f14 = matrix1.get(1, 4); + final float f24 = matrix1.get(2, 4); + final float f34 = matrix1.get(3, 4); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + final float s30 = matrix2.get(3, 0); + final float s40 = matrix2.get(4, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s21 = matrix2.get(2, 1); + final float s31 = matrix2.get(3, 1); + final float s41 = matrix2.get(4, 1); + final float s02 = matrix2.get(0, 2); + final float s12 = matrix2.get(1, 2); + final float s22 = matrix2.get(2, 2); + final float s32 = matrix2.get(3, 2); + final float s42 = matrix2.get(4, 2); + final float s03 = matrix2.get(0, 3); + final float s13 = matrix2.get(1, 3); + final float s23 = matrix2.get(2, 3); + final float s33 = matrix2.get(3, 3); + final float s43 = matrix2.get(4, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33); + output.set(4, 0, f00 * s40 + f10 * s41 + f20 * s42 + f30 * s43); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33); + output.set(4, 1, f01 * s40 + f11 * s41 + f21 * s42 + f31 * s43); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33); + output.set(4, 2, f02 * s40 + f12 * s41 + f22 * s42 + f32 * s43); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23); + output.set(3, 3, f03 * s30 + f13 * s31 + f23 * s32 + f33 * s33); + output.set(4, 3, f03 * s40 + f13 * s41 + f23 * s42 + f33 * s43); + output.set(0, 4, f04 * s00 + f14 * s01 + f24 * s02 + f34 * s03); + output.set(1, 4, f04 * s10 + f14 * s11 + f24 * s12 + f34 * s13); + output.set(2, 4, f04 * s20 + f14 * s21 + f24 * s22 + f34 * s23); + output.set(3, 4, f04 * s30 + f14 * s31 + f24 * s32 + f34 * s33); + output.set(4, 4, f04 * s40 + f14 * s41 + f24 * s42 + f34 * s43); + return output; + } + + private static IMatrixSetterFloat multiplyMatrix1x5x1(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float f30 = matrix1.get(3, 0); + final float f40 = matrix1.get(4, 0); + final float s00 = matrix2.get(0, 0); + final float s01 = matrix2.get(0, 1); + final float s02 = matrix2.get(0, 2); + final float s03 = matrix2.get(0, 3); + final float s04 = matrix2.get(0, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + return output; + } + + private static IMatrixSetterFloat multiplyMatrix1x5x2(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float f30 = matrix1.get(3, 0); + final float f40 = matrix1.get(4, 0); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s02 = matrix2.get(0, 2); + final float s12 = matrix2.get(1, 2); + final float s03 = matrix2.get(0, 3); + final float s13 = matrix2.get(1, 3); + final float s04 = matrix2.get(0, 4); + final float s14 = matrix2.get(1, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + return output; + } + + private static IMatrixSetterFloat multiplyMatrix1x5x3(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float f30 = matrix1.get(3, 0); + final float f40 = matrix1.get(4, 0); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s21 = matrix2.get(2, 1); + final float s02 = matrix2.get(0, 2); + final float s12 = matrix2.get(1, 2); + final float s22 = matrix2.get(2, 2); + final float s03 = matrix2.get(0, 3); + final float s13 = matrix2.get(1, 3); + final float s23 = matrix2.get(2, 3); + final float s04 = matrix2.get(0, 4); + final float s14 = matrix2.get(1, 4); + final float s24 = matrix2.get(2, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24); + return output; + } + + private static IMatrixSetterFloat multiplyMatrix1x5x4(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float f30 = matrix1.get(3, 0); + final float f40 = matrix1.get(4, 0); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + final float s30 = matrix2.get(3, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s21 = matrix2.get(2, 1); + final float s31 = matrix2.get(3, 1); + final float s02 = matrix2.get(0, 2); + final float s12 = matrix2.get(1, 2); + final float s22 = matrix2.get(2, 2); + final float s32 = matrix2.get(3, 2); + final float s03 = matrix2.get(0, 3); + final float s13 = matrix2.get(1, 3); + final float s23 = matrix2.get(2, 3); + final float s33 = matrix2.get(3, 3); + final float s04 = matrix2.get(0, 4); + final float s14 = matrix2.get(1, 4); + final float s24 = matrix2.get(2, 4); + final float s34 = matrix2.get(3, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33 + f40 * s34); + return output; + } + + private static IMatrixSetterFloat multiplyMatrix1x5x5(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float f30 = matrix1.get(3, 0); + final float f40 = matrix1.get(4, 0); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + final float s30 = matrix2.get(3, 0); + final float s40 = matrix2.get(4, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s21 = matrix2.get(2, 1); + final float s31 = matrix2.get(3, 1); + final float s41 = matrix2.get(4, 1); + final float s02 = matrix2.get(0, 2); + final float s12 = matrix2.get(1, 2); + final float s22 = matrix2.get(2, 2); + final float s32 = matrix2.get(3, 2); + final float s42 = matrix2.get(4, 2); + final float s03 = matrix2.get(0, 3); + final float s13 = matrix2.get(1, 3); + final float s23 = matrix2.get(2, 3); + final float s33 = matrix2.get(3, 3); + final float s43 = matrix2.get(4, 3); + final float s04 = matrix2.get(0, 4); + final float s14 = matrix2.get(1, 4); + final float s24 = matrix2.get(2, 4); + final float s34 = matrix2.get(3, 4); + final float s44 = matrix2.get(4, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33 + f40 * s34); + output.set(4, 0, f00 * s40 + f10 * s41 + f20 * s42 + f30 * s43 + f40 * s44); + return output; + } + + private static IMatrixSetterFloat multiplyMatrix2x5x1(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float f30 = matrix1.get(3, 0); + final float f40 = matrix1.get(4, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f21 = matrix1.get(2, 1); + final float f31 = matrix1.get(3, 1); + final float f41 = matrix1.get(4, 1); + final float s00 = matrix2.get(0, 0); + final float s01 = matrix2.get(0, 1); + final float s02 = matrix2.get(0, 2); + final float s03 = matrix2.get(0, 3); + final float s04 = matrix2.get(0, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); return output; } private static IMatrixSetterFloat multiplyMatrix2x5x2(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final float f_c00 = matrix1.get(0, 0); - final float f_c10 = matrix1.get(1, 0); - final float f_c20 = matrix1.get(2, 0); - final float f_c30 = matrix1.get(3, 0); - final float f_c40 = matrix1.get(4, 0); - final float f_c01 = matrix1.get(0, 1); - final float f_c11 = matrix1.get(1, 1); - final float f_c21 = matrix1.get(2, 1); - final float f_c31 = matrix1.get(3, 1); - final float f_c41 = matrix1.get(4, 1); - final float s_c00 = matrix2.get(0, 0); - final float s_c10 = matrix2.get(1, 0); - final float s_c01 = matrix2.get(0, 1); - final float s_c11 = matrix2.get(1, 1); - final float s_c02 = matrix2.get(0, 2); - final float s_c12 = matrix2.get(1, 2); - final float s_c03 = matrix2.get(0, 3); - final float s_c13 = matrix2.get(1, 3); - final float s_c04 = matrix2.get(0, 4); - final float s_c14 = matrix2.get(1, 4); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float f30 = matrix1.get(3, 0); + final float f40 = matrix1.get(4, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f21 = matrix1.get(2, 1); + final float f31 = matrix1.get(3, 1); + final float f41 = matrix1.get(4, 1); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s02 = matrix2.get(0, 2); + final float s12 = matrix2.get(1, 2); + final float s03 = matrix2.get(0, 3); + final float s13 = matrix2.get(1, 3); + final float s04 = matrix2.get(0, 4); + final float s14 = matrix2.get(1, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14); return output; } private static IMatrixSetterFloat multiplyMatrix2x5x3(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final float f_c00 = matrix1.get(0, 0); - final float f_c10 = matrix1.get(1, 0); - final float f_c20 = matrix1.get(2, 0); - final float f_c30 = matrix1.get(3, 0); - final float f_c40 = matrix1.get(4, 0); - final float f_c01 = matrix1.get(0, 1); - final float f_c11 = matrix1.get(1, 1); - final float f_c21 = matrix1.get(2, 1); - final float f_c31 = matrix1.get(3, 1); - final float f_c41 = matrix1.get(4, 1); - final float s_c00 = matrix2.get(0, 0); - final float s_c10 = matrix2.get(1, 0); - final float s_c20 = matrix2.get(2, 0); - final float s_c01 = matrix2.get(0, 1); - final float s_c11 = matrix2.get(1, 1); - final float s_c21 = matrix2.get(2, 1); - final float s_c02 = matrix2.get(0, 2); - final float s_c12 = matrix2.get(1, 2); - final float s_c22 = matrix2.get(2, 2); - final float s_c03 = matrix2.get(0, 3); - final float s_c13 = matrix2.get(1, 3); - final float s_c23 = matrix2.get(2, 3); - final float s_c04 = matrix2.get(0, 4); - final float s_c14 = matrix2.get(1, 4); - final float s_c24 = matrix2.get(2, 4); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float f30 = matrix1.get(3, 0); + final float f40 = matrix1.get(4, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f21 = matrix1.get(2, 1); + final float f31 = matrix1.get(3, 1); + final float f41 = matrix1.get(4, 1); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s21 = matrix2.get(2, 1); + final float s02 = matrix2.get(0, 2); + final float s12 = matrix2.get(1, 2); + final float s22 = matrix2.get(2, 2); + final float s03 = matrix2.get(0, 3); + final float s13 = matrix2.get(1, 3); + final float s23 = matrix2.get(2, 3); + final float s04 = matrix2.get(0, 4); + final float s14 = matrix2.get(1, 4); + final float s24 = matrix2.get(2, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24); return output; } private static IMatrixSetterFloat multiplyMatrix2x5x4(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final float f_c00 = matrix1.get(0, 0); - final float f_c10 = matrix1.get(1, 0); - final float f_c20 = matrix1.get(2, 0); - final float f_c30 = matrix1.get(3, 0); - final float f_c40 = matrix1.get(4, 0); - final float f_c01 = matrix1.get(0, 1); - final float f_c11 = matrix1.get(1, 1); - final float f_c21 = matrix1.get(2, 1); - final float f_c31 = matrix1.get(3, 1); - final float f_c41 = matrix1.get(4, 1); - final float s_c00 = matrix2.get(0, 0); - final float s_c10 = matrix2.get(1, 0); - final float s_c20 = matrix2.get(2, 0); - final float s_c30 = matrix2.get(3, 0); - final float s_c01 = matrix2.get(0, 1); - final float s_c11 = matrix2.get(1, 1); - final float s_c21 = matrix2.get(2, 1); - final float s_c31 = matrix2.get(3, 1); - final float s_c02 = matrix2.get(0, 2); - final float s_c12 = matrix2.get(1, 2); - final float s_c22 = matrix2.get(2, 2); - final float s_c32 = matrix2.get(3, 2); - final float s_c03 = matrix2.get(0, 3); - final float s_c13 = matrix2.get(1, 3); - final float s_c23 = matrix2.get(2, 3); - final float s_c33 = matrix2.get(3, 3); - final float s_c04 = matrix2.get(0, 4); - final float s_c14 = matrix2.get(1, 4); - final float s_c24 = matrix2.get(2, 4); - final float s_c34 = matrix2.get(3, 4); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33 + f_c40*s_c34); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33 + f_c41*s_c34); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float f30 = matrix1.get(3, 0); + final float f40 = matrix1.get(4, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f21 = matrix1.get(2, 1); + final float f31 = matrix1.get(3, 1); + final float f41 = matrix1.get(4, 1); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + final float s30 = matrix2.get(3, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s21 = matrix2.get(2, 1); + final float s31 = matrix2.get(3, 1); + final float s02 = matrix2.get(0, 2); + final float s12 = matrix2.get(1, 2); + final float s22 = matrix2.get(2, 2); + final float s32 = matrix2.get(3, 2); + final float s03 = matrix2.get(0, 3); + final float s13 = matrix2.get(1, 3); + final float s23 = matrix2.get(2, 3); + final float s33 = matrix2.get(3, 3); + final float s04 = matrix2.get(0, 4); + final float s14 = matrix2.get(1, 4); + final float s24 = matrix2.get(2, 4); + final float s34 = matrix2.get(3, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33 + f40 * s34); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33 + f41 * s34); return output; } private static IMatrixSetterFloat multiplyMatrix2x5x5(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final float f_c00 = matrix1.get(0, 0); - final float f_c10 = matrix1.get(1, 0); - final float f_c20 = matrix1.get(2, 0); - final float f_c30 = matrix1.get(3, 0); - final float f_c40 = matrix1.get(4, 0); - final float f_c01 = matrix1.get(0, 1); - final float f_c11 = matrix1.get(1, 1); - final float f_c21 = matrix1.get(2, 1); - final float f_c31 = matrix1.get(3, 1); - final float f_c41 = matrix1.get(4, 1); - final float s_c00 = matrix2.get(0, 0); - final float s_c10 = matrix2.get(1, 0); - final float s_c20 = matrix2.get(2, 0); - final float s_c30 = matrix2.get(3, 0); - final float s_c40 = matrix2.get(4, 0); - final float s_c01 = matrix2.get(0, 1); - final float s_c11 = matrix2.get(1, 1); - final float s_c21 = matrix2.get(2, 1); - final float s_c31 = matrix2.get(3, 1); - final float s_c41 = matrix2.get(4, 1); - final float s_c02 = matrix2.get(0, 2); - final float s_c12 = matrix2.get(1, 2); - final float s_c22 = matrix2.get(2, 2); - final float s_c32 = matrix2.get(3, 2); - final float s_c42 = matrix2.get(4, 2); - final float s_c03 = matrix2.get(0, 3); - final float s_c13 = matrix2.get(1, 3); - final float s_c23 = matrix2.get(2, 3); - final float s_c33 = matrix2.get(3, 3); - final float s_c43 = matrix2.get(4, 3); - final float s_c04 = matrix2.get(0, 4); - final float s_c14 = matrix2.get(1, 4); - final float s_c24 = matrix2.get(2, 4); - final float s_c34 = matrix2.get(3, 4); - final float s_c44 = matrix2.get(4, 4); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33 + f_c40*s_c34); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33 + f_c41*s_c34); - output.set(4, 0, f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42 + f_c30*s_c43 + f_c40*s_c44); - output.set(4, 1, f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42 + f_c31*s_c43 + f_c41*s_c44); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float f30 = matrix1.get(3, 0); + final float f40 = matrix1.get(4, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f21 = matrix1.get(2, 1); + final float f31 = matrix1.get(3, 1); + final float f41 = matrix1.get(4, 1); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + final float s30 = matrix2.get(3, 0); + final float s40 = matrix2.get(4, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s21 = matrix2.get(2, 1); + final float s31 = matrix2.get(3, 1); + final float s41 = matrix2.get(4, 1); + final float s02 = matrix2.get(0, 2); + final float s12 = matrix2.get(1, 2); + final float s22 = matrix2.get(2, 2); + final float s32 = matrix2.get(3, 2); + final float s42 = matrix2.get(4, 2); + final float s03 = matrix2.get(0, 3); + final float s13 = matrix2.get(1, 3); + final float s23 = matrix2.get(2, 3); + final float s33 = matrix2.get(3, 3); + final float s43 = matrix2.get(4, 3); + final float s04 = matrix2.get(0, 4); + final float s14 = matrix2.get(1, 4); + final float s24 = matrix2.get(2, 4); + final float s34 = matrix2.get(3, 4); + final float s44 = matrix2.get(4, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33 + f40 * s34); + output.set(4, 0, f00 * s40 + f10 * s41 + f20 * s42 + f30 * s43 + f40 * s44); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33 + f41 * s34); + output.set(4, 1, f01 * s40 + f11 * s41 + f21 * s42 + f31 * s43 + f41 * s44); + return output; + } + + private static IMatrixSetterFloat multiplyMatrix3x5x1(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float f30 = matrix1.get(3, 0); + final float f40 = matrix1.get(4, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f21 = matrix1.get(2, 1); + final float f31 = matrix1.get(3, 1); + final float f41 = matrix1.get(4, 1); + final float f02 = matrix1.get(0, 2); + final float f12 = matrix1.get(1, 2); + final float f22 = matrix1.get(2, 2); + final float f32 = matrix1.get(3, 2); + final float f42 = matrix1.get(4, 2); + final float s00 = matrix2.get(0, 0); + final float s01 = matrix2.get(0, 1); + final float s02 = matrix2.get(0, 2); + final float s03 = matrix2.get(0, 3); + final float s04 = matrix2.get(0, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04); return output; } private static IMatrixSetterFloat multiplyMatrix3x5x2(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final float f_c00 = matrix1.get(0, 0); - final float f_c10 = matrix1.get(1, 0); - final float f_c20 = matrix1.get(2, 0); - final float f_c30 = matrix1.get(3, 0); - final float f_c40 = matrix1.get(4, 0); - final float f_c01 = matrix1.get(0, 1); - final float f_c11 = matrix1.get(1, 1); - final float f_c21 = matrix1.get(2, 1); - final float f_c31 = matrix1.get(3, 1); - final float f_c41 = matrix1.get(4, 1); - final float f_c02 = matrix1.get(0, 2); - final float f_c12 = matrix1.get(1, 2); - final float f_c22 = matrix1.get(2, 2); - final float f_c32 = matrix1.get(3, 2); - final float f_c42 = matrix1.get(4, 2); - final float s_c00 = matrix2.get(0, 0); - final float s_c10 = matrix2.get(1, 0); - final float s_c01 = matrix2.get(0, 1); - final float s_c11 = matrix2.get(1, 1); - final float s_c02 = matrix2.get(0, 2); - final float s_c12 = matrix2.get(1, 2); - final float s_c03 = matrix2.get(0, 3); - final float s_c13 = matrix2.get(1, 3); - final float s_c04 = matrix2.get(0, 4); - final float s_c14 = matrix2.get(1, 4); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float f30 = matrix1.get(3, 0); + final float f40 = matrix1.get(4, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f21 = matrix1.get(2, 1); + final float f31 = matrix1.get(3, 1); + final float f41 = matrix1.get(4, 1); + final float f02 = matrix1.get(0, 2); + final float f12 = matrix1.get(1, 2); + final float f22 = matrix1.get(2, 2); + final float f32 = matrix1.get(3, 2); + final float f42 = matrix1.get(4, 2); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s02 = matrix2.get(0, 2); + final float s12 = matrix2.get(1, 2); + final float s03 = matrix2.get(0, 3); + final float s13 = matrix2.get(1, 3); + final float s04 = matrix2.get(0, 4); + final float s14 = matrix2.get(1, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14); return output; } private static IMatrixSetterFloat multiplyMatrix3x5x3(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final float f_c00 = matrix1.get(0, 0); - final float f_c10 = matrix1.get(1, 0); - final float f_c20 = matrix1.get(2, 0); - final float f_c30 = matrix1.get(3, 0); - final float f_c40 = matrix1.get(4, 0); - final float f_c01 = matrix1.get(0, 1); - final float f_c11 = matrix1.get(1, 1); - final float f_c21 = matrix1.get(2, 1); - final float f_c31 = matrix1.get(3, 1); - final float f_c41 = matrix1.get(4, 1); - final float f_c02 = matrix1.get(0, 2); - final float f_c12 = matrix1.get(1, 2); - final float f_c22 = matrix1.get(2, 2); - final float f_c32 = matrix1.get(3, 2); - final float f_c42 = matrix1.get(4, 2); - final float s_c00 = matrix2.get(0, 0); - final float s_c10 = matrix2.get(1, 0); - final float s_c20 = matrix2.get(2, 0); - final float s_c01 = matrix2.get(0, 1); - final float s_c11 = matrix2.get(1, 1); - final float s_c21 = matrix2.get(2, 1); - final float s_c02 = matrix2.get(0, 2); - final float s_c12 = matrix2.get(1, 2); - final float s_c22 = matrix2.get(2, 2); - final float s_c03 = matrix2.get(0, 3); - final float s_c13 = matrix2.get(1, 3); - final float s_c23 = matrix2.get(2, 3); - final float s_c04 = matrix2.get(0, 4); - final float s_c14 = matrix2.get(1, 4); - final float s_c24 = matrix2.get(2, 4); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23 + f_c42*s_c24); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float f30 = matrix1.get(3, 0); + final float f40 = matrix1.get(4, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f21 = matrix1.get(2, 1); + final float f31 = matrix1.get(3, 1); + final float f41 = matrix1.get(4, 1); + final float f02 = matrix1.get(0, 2); + final float f12 = matrix1.get(1, 2); + final float f22 = matrix1.get(2, 2); + final float f32 = matrix1.get(3, 2); + final float f42 = matrix1.get(4, 2); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s21 = matrix2.get(2, 1); + final float s02 = matrix2.get(0, 2); + final float s12 = matrix2.get(1, 2); + final float s22 = matrix2.get(2, 2); + final float s03 = matrix2.get(0, 3); + final float s13 = matrix2.get(1, 3); + final float s23 = matrix2.get(2, 3); + final float s04 = matrix2.get(0, 4); + final float s14 = matrix2.get(1, 4); + final float s24 = matrix2.get(2, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23 + f42 * s24); return output; } private static IMatrixSetterFloat multiplyMatrix3x5x4(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final float f_c00 = matrix1.get(0, 0); - final float f_c10 = matrix1.get(1, 0); - final float f_c20 = matrix1.get(2, 0); - final float f_c30 = matrix1.get(3, 0); - final float f_c40 = matrix1.get(4, 0); - final float f_c01 = matrix1.get(0, 1); - final float f_c11 = matrix1.get(1, 1); - final float f_c21 = matrix1.get(2, 1); - final float f_c31 = matrix1.get(3, 1); - final float f_c41 = matrix1.get(4, 1); - final float f_c02 = matrix1.get(0, 2); - final float f_c12 = matrix1.get(1, 2); - final float f_c22 = matrix1.get(2, 2); - final float f_c32 = matrix1.get(3, 2); - final float f_c42 = matrix1.get(4, 2); - final float s_c00 = matrix2.get(0, 0); - final float s_c10 = matrix2.get(1, 0); - final float s_c20 = matrix2.get(2, 0); - final float s_c30 = matrix2.get(3, 0); - final float s_c01 = matrix2.get(0, 1); - final float s_c11 = matrix2.get(1, 1); - final float s_c21 = matrix2.get(2, 1); - final float s_c31 = matrix2.get(3, 1); - final float s_c02 = matrix2.get(0, 2); - final float s_c12 = matrix2.get(1, 2); - final float s_c22 = matrix2.get(2, 2); - final float s_c32 = matrix2.get(3, 2); - final float s_c03 = matrix2.get(0, 3); - final float s_c13 = matrix2.get(1, 3); - final float s_c23 = matrix2.get(2, 3); - final float s_c33 = matrix2.get(3, 3); - final float s_c04 = matrix2.get(0, 4); - final float s_c14 = matrix2.get(1, 4); - final float s_c24 = matrix2.get(2, 4); - final float s_c34 = matrix2.get(3, 4); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23 + f_c42*s_c24); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33 + f_c40*s_c34); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33 + f_c41*s_c34); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33 + f_c42*s_c34); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float f30 = matrix1.get(3, 0); + final float f40 = matrix1.get(4, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f21 = matrix1.get(2, 1); + final float f31 = matrix1.get(3, 1); + final float f41 = matrix1.get(4, 1); + final float f02 = matrix1.get(0, 2); + final float f12 = matrix1.get(1, 2); + final float f22 = matrix1.get(2, 2); + final float f32 = matrix1.get(3, 2); + final float f42 = matrix1.get(4, 2); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + final float s30 = matrix2.get(3, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s21 = matrix2.get(2, 1); + final float s31 = matrix2.get(3, 1); + final float s02 = matrix2.get(0, 2); + final float s12 = matrix2.get(1, 2); + final float s22 = matrix2.get(2, 2); + final float s32 = matrix2.get(3, 2); + final float s03 = matrix2.get(0, 3); + final float s13 = matrix2.get(1, 3); + final float s23 = matrix2.get(2, 3); + final float s33 = matrix2.get(3, 3); + final float s04 = matrix2.get(0, 4); + final float s14 = matrix2.get(1, 4); + final float s24 = matrix2.get(2, 4); + final float s34 = matrix2.get(3, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33 + f40 * s34); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33 + f41 * s34); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23 + f42 * s24); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33 + f42 * s34); return output; } private static IMatrixSetterFloat multiplyMatrix3x5x5(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final float f_c00 = matrix1.get(0, 0); - final float f_c10 = matrix1.get(1, 0); - final float f_c20 = matrix1.get(2, 0); - final float f_c30 = matrix1.get(3, 0); - final float f_c40 = matrix1.get(4, 0); - final float f_c01 = matrix1.get(0, 1); - final float f_c11 = matrix1.get(1, 1); - final float f_c21 = matrix1.get(2, 1); - final float f_c31 = matrix1.get(3, 1); - final float f_c41 = matrix1.get(4, 1); - final float f_c02 = matrix1.get(0, 2); - final float f_c12 = matrix1.get(1, 2); - final float f_c22 = matrix1.get(2, 2); - final float f_c32 = matrix1.get(3, 2); - final float f_c42 = matrix1.get(4, 2); - final float s_c00 = matrix2.get(0, 0); - final float s_c10 = matrix2.get(1, 0); - final float s_c20 = matrix2.get(2, 0); - final float s_c30 = matrix2.get(3, 0); - final float s_c40 = matrix2.get(4, 0); - final float s_c01 = matrix2.get(0, 1); - final float s_c11 = matrix2.get(1, 1); - final float s_c21 = matrix2.get(2, 1); - final float s_c31 = matrix2.get(3, 1); - final float s_c41 = matrix2.get(4, 1); - final float s_c02 = matrix2.get(0, 2); - final float s_c12 = matrix2.get(1, 2); - final float s_c22 = matrix2.get(2, 2); - final float s_c32 = matrix2.get(3, 2); - final float s_c42 = matrix2.get(4, 2); - final float s_c03 = matrix2.get(0, 3); - final float s_c13 = matrix2.get(1, 3); - final float s_c23 = matrix2.get(2, 3); - final float s_c33 = matrix2.get(3, 3); - final float s_c43 = matrix2.get(4, 3); - final float s_c04 = matrix2.get(0, 4); - final float s_c14 = matrix2.get(1, 4); - final float s_c24 = matrix2.get(2, 4); - final float s_c34 = matrix2.get(3, 4); - final float s_c44 = matrix2.get(4, 4); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23 + f_c42*s_c24); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33 + f_c40*s_c34); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33 + f_c41*s_c34); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33 + f_c42*s_c34); - output.set(4, 0, f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42 + f_c30*s_c43 + f_c40*s_c44); - output.set(4, 1, f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42 + f_c31*s_c43 + f_c41*s_c44); - output.set(4, 2, f_c02*s_c40 + f_c12*s_c41 + f_c22*s_c42 + f_c32*s_c43 + f_c42*s_c44); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float f30 = matrix1.get(3, 0); + final float f40 = matrix1.get(4, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f21 = matrix1.get(2, 1); + final float f31 = matrix1.get(3, 1); + final float f41 = matrix1.get(4, 1); + final float f02 = matrix1.get(0, 2); + final float f12 = matrix1.get(1, 2); + final float f22 = matrix1.get(2, 2); + final float f32 = matrix1.get(3, 2); + final float f42 = matrix1.get(4, 2); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + final float s30 = matrix2.get(3, 0); + final float s40 = matrix2.get(4, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s21 = matrix2.get(2, 1); + final float s31 = matrix2.get(3, 1); + final float s41 = matrix2.get(4, 1); + final float s02 = matrix2.get(0, 2); + final float s12 = matrix2.get(1, 2); + final float s22 = matrix2.get(2, 2); + final float s32 = matrix2.get(3, 2); + final float s42 = matrix2.get(4, 2); + final float s03 = matrix2.get(0, 3); + final float s13 = matrix2.get(1, 3); + final float s23 = matrix2.get(2, 3); + final float s33 = matrix2.get(3, 3); + final float s43 = matrix2.get(4, 3); + final float s04 = matrix2.get(0, 4); + final float s14 = matrix2.get(1, 4); + final float s24 = matrix2.get(2, 4); + final float s34 = matrix2.get(3, 4); + final float s44 = matrix2.get(4, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33 + f40 * s34); + output.set(4, 0, f00 * s40 + f10 * s41 + f20 * s42 + f30 * s43 + f40 * s44); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33 + f41 * s34); + output.set(4, 1, f01 * s40 + f11 * s41 + f21 * s42 + f31 * s43 + f41 * s44); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23 + f42 * s24); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33 + f42 * s34); + output.set(4, 2, f02 * s40 + f12 * s41 + f22 * s42 + f32 * s43 + f42 * s44); + return output; + } + + private static IMatrixSetterFloat multiplyMatrix4x5x1(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float f30 = matrix1.get(3, 0); + final float f40 = matrix1.get(4, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f21 = matrix1.get(2, 1); + final float f31 = matrix1.get(3, 1); + final float f41 = matrix1.get(4, 1); + final float f02 = matrix1.get(0, 2); + final float f12 = matrix1.get(1, 2); + final float f22 = matrix1.get(2, 2); + final float f32 = matrix1.get(3, 2); + final float f42 = matrix1.get(4, 2); + final float f03 = matrix1.get(0, 3); + final float f13 = matrix1.get(1, 3); + final float f23 = matrix1.get(2, 3); + final float f33 = matrix1.get(3, 3); + final float f43 = matrix1.get(4, 3); + final float s00 = matrix2.get(0, 0); + final float s01 = matrix2.get(0, 1); + final float s02 = matrix2.get(0, 2); + final float s03 = matrix2.get(0, 3); + final float s04 = matrix2.get(0, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03 + f43 * s04); return output; } private static IMatrixSetterFloat multiplyMatrix4x5x2(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final float f_c00 = matrix1.get(0, 0); - final float f_c10 = matrix1.get(1, 0); - final float f_c20 = matrix1.get(2, 0); - final float f_c30 = matrix1.get(3, 0); - final float f_c40 = matrix1.get(4, 0); - final float f_c01 = matrix1.get(0, 1); - final float f_c11 = matrix1.get(1, 1); - final float f_c21 = matrix1.get(2, 1); - final float f_c31 = matrix1.get(3, 1); - final float f_c41 = matrix1.get(4, 1); - final float f_c02 = matrix1.get(0, 2); - final float f_c12 = matrix1.get(1, 2); - final float f_c22 = matrix1.get(2, 2); - final float f_c32 = matrix1.get(3, 2); - final float f_c42 = matrix1.get(4, 2); - final float f_c03 = matrix1.get(0, 3); - final float f_c13 = matrix1.get(1, 3); - final float f_c23 = matrix1.get(2, 3); - final float f_c33 = matrix1.get(3, 3); - final float f_c43 = matrix1.get(4, 3); - final float s_c00 = matrix2.get(0, 0); - final float s_c10 = matrix2.get(1, 0); - final float s_c01 = matrix2.get(0, 1); - final float s_c11 = matrix2.get(1, 1); - final float s_c02 = matrix2.get(0, 2); - final float s_c12 = matrix2.get(1, 2); - final float s_c03 = matrix2.get(0, 3); - final float s_c13 = matrix2.get(1, 3); - final float s_c04 = matrix2.get(0, 4); - final float s_c14 = matrix2.get(1, 4); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03 + f_c43*s_c04); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13 + f_c43*s_c14); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float f30 = matrix1.get(3, 0); + final float f40 = matrix1.get(4, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f21 = matrix1.get(2, 1); + final float f31 = matrix1.get(3, 1); + final float f41 = matrix1.get(4, 1); + final float f02 = matrix1.get(0, 2); + final float f12 = matrix1.get(1, 2); + final float f22 = matrix1.get(2, 2); + final float f32 = matrix1.get(3, 2); + final float f42 = matrix1.get(4, 2); + final float f03 = matrix1.get(0, 3); + final float f13 = matrix1.get(1, 3); + final float f23 = matrix1.get(2, 3); + final float f33 = matrix1.get(3, 3); + final float f43 = matrix1.get(4, 3); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s02 = matrix2.get(0, 2); + final float s12 = matrix2.get(1, 2); + final float s03 = matrix2.get(0, 3); + final float s13 = matrix2.get(1, 3); + final float s04 = matrix2.get(0, 4); + final float s14 = matrix2.get(1, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03 + f43 * s04); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13 + f43 * s14); return output; } private static IMatrixSetterFloat multiplyMatrix4x5x3(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final float f_c00 = matrix1.get(0, 0); - final float f_c10 = matrix1.get(1, 0); - final float f_c20 = matrix1.get(2, 0); - final float f_c30 = matrix1.get(3, 0); - final float f_c40 = matrix1.get(4, 0); - final float f_c01 = matrix1.get(0, 1); - final float f_c11 = matrix1.get(1, 1); - final float f_c21 = matrix1.get(2, 1); - final float f_c31 = matrix1.get(3, 1); - final float f_c41 = matrix1.get(4, 1); - final float f_c02 = matrix1.get(0, 2); - final float f_c12 = matrix1.get(1, 2); - final float f_c22 = matrix1.get(2, 2); - final float f_c32 = matrix1.get(3, 2); - final float f_c42 = matrix1.get(4, 2); - final float f_c03 = matrix1.get(0, 3); - final float f_c13 = matrix1.get(1, 3); - final float f_c23 = matrix1.get(2, 3); - final float f_c33 = matrix1.get(3, 3); - final float f_c43 = matrix1.get(4, 3); - final float s_c00 = matrix2.get(0, 0); - final float s_c10 = matrix2.get(1, 0); - final float s_c20 = matrix2.get(2, 0); - final float s_c01 = matrix2.get(0, 1); - final float s_c11 = matrix2.get(1, 1); - final float s_c21 = matrix2.get(2, 1); - final float s_c02 = matrix2.get(0, 2); - final float s_c12 = matrix2.get(1, 2); - final float s_c22 = matrix2.get(2, 2); - final float s_c03 = matrix2.get(0, 3); - final float s_c13 = matrix2.get(1, 3); - final float s_c23 = matrix2.get(2, 3); - final float s_c04 = matrix2.get(0, 4); - final float s_c14 = matrix2.get(1, 4); - final float s_c24 = matrix2.get(2, 4); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03 + f_c43*s_c04); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13 + f_c43*s_c14); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23 + f_c42*s_c24); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23 + f_c43*s_c24); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float f30 = matrix1.get(3, 0); + final float f40 = matrix1.get(4, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f21 = matrix1.get(2, 1); + final float f31 = matrix1.get(3, 1); + final float f41 = matrix1.get(4, 1); + final float f02 = matrix1.get(0, 2); + final float f12 = matrix1.get(1, 2); + final float f22 = matrix1.get(2, 2); + final float f32 = matrix1.get(3, 2); + final float f42 = matrix1.get(4, 2); + final float f03 = matrix1.get(0, 3); + final float f13 = matrix1.get(1, 3); + final float f23 = matrix1.get(2, 3); + final float f33 = matrix1.get(3, 3); + final float f43 = matrix1.get(4, 3); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s21 = matrix2.get(2, 1); + final float s02 = matrix2.get(0, 2); + final float s12 = matrix2.get(1, 2); + final float s22 = matrix2.get(2, 2); + final float s03 = matrix2.get(0, 3); + final float s13 = matrix2.get(1, 3); + final float s23 = matrix2.get(2, 3); + final float s04 = matrix2.get(0, 4); + final float s14 = matrix2.get(1, 4); + final float s24 = matrix2.get(2, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23 + f42 * s24); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03 + f43 * s04); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13 + f43 * s14); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23 + f43 * s24); return output; } private static IMatrixSetterFloat multiplyMatrix4x5x4(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final float f_c00 = matrix1.get(0, 0); - final float f_c10 = matrix1.get(1, 0); - final float f_c20 = matrix1.get(2, 0); - final float f_c30 = matrix1.get(3, 0); - final float f_c40 = matrix1.get(4, 0); - final float f_c01 = matrix1.get(0, 1); - final float f_c11 = matrix1.get(1, 1); - final float f_c21 = matrix1.get(2, 1); - final float f_c31 = matrix1.get(3, 1); - final float f_c41 = matrix1.get(4, 1); - final float f_c02 = matrix1.get(0, 2); - final float f_c12 = matrix1.get(1, 2); - final float f_c22 = matrix1.get(2, 2); - final float f_c32 = matrix1.get(3, 2); - final float f_c42 = matrix1.get(4, 2); - final float f_c03 = matrix1.get(0, 3); - final float f_c13 = matrix1.get(1, 3); - final float f_c23 = matrix1.get(2, 3); - final float f_c33 = matrix1.get(3, 3); - final float f_c43 = matrix1.get(4, 3); - final float s_c00 = matrix2.get(0, 0); - final float s_c10 = matrix2.get(1, 0); - final float s_c20 = matrix2.get(2, 0); - final float s_c30 = matrix2.get(3, 0); - final float s_c01 = matrix2.get(0, 1); - final float s_c11 = matrix2.get(1, 1); - final float s_c21 = matrix2.get(2, 1); - final float s_c31 = matrix2.get(3, 1); - final float s_c02 = matrix2.get(0, 2); - final float s_c12 = matrix2.get(1, 2); - final float s_c22 = matrix2.get(2, 2); - final float s_c32 = matrix2.get(3, 2); - final float s_c03 = matrix2.get(0, 3); - final float s_c13 = matrix2.get(1, 3); - final float s_c23 = matrix2.get(2, 3); - final float s_c33 = matrix2.get(3, 3); - final float s_c04 = matrix2.get(0, 4); - final float s_c14 = matrix2.get(1, 4); - final float s_c24 = matrix2.get(2, 4); - final float s_c34 = matrix2.get(3, 4); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03 + f_c43*s_c04); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13 + f_c43*s_c14); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23 + f_c42*s_c24); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23 + f_c43*s_c24); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33 + f_c40*s_c34); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33 + f_c41*s_c34); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33 + f_c42*s_c34); - output.set(3, 3, f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32 + f_c33*s_c33 + f_c43*s_c34); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float f30 = matrix1.get(3, 0); + final float f40 = matrix1.get(4, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f21 = matrix1.get(2, 1); + final float f31 = matrix1.get(3, 1); + final float f41 = matrix1.get(4, 1); + final float f02 = matrix1.get(0, 2); + final float f12 = matrix1.get(1, 2); + final float f22 = matrix1.get(2, 2); + final float f32 = matrix1.get(3, 2); + final float f42 = matrix1.get(4, 2); + final float f03 = matrix1.get(0, 3); + final float f13 = matrix1.get(1, 3); + final float f23 = matrix1.get(2, 3); + final float f33 = matrix1.get(3, 3); + final float f43 = matrix1.get(4, 3); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + final float s30 = matrix2.get(3, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s21 = matrix2.get(2, 1); + final float s31 = matrix2.get(3, 1); + final float s02 = matrix2.get(0, 2); + final float s12 = matrix2.get(1, 2); + final float s22 = matrix2.get(2, 2); + final float s32 = matrix2.get(3, 2); + final float s03 = matrix2.get(0, 3); + final float s13 = matrix2.get(1, 3); + final float s23 = matrix2.get(2, 3); + final float s33 = matrix2.get(3, 3); + final float s04 = matrix2.get(0, 4); + final float s14 = matrix2.get(1, 4); + final float s24 = matrix2.get(2, 4); + final float s34 = matrix2.get(3, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33 + f40 * s34); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33 + f41 * s34); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23 + f42 * s24); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33 + f42 * s34); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03 + f43 * s04); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13 + f43 * s14); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23 + f43 * s24); + output.set(3, 3, f03 * s30 + f13 * s31 + f23 * s32 + f33 * s33 + f43 * s34); return output; } private static IMatrixSetterFloat multiplyMatrix4x5x5(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final float f_c00 = matrix1.get(0, 0); - final float f_c10 = matrix1.get(1, 0); - final float f_c20 = matrix1.get(2, 0); - final float f_c30 = matrix1.get(3, 0); - final float f_c40 = matrix1.get(4, 0); - final float f_c01 = matrix1.get(0, 1); - final float f_c11 = matrix1.get(1, 1); - final float f_c21 = matrix1.get(2, 1); - final float f_c31 = matrix1.get(3, 1); - final float f_c41 = matrix1.get(4, 1); - final float f_c02 = matrix1.get(0, 2); - final float f_c12 = matrix1.get(1, 2); - final float f_c22 = matrix1.get(2, 2); - final float f_c32 = matrix1.get(3, 2); - final float f_c42 = matrix1.get(4, 2); - final float f_c03 = matrix1.get(0, 3); - final float f_c13 = matrix1.get(1, 3); - final float f_c23 = matrix1.get(2, 3); - final float f_c33 = matrix1.get(3, 3); - final float f_c43 = matrix1.get(4, 3); - final float s_c00 = matrix2.get(0, 0); - final float s_c10 = matrix2.get(1, 0); - final float s_c20 = matrix2.get(2, 0); - final float s_c30 = matrix2.get(3, 0); - final float s_c40 = matrix2.get(4, 0); - final float s_c01 = matrix2.get(0, 1); - final float s_c11 = matrix2.get(1, 1); - final float s_c21 = matrix2.get(2, 1); - final float s_c31 = matrix2.get(3, 1); - final float s_c41 = matrix2.get(4, 1); - final float s_c02 = matrix2.get(0, 2); - final float s_c12 = matrix2.get(1, 2); - final float s_c22 = matrix2.get(2, 2); - final float s_c32 = matrix2.get(3, 2); - final float s_c42 = matrix2.get(4, 2); - final float s_c03 = matrix2.get(0, 3); - final float s_c13 = matrix2.get(1, 3); - final float s_c23 = matrix2.get(2, 3); - final float s_c33 = matrix2.get(3, 3); - final float s_c43 = matrix2.get(4, 3); - final float s_c04 = matrix2.get(0, 4); - final float s_c14 = matrix2.get(1, 4); - final float s_c24 = matrix2.get(2, 4); - final float s_c34 = matrix2.get(3, 4); - final float s_c44 = matrix2.get(4, 4); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03 + f_c43*s_c04); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13 + f_c43*s_c14); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23 + f_c42*s_c24); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23 + f_c43*s_c24); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33 + f_c40*s_c34); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33 + f_c41*s_c34); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33 + f_c42*s_c34); - output.set(3, 3, f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32 + f_c33*s_c33 + f_c43*s_c34); - output.set(4, 0, f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42 + f_c30*s_c43 + f_c40*s_c44); - output.set(4, 1, f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42 + f_c31*s_c43 + f_c41*s_c44); - output.set(4, 2, f_c02*s_c40 + f_c12*s_c41 + f_c22*s_c42 + f_c32*s_c43 + f_c42*s_c44); - output.set(4, 3, f_c03*s_c40 + f_c13*s_c41 + f_c23*s_c42 + f_c33*s_c43 + f_c43*s_c44); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float f30 = matrix1.get(3, 0); + final float f40 = matrix1.get(4, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f21 = matrix1.get(2, 1); + final float f31 = matrix1.get(3, 1); + final float f41 = matrix1.get(4, 1); + final float f02 = matrix1.get(0, 2); + final float f12 = matrix1.get(1, 2); + final float f22 = matrix1.get(2, 2); + final float f32 = matrix1.get(3, 2); + final float f42 = matrix1.get(4, 2); + final float f03 = matrix1.get(0, 3); + final float f13 = matrix1.get(1, 3); + final float f23 = matrix1.get(2, 3); + final float f33 = matrix1.get(3, 3); + final float f43 = matrix1.get(4, 3); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + final float s30 = matrix2.get(3, 0); + final float s40 = matrix2.get(4, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s21 = matrix2.get(2, 1); + final float s31 = matrix2.get(3, 1); + final float s41 = matrix2.get(4, 1); + final float s02 = matrix2.get(0, 2); + final float s12 = matrix2.get(1, 2); + final float s22 = matrix2.get(2, 2); + final float s32 = matrix2.get(3, 2); + final float s42 = matrix2.get(4, 2); + final float s03 = matrix2.get(0, 3); + final float s13 = matrix2.get(1, 3); + final float s23 = matrix2.get(2, 3); + final float s33 = matrix2.get(3, 3); + final float s43 = matrix2.get(4, 3); + final float s04 = matrix2.get(0, 4); + final float s14 = matrix2.get(1, 4); + final float s24 = matrix2.get(2, 4); + final float s34 = matrix2.get(3, 4); + final float s44 = matrix2.get(4, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33 + f40 * s34); + output.set(4, 0, f00 * s40 + f10 * s41 + f20 * s42 + f30 * s43 + f40 * s44); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33 + f41 * s34); + output.set(4, 1, f01 * s40 + f11 * s41 + f21 * s42 + f31 * s43 + f41 * s44); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23 + f42 * s24); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33 + f42 * s34); + output.set(4, 2, f02 * s40 + f12 * s41 + f22 * s42 + f32 * s43 + f42 * s44); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03 + f43 * s04); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13 + f43 * s14); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23 + f43 * s24); + output.set(3, 3, f03 * s30 + f13 * s31 + f23 * s32 + f33 * s33 + f43 * s34); + output.set(4, 3, f03 * s40 + f13 * s41 + f23 * s42 + f33 * s43 + f43 * s44); + return output; + } + + private static IMatrixSetterFloat multiplyMatrix5x5x1(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float f30 = matrix1.get(3, 0); + final float f40 = matrix1.get(4, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f21 = matrix1.get(2, 1); + final float f31 = matrix1.get(3, 1); + final float f41 = matrix1.get(4, 1); + final float f02 = matrix1.get(0, 2); + final float f12 = matrix1.get(1, 2); + final float f22 = matrix1.get(2, 2); + final float f32 = matrix1.get(3, 2); + final float f42 = matrix1.get(4, 2); + final float f03 = matrix1.get(0, 3); + final float f13 = matrix1.get(1, 3); + final float f23 = matrix1.get(2, 3); + final float f33 = matrix1.get(3, 3); + final float f43 = matrix1.get(4, 3); + final float f04 = matrix1.get(0, 4); + final float f14 = matrix1.get(1, 4); + final float f24 = matrix1.get(2, 4); + final float f34 = matrix1.get(3, 4); + final float f44 = matrix1.get(4, 4); + final float s00 = matrix2.get(0, 0); + final float s01 = matrix2.get(0, 1); + final float s02 = matrix2.get(0, 2); + final float s03 = matrix2.get(0, 3); + final float s04 = matrix2.get(0, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03 + f43 * s04); + output.set(0, 4, f04 * s00 + f14 * s01 + f24 * s02 + f34 * s03 + f44 * s04); return output; } private static IMatrixSetterFloat multiplyMatrix5x5x2(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final float f_c00 = matrix1.get(0, 0); - final float f_c10 = matrix1.get(1, 0); - final float f_c20 = matrix1.get(2, 0); - final float f_c30 = matrix1.get(3, 0); - final float f_c40 = matrix1.get(4, 0); - final float f_c01 = matrix1.get(0, 1); - final float f_c11 = matrix1.get(1, 1); - final float f_c21 = matrix1.get(2, 1); - final float f_c31 = matrix1.get(3, 1); - final float f_c41 = matrix1.get(4, 1); - final float f_c02 = matrix1.get(0, 2); - final float f_c12 = matrix1.get(1, 2); - final float f_c22 = matrix1.get(2, 2); - final float f_c32 = matrix1.get(3, 2); - final float f_c42 = matrix1.get(4, 2); - final float f_c03 = matrix1.get(0, 3); - final float f_c13 = matrix1.get(1, 3); - final float f_c23 = matrix1.get(2, 3); - final float f_c33 = matrix1.get(3, 3); - final float f_c43 = matrix1.get(4, 3); - final float f_c04 = matrix1.get(0, 4); - final float f_c14 = matrix1.get(1, 4); - final float f_c24 = matrix1.get(2, 4); - final float f_c34 = matrix1.get(3, 4); - final float f_c44 = matrix1.get(4, 4); - final float s_c00 = matrix2.get(0, 0); - final float s_c10 = matrix2.get(1, 0); - final float s_c01 = matrix2.get(0, 1); - final float s_c11 = matrix2.get(1, 1); - final float s_c02 = matrix2.get(0, 2); - final float s_c12 = matrix2.get(1, 2); - final float s_c03 = matrix2.get(0, 3); - final float s_c13 = matrix2.get(1, 3); - final float s_c04 = matrix2.get(0, 4); - final float s_c14 = matrix2.get(1, 4); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03 + f_c43*s_c04); - output.set(0, 4, f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02 + f_c34*s_c03 + f_c44*s_c04); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13 + f_c43*s_c14); - output.set(1, 4, f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12 + f_c34*s_c13 + f_c44*s_c14); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float f30 = matrix1.get(3, 0); + final float f40 = matrix1.get(4, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f21 = matrix1.get(2, 1); + final float f31 = matrix1.get(3, 1); + final float f41 = matrix1.get(4, 1); + final float f02 = matrix1.get(0, 2); + final float f12 = matrix1.get(1, 2); + final float f22 = matrix1.get(2, 2); + final float f32 = matrix1.get(3, 2); + final float f42 = matrix1.get(4, 2); + final float f03 = matrix1.get(0, 3); + final float f13 = matrix1.get(1, 3); + final float f23 = matrix1.get(2, 3); + final float f33 = matrix1.get(3, 3); + final float f43 = matrix1.get(4, 3); + final float f04 = matrix1.get(0, 4); + final float f14 = matrix1.get(1, 4); + final float f24 = matrix1.get(2, 4); + final float f34 = matrix1.get(3, 4); + final float f44 = matrix1.get(4, 4); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s02 = matrix2.get(0, 2); + final float s12 = matrix2.get(1, 2); + final float s03 = matrix2.get(0, 3); + final float s13 = matrix2.get(1, 3); + final float s04 = matrix2.get(0, 4); + final float s14 = matrix2.get(1, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03 + f43 * s04); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13 + f43 * s14); + output.set(0, 4, f04 * s00 + f14 * s01 + f24 * s02 + f34 * s03 + f44 * s04); + output.set(1, 4, f04 * s10 + f14 * s11 + f24 * s12 + f34 * s13 + f44 * s14); return output; } private static IMatrixSetterFloat multiplyMatrix5x5x3(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final float f_c00 = matrix1.get(0, 0); - final float f_c10 = matrix1.get(1, 0); - final float f_c20 = matrix1.get(2, 0); - final float f_c30 = matrix1.get(3, 0); - final float f_c40 = matrix1.get(4, 0); - final float f_c01 = matrix1.get(0, 1); - final float f_c11 = matrix1.get(1, 1); - final float f_c21 = matrix1.get(2, 1); - final float f_c31 = matrix1.get(3, 1); - final float f_c41 = matrix1.get(4, 1); - final float f_c02 = matrix1.get(0, 2); - final float f_c12 = matrix1.get(1, 2); - final float f_c22 = matrix1.get(2, 2); - final float f_c32 = matrix1.get(3, 2); - final float f_c42 = matrix1.get(4, 2); - final float f_c03 = matrix1.get(0, 3); - final float f_c13 = matrix1.get(1, 3); - final float f_c23 = matrix1.get(2, 3); - final float f_c33 = matrix1.get(3, 3); - final float f_c43 = matrix1.get(4, 3); - final float f_c04 = matrix1.get(0, 4); - final float f_c14 = matrix1.get(1, 4); - final float f_c24 = matrix1.get(2, 4); - final float f_c34 = matrix1.get(3, 4); - final float f_c44 = matrix1.get(4, 4); - final float s_c00 = matrix2.get(0, 0); - final float s_c10 = matrix2.get(1, 0); - final float s_c20 = matrix2.get(2, 0); - final float s_c01 = matrix2.get(0, 1); - final float s_c11 = matrix2.get(1, 1); - final float s_c21 = matrix2.get(2, 1); - final float s_c02 = matrix2.get(0, 2); - final float s_c12 = matrix2.get(1, 2); - final float s_c22 = matrix2.get(2, 2); - final float s_c03 = matrix2.get(0, 3); - final float s_c13 = matrix2.get(1, 3); - final float s_c23 = matrix2.get(2, 3); - final float s_c04 = matrix2.get(0, 4); - final float s_c14 = matrix2.get(1, 4); - final float s_c24 = matrix2.get(2, 4); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03 + f_c43*s_c04); - output.set(0, 4, f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02 + f_c34*s_c03 + f_c44*s_c04); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13 + f_c43*s_c14); - output.set(1, 4, f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12 + f_c34*s_c13 + f_c44*s_c14); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23 + f_c42*s_c24); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23 + f_c43*s_c24); - output.set(2, 4, f_c04*s_c20 + f_c14*s_c21 + f_c24*s_c22 + f_c34*s_c23 + f_c44*s_c24); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float f30 = matrix1.get(3, 0); + final float f40 = matrix1.get(4, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f21 = matrix1.get(2, 1); + final float f31 = matrix1.get(3, 1); + final float f41 = matrix1.get(4, 1); + final float f02 = matrix1.get(0, 2); + final float f12 = matrix1.get(1, 2); + final float f22 = matrix1.get(2, 2); + final float f32 = matrix1.get(3, 2); + final float f42 = matrix1.get(4, 2); + final float f03 = matrix1.get(0, 3); + final float f13 = matrix1.get(1, 3); + final float f23 = matrix1.get(2, 3); + final float f33 = matrix1.get(3, 3); + final float f43 = matrix1.get(4, 3); + final float f04 = matrix1.get(0, 4); + final float f14 = matrix1.get(1, 4); + final float f24 = matrix1.get(2, 4); + final float f34 = matrix1.get(3, 4); + final float f44 = matrix1.get(4, 4); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s21 = matrix2.get(2, 1); + final float s02 = matrix2.get(0, 2); + final float s12 = matrix2.get(1, 2); + final float s22 = matrix2.get(2, 2); + final float s03 = matrix2.get(0, 3); + final float s13 = matrix2.get(1, 3); + final float s23 = matrix2.get(2, 3); + final float s04 = matrix2.get(0, 4); + final float s14 = matrix2.get(1, 4); + final float s24 = matrix2.get(2, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23 + f42 * s24); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03 + f43 * s04); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13 + f43 * s14); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23 + f43 * s24); + output.set(0, 4, f04 * s00 + f14 * s01 + f24 * s02 + f34 * s03 + f44 * s04); + output.set(1, 4, f04 * s10 + f14 * s11 + f24 * s12 + f34 * s13 + f44 * s14); + output.set(2, 4, f04 * s20 + f14 * s21 + f24 * s22 + f34 * s23 + f44 * s24); return output; } private static IMatrixSetterFloat multiplyMatrix5x5x4(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final float f_c00 = matrix1.get(0, 0); - final float f_c10 = matrix1.get(1, 0); - final float f_c20 = matrix1.get(2, 0); - final float f_c30 = matrix1.get(3, 0); - final float f_c40 = matrix1.get(4, 0); - final float f_c01 = matrix1.get(0, 1); - final float f_c11 = matrix1.get(1, 1); - final float f_c21 = matrix1.get(2, 1); - final float f_c31 = matrix1.get(3, 1); - final float f_c41 = matrix1.get(4, 1); - final float f_c02 = matrix1.get(0, 2); - final float f_c12 = matrix1.get(1, 2); - final float f_c22 = matrix1.get(2, 2); - final float f_c32 = matrix1.get(3, 2); - final float f_c42 = matrix1.get(4, 2); - final float f_c03 = matrix1.get(0, 3); - final float f_c13 = matrix1.get(1, 3); - final float f_c23 = matrix1.get(2, 3); - final float f_c33 = matrix1.get(3, 3); - final float f_c43 = matrix1.get(4, 3); - final float f_c04 = matrix1.get(0, 4); - final float f_c14 = matrix1.get(1, 4); - final float f_c24 = matrix1.get(2, 4); - final float f_c34 = matrix1.get(3, 4); - final float f_c44 = matrix1.get(4, 4); - final float s_c00 = matrix2.get(0, 0); - final float s_c10 = matrix2.get(1, 0); - final float s_c20 = matrix2.get(2, 0); - final float s_c30 = matrix2.get(3, 0); - final float s_c01 = matrix2.get(0, 1); - final float s_c11 = matrix2.get(1, 1); - final float s_c21 = matrix2.get(2, 1); - final float s_c31 = matrix2.get(3, 1); - final float s_c02 = matrix2.get(0, 2); - final float s_c12 = matrix2.get(1, 2); - final float s_c22 = matrix2.get(2, 2); - final float s_c32 = matrix2.get(3, 2); - final float s_c03 = matrix2.get(0, 3); - final float s_c13 = matrix2.get(1, 3); - final float s_c23 = matrix2.get(2, 3); - final float s_c33 = matrix2.get(3, 3); - final float s_c04 = matrix2.get(0, 4); - final float s_c14 = matrix2.get(1, 4); - final float s_c24 = matrix2.get(2, 4); - final float s_c34 = matrix2.get(3, 4); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03 + f_c43*s_c04); - output.set(0, 4, f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02 + f_c34*s_c03 + f_c44*s_c04); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13 + f_c43*s_c14); - output.set(1, 4, f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12 + f_c34*s_c13 + f_c44*s_c14); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23 + f_c42*s_c24); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23 + f_c43*s_c24); - output.set(2, 4, f_c04*s_c20 + f_c14*s_c21 + f_c24*s_c22 + f_c34*s_c23 + f_c44*s_c24); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33 + f_c40*s_c34); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33 + f_c41*s_c34); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33 + f_c42*s_c34); - output.set(3, 3, f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32 + f_c33*s_c33 + f_c43*s_c34); - output.set(3, 4, f_c04*s_c30 + f_c14*s_c31 + f_c24*s_c32 + f_c34*s_c33 + f_c44*s_c34); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float f30 = matrix1.get(3, 0); + final float f40 = matrix1.get(4, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f21 = matrix1.get(2, 1); + final float f31 = matrix1.get(3, 1); + final float f41 = matrix1.get(4, 1); + final float f02 = matrix1.get(0, 2); + final float f12 = matrix1.get(1, 2); + final float f22 = matrix1.get(2, 2); + final float f32 = matrix1.get(3, 2); + final float f42 = matrix1.get(4, 2); + final float f03 = matrix1.get(0, 3); + final float f13 = matrix1.get(1, 3); + final float f23 = matrix1.get(2, 3); + final float f33 = matrix1.get(3, 3); + final float f43 = matrix1.get(4, 3); + final float f04 = matrix1.get(0, 4); + final float f14 = matrix1.get(1, 4); + final float f24 = matrix1.get(2, 4); + final float f34 = matrix1.get(3, 4); + final float f44 = matrix1.get(4, 4); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + final float s30 = matrix2.get(3, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s21 = matrix2.get(2, 1); + final float s31 = matrix2.get(3, 1); + final float s02 = matrix2.get(0, 2); + final float s12 = matrix2.get(1, 2); + final float s22 = matrix2.get(2, 2); + final float s32 = matrix2.get(3, 2); + final float s03 = matrix2.get(0, 3); + final float s13 = matrix2.get(1, 3); + final float s23 = matrix2.get(2, 3); + final float s33 = matrix2.get(3, 3); + final float s04 = matrix2.get(0, 4); + final float s14 = matrix2.get(1, 4); + final float s24 = matrix2.get(2, 4); + final float s34 = matrix2.get(3, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33 + f40 * s34); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33 + f41 * s34); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23 + f42 * s24); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33 + f42 * s34); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03 + f43 * s04); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13 + f43 * s14); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23 + f43 * s24); + output.set(3, 3, f03 * s30 + f13 * s31 + f23 * s32 + f33 * s33 + f43 * s34); + output.set(0, 4, f04 * s00 + f14 * s01 + f24 * s02 + f34 * s03 + f44 * s04); + output.set(1, 4, f04 * s10 + f14 * s11 + f24 * s12 + f34 * s13 + f44 * s14); + output.set(2, 4, f04 * s20 + f14 * s21 + f24 * s22 + f34 * s23 + f44 * s24); + output.set(3, 4, f04 * s30 + f14 * s31 + f24 * s32 + f34 * s33 + f44 * s34); return output; } private static IMatrixSetterFloat multiplyMatrix5x5x5(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final float f_c00 = matrix1.get(0, 0); - final float f_c10 = matrix1.get(1, 0); - final float f_c20 = matrix1.get(2, 0); - final float f_c30 = matrix1.get(3, 0); - final float f_c40 = matrix1.get(4, 0); - final float f_c01 = matrix1.get(0, 1); - final float f_c11 = matrix1.get(1, 1); - final float f_c21 = matrix1.get(2, 1); - final float f_c31 = matrix1.get(3, 1); - final float f_c41 = matrix1.get(4, 1); - final float f_c02 = matrix1.get(0, 2); - final float f_c12 = matrix1.get(1, 2); - final float f_c22 = matrix1.get(2, 2); - final float f_c32 = matrix1.get(3, 2); - final float f_c42 = matrix1.get(4, 2); - final float f_c03 = matrix1.get(0, 3); - final float f_c13 = matrix1.get(1, 3); - final float f_c23 = matrix1.get(2, 3); - final float f_c33 = matrix1.get(3, 3); - final float f_c43 = matrix1.get(4, 3); - final float f_c04 = matrix1.get(0, 4); - final float f_c14 = matrix1.get(1, 4); - final float f_c24 = matrix1.get(2, 4); - final float f_c34 = matrix1.get(3, 4); - final float f_c44 = matrix1.get(4, 4); - final float s_c00 = matrix2.get(0, 0); - final float s_c10 = matrix2.get(1, 0); - final float s_c20 = matrix2.get(2, 0); - final float s_c30 = matrix2.get(3, 0); - final float s_c40 = matrix2.get(4, 0); - final float s_c01 = matrix2.get(0, 1); - final float s_c11 = matrix2.get(1, 1); - final float s_c21 = matrix2.get(2, 1); - final float s_c31 = matrix2.get(3, 1); - final float s_c41 = matrix2.get(4, 1); - final float s_c02 = matrix2.get(0, 2); - final float s_c12 = matrix2.get(1, 2); - final float s_c22 = matrix2.get(2, 2); - final float s_c32 = matrix2.get(3, 2); - final float s_c42 = matrix2.get(4, 2); - final float s_c03 = matrix2.get(0, 3); - final float s_c13 = matrix2.get(1, 3); - final float s_c23 = matrix2.get(2, 3); - final float s_c33 = matrix2.get(3, 3); - final float s_c43 = matrix2.get(4, 3); - final float s_c04 = matrix2.get(0, 4); - final float s_c14 = matrix2.get(1, 4); - final float s_c24 = matrix2.get(2, 4); - final float s_c34 = matrix2.get(3, 4); - final float s_c44 = matrix2.get(4, 4); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03 + f_c43*s_c04); - output.set(0, 4, f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02 + f_c34*s_c03 + f_c44*s_c04); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13 + f_c43*s_c14); - output.set(1, 4, f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12 + f_c34*s_c13 + f_c44*s_c14); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23 + f_c42*s_c24); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23 + f_c43*s_c24); - output.set(2, 4, f_c04*s_c20 + f_c14*s_c21 + f_c24*s_c22 + f_c34*s_c23 + f_c44*s_c24); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33 + f_c40*s_c34); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33 + f_c41*s_c34); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33 + f_c42*s_c34); - output.set(3, 3, f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32 + f_c33*s_c33 + f_c43*s_c34); - output.set(3, 4, f_c04*s_c30 + f_c14*s_c31 + f_c24*s_c32 + f_c34*s_c33 + f_c44*s_c34); - output.set(4, 0, f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42 + f_c30*s_c43 + f_c40*s_c44); - output.set(4, 1, f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42 + f_c31*s_c43 + f_c41*s_c44); - output.set(4, 2, f_c02*s_c40 + f_c12*s_c41 + f_c22*s_c42 + f_c32*s_c43 + f_c42*s_c44); - output.set(4, 3, f_c03*s_c40 + f_c13*s_c41 + f_c23*s_c42 + f_c33*s_c43 + f_c43*s_c44); - output.set(4, 4, f_c04*s_c40 + f_c14*s_c41 + f_c24*s_c42 + f_c34*s_c43 + f_c44*s_c44); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final float f00 = matrix1.get(0, 0); + final float f10 = matrix1.get(1, 0); + final float f20 = matrix1.get(2, 0); + final float f30 = matrix1.get(3, 0); + final float f40 = matrix1.get(4, 0); + final float f01 = matrix1.get(0, 1); + final float f11 = matrix1.get(1, 1); + final float f21 = matrix1.get(2, 1); + final float f31 = matrix1.get(3, 1); + final float f41 = matrix1.get(4, 1); + final float f02 = matrix1.get(0, 2); + final float f12 = matrix1.get(1, 2); + final float f22 = matrix1.get(2, 2); + final float f32 = matrix1.get(3, 2); + final float f42 = matrix1.get(4, 2); + final float f03 = matrix1.get(0, 3); + final float f13 = matrix1.get(1, 3); + final float f23 = matrix1.get(2, 3); + final float f33 = matrix1.get(3, 3); + final float f43 = matrix1.get(4, 3); + final float f04 = matrix1.get(0, 4); + final float f14 = matrix1.get(1, 4); + final float f24 = matrix1.get(2, 4); + final float f34 = matrix1.get(3, 4); + final float f44 = matrix1.get(4, 4); + final float s00 = matrix2.get(0, 0); + final float s10 = matrix2.get(1, 0); + final float s20 = matrix2.get(2, 0); + final float s30 = matrix2.get(3, 0); + final float s40 = matrix2.get(4, 0); + final float s01 = matrix2.get(0, 1); + final float s11 = matrix2.get(1, 1); + final float s21 = matrix2.get(2, 1); + final float s31 = matrix2.get(3, 1); + final float s41 = matrix2.get(4, 1); + final float s02 = matrix2.get(0, 2); + final float s12 = matrix2.get(1, 2); + final float s22 = matrix2.get(2, 2); + final float s32 = matrix2.get(3, 2); + final float s42 = matrix2.get(4, 2); + final float s03 = matrix2.get(0, 3); + final float s13 = matrix2.get(1, 3); + final float s23 = matrix2.get(2, 3); + final float s33 = matrix2.get(3, 3); + final float s43 = matrix2.get(4, 3); + final float s04 = matrix2.get(0, 4); + final float s14 = matrix2.get(1, 4); + final float s24 = matrix2.get(2, 4); + final float s34 = matrix2.get(3, 4); + final float s44 = matrix2.get(4, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33 + f40 * s34); + output.set(4, 0, f00 * s40 + f10 * s41 + f20 * s42 + f30 * s43 + f40 * s44); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33 + f41 * s34); + output.set(4, 1, f01 * s40 + f11 * s41 + f21 * s42 + f31 * s43 + f41 * s44); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23 + f42 * s24); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33 + f42 * s34); + output.set(4, 2, f02 * s40 + f12 * s41 + f22 * s42 + f32 * s43 + f42 * s44); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03 + f43 * s04); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13 + f43 * s14); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23 + f43 * s24); + output.set(3, 3, f03 * s30 + f13 * s31 + f23 * s32 + f33 * s33 + f43 * s34); + output.set(4, 3, f03 * s40 + f13 * s41 + f23 * s42 + f33 * s43 + f43 * s44); + output.set(0, 4, f04 * s00 + f14 * s01 + f24 * s02 + f34 * s03 + f44 * s04); + output.set(1, 4, f04 * s10 + f14 * s11 + f24 * s12 + f34 * s13 + f44 * s14); + output.set(2, 4, f04 * s20 + f14 * s21 + f24 * s22 + f34 * s23 + f44 * s24); + output.set(3, 4, f04 * s30 + f14 * s31 + f24 * s32 + f34 * s33 + f44 * s34); + output.set(4, 4, f04 * s40 + f14 * s41 + f24 * s42 + f34 * s43 + f44 * s44); return output; } /** * Automatically generated concrete matrix multiplication. If no mapping exist, this method returns null. * - * @return new Float2Dimensional + * @return new Float2Dimensional */ - @org.jetbrains.annotations.Nullable - public static Float2Dimensional multiplyMatrix(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2) { + @org.jetbrains.annotations.Nullable + public static Float2Dimensional multiplyMatrix(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2) { if (matrix1.getColumns() != matrix2.getRows()) return null; - switch (matrix1.getColumns()) { - case 2: switch (matrix1.getRows()) { - case 2: switch (matrix2.getColumns()) { + switch(matrix1.getColumns()) { + case 1: switch(matrix1.getRows()) { + case 1: switch(matrix2.getColumns()) { + case 1: return (Float2Dimensional) multiplyMatrix1x1x1(matrix1, matrix2, new Float2Dimensional(1, 1)); + case 2: return (Float2Dimensional) multiplyMatrix1x1x2(matrix1, matrix2, new Float2Dimensional(2, 1)); + case 3: return (Float2Dimensional) multiplyMatrix1x1x3(matrix1, matrix2, new Float2Dimensional(3, 1)); + case 4: return (Float2Dimensional) multiplyMatrix1x1x4(matrix1, matrix2, new Float2Dimensional(4, 1)); + case 5: return (Float2Dimensional) multiplyMatrix1x1x5(matrix1, matrix2, new Float2Dimensional(5, 1)); + default: return null; + } + case 2: switch(matrix2.getColumns()) { + case 1: return (Float2Dimensional) multiplyMatrix2x1x1(matrix1, matrix2, new Float2Dimensional(1, 2)); + case 2: return (Float2Dimensional) multiplyMatrix2x1x2(matrix1, matrix2, new Float2Dimensional(2, 2)); + case 3: return (Float2Dimensional) multiplyMatrix2x1x3(matrix1, matrix2, new Float2Dimensional(3, 2)); + case 4: return (Float2Dimensional) multiplyMatrix2x1x4(matrix1, matrix2, new Float2Dimensional(4, 2)); + case 5: return (Float2Dimensional) multiplyMatrix2x1x5(matrix1, matrix2, new Float2Dimensional(5, 2)); + default: return null; + } + case 3: switch(matrix2.getColumns()) { + case 1: return (Float2Dimensional) multiplyMatrix3x1x1(matrix1, matrix2, new Float2Dimensional(1, 3)); + case 2: return (Float2Dimensional) multiplyMatrix3x1x2(matrix1, matrix2, new Float2Dimensional(2, 3)); + case 3: return (Float2Dimensional) multiplyMatrix3x1x3(matrix1, matrix2, new Float2Dimensional(3, 3)); + case 4: return (Float2Dimensional) multiplyMatrix3x1x4(matrix1, matrix2, new Float2Dimensional(4, 3)); + case 5: return (Float2Dimensional) multiplyMatrix3x1x5(matrix1, matrix2, new Float2Dimensional(5, 3)); + default: return null; + } + case 4: switch(matrix2.getColumns()) { + case 1: return (Float2Dimensional) multiplyMatrix4x1x1(matrix1, matrix2, new Float2Dimensional(1, 4)); + case 2: return (Float2Dimensional) multiplyMatrix4x1x2(matrix1, matrix2, new Float2Dimensional(2, 4)); + case 3: return (Float2Dimensional) multiplyMatrix4x1x3(matrix1, matrix2, new Float2Dimensional(3, 4)); + case 4: return (Float2Dimensional) multiplyMatrix4x1x4(matrix1, matrix2, new Float2Dimensional(4, 4)); + case 5: return (Float2Dimensional) multiplyMatrix4x1x5(matrix1, matrix2, new Float2Dimensional(5, 4)); + default: return null; + } + case 5: switch(matrix2.getColumns()) { + case 1: return (Float2Dimensional) multiplyMatrix5x1x1(matrix1, matrix2, new Float2Dimensional(1, 5)); + case 2: return (Float2Dimensional) multiplyMatrix5x1x2(matrix1, matrix2, new Float2Dimensional(2, 5)); + case 3: return (Float2Dimensional) multiplyMatrix5x1x3(matrix1, matrix2, new Float2Dimensional(3, 5)); + case 4: return (Float2Dimensional) multiplyMatrix5x1x4(matrix1, matrix2, new Float2Dimensional(4, 5)); + case 5: return (Float2Dimensional) multiplyMatrix5x1x5(matrix1, matrix2, new Float2Dimensional(5, 5)); + default: return null; + } + default: return null; + } + case 2: switch(matrix1.getRows()) { + case 1: switch(matrix2.getColumns()) { + case 1: return (Float2Dimensional) multiplyMatrix1x2x1(matrix1, matrix2, new Float2Dimensional(1, 1)); + case 2: return (Float2Dimensional) multiplyMatrix1x2x2(matrix1, matrix2, new Float2Dimensional(2, 1)); + case 3: return (Float2Dimensional) multiplyMatrix1x2x3(matrix1, matrix2, new Float2Dimensional(3, 1)); + case 4: return (Float2Dimensional) multiplyMatrix1x2x4(matrix1, matrix2, new Float2Dimensional(4, 1)); + case 5: return (Float2Dimensional) multiplyMatrix1x2x5(matrix1, matrix2, new Float2Dimensional(5, 1)); + default: return null; + } + case 2: switch(matrix2.getColumns()) { + case 1: return (Float2Dimensional) multiplyMatrix2x2x1(matrix1, matrix2, new Float2Dimensional(1, 2)); case 2: return (Float2Dimensional) multiplyMatrix2x2x2(matrix1, matrix2, new Float2Dimensional(2, 2)); case 3: return (Float2Dimensional) multiplyMatrix2x2x3(matrix1, matrix2, new Float2Dimensional(3, 2)); case 4: return (Float2Dimensional) multiplyMatrix2x2x4(matrix1, matrix2, new Float2Dimensional(4, 2)); case 5: return (Float2Dimensional) multiplyMatrix2x2x5(matrix1, matrix2, new Float2Dimensional(5, 2)); default: return null; } - case 3: switch (matrix2.getColumns()) { + case 3: switch(matrix2.getColumns()) { + case 1: return (Float2Dimensional) multiplyMatrix3x2x1(matrix1, matrix2, new Float2Dimensional(1, 3)); case 2: return (Float2Dimensional) multiplyMatrix3x2x2(matrix1, matrix2, new Float2Dimensional(2, 3)); case 3: return (Float2Dimensional) multiplyMatrix3x2x3(matrix1, matrix2, new Float2Dimensional(3, 3)); case 4: return (Float2Dimensional) multiplyMatrix3x2x4(matrix1, matrix2, new Float2Dimensional(4, 3)); case 5: return (Float2Dimensional) multiplyMatrix3x2x5(matrix1, matrix2, new Float2Dimensional(5, 3)); default: return null; } - case 4: switch (matrix2.getColumns()) { + case 4: switch(matrix2.getColumns()) { + case 1: return (Float2Dimensional) multiplyMatrix4x2x1(matrix1, matrix2, new Float2Dimensional(1, 4)); case 2: return (Float2Dimensional) multiplyMatrix4x2x2(matrix1, matrix2, new Float2Dimensional(2, 4)); case 3: return (Float2Dimensional) multiplyMatrix4x2x3(matrix1, matrix2, new Float2Dimensional(3, 4)); case 4: return (Float2Dimensional) multiplyMatrix4x2x4(matrix1, matrix2, new Float2Dimensional(4, 4)); case 5: return (Float2Dimensional) multiplyMatrix4x2x5(matrix1, matrix2, new Float2Dimensional(5, 4)); default: return null; } - case 5: switch (matrix2.getColumns()) { + case 5: switch(matrix2.getColumns()) { + case 1: return (Float2Dimensional) multiplyMatrix5x2x1(matrix1, matrix2, new Float2Dimensional(1, 5)); case 2: return (Float2Dimensional) multiplyMatrix5x2x2(matrix1, matrix2, new Float2Dimensional(2, 5)); case 3: return (Float2Dimensional) multiplyMatrix5x2x3(matrix1, matrix2, new Float2Dimensional(3, 5)); case 4: return (Float2Dimensional) multiplyMatrix5x2x4(matrix1, matrix2, new Float2Dimensional(4, 5)); @@ -2788,29 +4230,41 @@ public final class MultiplicationsFloat { } default: return null; } - case 3: switch (matrix1.getRows()) { - case 2: switch (matrix2.getColumns()) { + case 3: switch(matrix1.getRows()) { + case 1: switch(matrix2.getColumns()) { + case 1: return (Float2Dimensional) multiplyMatrix1x3x1(matrix1, matrix2, new Float2Dimensional(1, 1)); + case 2: return (Float2Dimensional) multiplyMatrix1x3x2(matrix1, matrix2, new Float2Dimensional(2, 1)); + case 3: return (Float2Dimensional) multiplyMatrix1x3x3(matrix1, matrix2, new Float2Dimensional(3, 1)); + case 4: return (Float2Dimensional) multiplyMatrix1x3x4(matrix1, matrix2, new Float2Dimensional(4, 1)); + case 5: return (Float2Dimensional) multiplyMatrix1x3x5(matrix1, matrix2, new Float2Dimensional(5, 1)); + default: return null; + } + case 2: switch(matrix2.getColumns()) { + case 1: return (Float2Dimensional) multiplyMatrix2x3x1(matrix1, matrix2, new Float2Dimensional(1, 2)); case 2: return (Float2Dimensional) multiplyMatrix2x3x2(matrix1, matrix2, new Float2Dimensional(2, 2)); case 3: return (Float2Dimensional) multiplyMatrix2x3x3(matrix1, matrix2, new Float2Dimensional(3, 2)); case 4: return (Float2Dimensional) multiplyMatrix2x3x4(matrix1, matrix2, new Float2Dimensional(4, 2)); case 5: return (Float2Dimensional) multiplyMatrix2x3x5(matrix1, matrix2, new Float2Dimensional(5, 2)); default: return null; } - case 3: switch (matrix2.getColumns()) { + case 3: switch(matrix2.getColumns()) { + case 1: return (Float2Dimensional) multiplyMatrix3x3x1(matrix1, matrix2, new Float2Dimensional(1, 3)); case 2: return (Float2Dimensional) multiplyMatrix3x3x2(matrix1, matrix2, new Float2Dimensional(2, 3)); case 3: return (Float2Dimensional) multiplyMatrix3x3x3(matrix1, matrix2, new Float2Dimensional(3, 3)); case 4: return (Float2Dimensional) multiplyMatrix3x3x4(matrix1, matrix2, new Float2Dimensional(4, 3)); case 5: return (Float2Dimensional) multiplyMatrix3x3x5(matrix1, matrix2, new Float2Dimensional(5, 3)); default: return null; } - case 4: switch (matrix2.getColumns()) { + case 4: switch(matrix2.getColumns()) { + case 1: return (Float2Dimensional) multiplyMatrix4x3x1(matrix1, matrix2, new Float2Dimensional(1, 4)); case 2: return (Float2Dimensional) multiplyMatrix4x3x2(matrix1, matrix2, new Float2Dimensional(2, 4)); case 3: return (Float2Dimensional) multiplyMatrix4x3x3(matrix1, matrix2, new Float2Dimensional(3, 4)); case 4: return (Float2Dimensional) multiplyMatrix4x3x4(matrix1, matrix2, new Float2Dimensional(4, 4)); case 5: return (Float2Dimensional) multiplyMatrix4x3x5(matrix1, matrix2, new Float2Dimensional(5, 4)); default: return null; } - case 5: switch (matrix2.getColumns()) { + case 5: switch(matrix2.getColumns()) { + case 1: return (Float2Dimensional) multiplyMatrix5x3x1(matrix1, matrix2, new Float2Dimensional(1, 5)); case 2: return (Float2Dimensional) multiplyMatrix5x3x2(matrix1, matrix2, new Float2Dimensional(2, 5)); case 3: return (Float2Dimensional) multiplyMatrix5x3x3(matrix1, matrix2, new Float2Dimensional(3, 5)); case 4: return (Float2Dimensional) multiplyMatrix5x3x4(matrix1, matrix2, new Float2Dimensional(4, 5)); @@ -2819,29 +4273,41 @@ public final class MultiplicationsFloat { } default: return null; } - case 4: switch (matrix1.getRows()) { - case 2: switch (matrix2.getColumns()) { + case 4: switch(matrix1.getRows()) { + case 1: switch(matrix2.getColumns()) { + case 1: return (Float2Dimensional) multiplyMatrix1x4x1(matrix1, matrix2, new Float2Dimensional(1, 1)); + case 2: return (Float2Dimensional) multiplyMatrix1x4x2(matrix1, matrix2, new Float2Dimensional(2, 1)); + case 3: return (Float2Dimensional) multiplyMatrix1x4x3(matrix1, matrix2, new Float2Dimensional(3, 1)); + case 4: return (Float2Dimensional) multiplyMatrix1x4x4(matrix1, matrix2, new Float2Dimensional(4, 1)); + case 5: return (Float2Dimensional) multiplyMatrix1x4x5(matrix1, matrix2, new Float2Dimensional(5, 1)); + default: return null; + } + case 2: switch(matrix2.getColumns()) { + case 1: return (Float2Dimensional) multiplyMatrix2x4x1(matrix1, matrix2, new Float2Dimensional(1, 2)); case 2: return (Float2Dimensional) multiplyMatrix2x4x2(matrix1, matrix2, new Float2Dimensional(2, 2)); case 3: return (Float2Dimensional) multiplyMatrix2x4x3(matrix1, matrix2, new Float2Dimensional(3, 2)); case 4: return (Float2Dimensional) multiplyMatrix2x4x4(matrix1, matrix2, new Float2Dimensional(4, 2)); case 5: return (Float2Dimensional) multiplyMatrix2x4x5(matrix1, matrix2, new Float2Dimensional(5, 2)); default: return null; } - case 3: switch (matrix2.getColumns()) { + case 3: switch(matrix2.getColumns()) { + case 1: return (Float2Dimensional) multiplyMatrix3x4x1(matrix1, matrix2, new Float2Dimensional(1, 3)); case 2: return (Float2Dimensional) multiplyMatrix3x4x2(matrix1, matrix2, new Float2Dimensional(2, 3)); case 3: return (Float2Dimensional) multiplyMatrix3x4x3(matrix1, matrix2, new Float2Dimensional(3, 3)); case 4: return (Float2Dimensional) multiplyMatrix3x4x4(matrix1, matrix2, new Float2Dimensional(4, 3)); case 5: return (Float2Dimensional) multiplyMatrix3x4x5(matrix1, matrix2, new Float2Dimensional(5, 3)); default: return null; } - case 4: switch (matrix2.getColumns()) { + case 4: switch(matrix2.getColumns()) { + case 1: return (Float2Dimensional) multiplyMatrix4x4x1(matrix1, matrix2, new Float2Dimensional(1, 4)); case 2: return (Float2Dimensional) multiplyMatrix4x4x2(matrix1, matrix2, new Float2Dimensional(2, 4)); case 3: return (Float2Dimensional) multiplyMatrix4x4x3(matrix1, matrix2, new Float2Dimensional(3, 4)); case 4: return (Float2Dimensional) multiplyMatrix4x4x4(matrix1, matrix2, new Float2Dimensional(4, 4)); case 5: return (Float2Dimensional) multiplyMatrix4x4x5(matrix1, matrix2, new Float2Dimensional(5, 4)); default: return null; } - case 5: switch (matrix2.getColumns()) { + case 5: switch(matrix2.getColumns()) { + case 1: return (Float2Dimensional) multiplyMatrix5x4x1(matrix1, matrix2, new Float2Dimensional(1, 5)); case 2: return (Float2Dimensional) multiplyMatrix5x4x2(matrix1, matrix2, new Float2Dimensional(2, 5)); case 3: return (Float2Dimensional) multiplyMatrix5x4x3(matrix1, matrix2, new Float2Dimensional(3, 5)); case 4: return (Float2Dimensional) multiplyMatrix5x4x4(matrix1, matrix2, new Float2Dimensional(4, 5)); @@ -2850,29 +4316,41 @@ public final class MultiplicationsFloat { } default: return null; } - case 5: switch (matrix1.getRows()) { - case 2: switch (matrix2.getColumns()) { + case 5: switch(matrix1.getRows()) { + case 1: switch(matrix2.getColumns()) { + case 1: return (Float2Dimensional) multiplyMatrix1x5x1(matrix1, matrix2, new Float2Dimensional(1, 1)); + case 2: return (Float2Dimensional) multiplyMatrix1x5x2(matrix1, matrix2, new Float2Dimensional(2, 1)); + case 3: return (Float2Dimensional) multiplyMatrix1x5x3(matrix1, matrix2, new Float2Dimensional(3, 1)); + case 4: return (Float2Dimensional) multiplyMatrix1x5x4(matrix1, matrix2, new Float2Dimensional(4, 1)); + case 5: return (Float2Dimensional) multiplyMatrix1x5x5(matrix1, matrix2, new Float2Dimensional(5, 1)); + default: return null; + } + case 2: switch(matrix2.getColumns()) { + case 1: return (Float2Dimensional) multiplyMatrix2x5x1(matrix1, matrix2, new Float2Dimensional(1, 2)); case 2: return (Float2Dimensional) multiplyMatrix2x5x2(matrix1, matrix2, new Float2Dimensional(2, 2)); case 3: return (Float2Dimensional) multiplyMatrix2x5x3(matrix1, matrix2, new Float2Dimensional(3, 2)); case 4: return (Float2Dimensional) multiplyMatrix2x5x4(matrix1, matrix2, new Float2Dimensional(4, 2)); case 5: return (Float2Dimensional) multiplyMatrix2x5x5(matrix1, matrix2, new Float2Dimensional(5, 2)); default: return null; } - case 3: switch (matrix2.getColumns()) { + case 3: switch(matrix2.getColumns()) { + case 1: return (Float2Dimensional) multiplyMatrix3x5x1(matrix1, matrix2, new Float2Dimensional(1, 3)); case 2: return (Float2Dimensional) multiplyMatrix3x5x2(matrix1, matrix2, new Float2Dimensional(2, 3)); case 3: return (Float2Dimensional) multiplyMatrix3x5x3(matrix1, matrix2, new Float2Dimensional(3, 3)); case 4: return (Float2Dimensional) multiplyMatrix3x5x4(matrix1, matrix2, new Float2Dimensional(4, 3)); case 5: return (Float2Dimensional) multiplyMatrix3x5x5(matrix1, matrix2, new Float2Dimensional(5, 3)); default: return null; } - case 4: switch (matrix2.getColumns()) { + case 4: switch(matrix2.getColumns()) { + case 1: return (Float2Dimensional) multiplyMatrix4x5x1(matrix1, matrix2, new Float2Dimensional(1, 4)); case 2: return (Float2Dimensional) multiplyMatrix4x5x2(matrix1, matrix2, new Float2Dimensional(2, 4)); case 3: return (Float2Dimensional) multiplyMatrix4x5x3(matrix1, matrix2, new Float2Dimensional(3, 4)); case 4: return (Float2Dimensional) multiplyMatrix4x5x4(matrix1, matrix2, new Float2Dimensional(4, 4)); case 5: return (Float2Dimensional) multiplyMatrix4x5x5(matrix1, matrix2, new Float2Dimensional(5, 4)); default: return null; } - case 5: switch (matrix2.getColumns()) { + case 5: switch(matrix2.getColumns()) { + case 1: return (Float2Dimensional) multiplyMatrix5x5x1(matrix1, matrix2, new Float2Dimensional(1, 5)); case 2: return (Float2Dimensional) multiplyMatrix5x5x2(matrix1, matrix2, new Float2Dimensional(2, 5)); case 3: return (Float2Dimensional) multiplyMatrix5x5x3(matrix1, matrix2, new Float2Dimensional(3, 5)); case 4: return (Float2Dimensional) multiplyMatrix5x5x4(matrix1, matrix2, new Float2Dimensional(4, 5)); @@ -2884,39 +4362,94 @@ public final class MultiplicationsFloat { default: return null; } } - /** - * Automatically generated concrete matrix multiplication. If no mapping exist, this method returns null. - * This method writes the result to specified [output] - * @return provided IMatrixSetterFloat if mapping exists and computed, or null if mapping does not exist + * Automatically generated concrete matrix multiplication. + * This function writes the result onto specified output, and returns it, if mapping exists and computed, otherwise returns null. + * + * @return provided output, or null if mapping does not exist */ - @org.jetbrains.annotations.Nullable - public static IMatrixSetterFloat multiplyMatrix(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { + @org.jetbrains.annotations.Nullable + public static IMatrixSetterFloat multiplyMatrix(final IMatrixGetterFloat matrix1, final IMatrixGetterFloat matrix2, final IMatrixSetterFloat output) { if (matrix1.getColumns() != matrix2.getRows()) return null; - switch (matrix1.getColumns()) { - case 2: switch (matrix1.getRows()) { - case 2: switch (matrix2.getColumns()) { + switch(matrix1.getColumns()) { + case 1: switch(matrix1.getRows()) { + case 1: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix1x1x1(matrix1, matrix2, output); + case 2: return multiplyMatrix1x1x2(matrix1, matrix2, output); + case 3: return multiplyMatrix1x1x3(matrix1, matrix2, output); + case 4: return multiplyMatrix1x1x4(matrix1, matrix2, output); + case 5: return multiplyMatrix1x1x5(matrix1, matrix2, output); + default: return null; + } + case 2: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix2x1x1(matrix1, matrix2, output); + case 2: return multiplyMatrix2x1x2(matrix1, matrix2, output); + case 3: return multiplyMatrix2x1x3(matrix1, matrix2, output); + case 4: return multiplyMatrix2x1x4(matrix1, matrix2, output); + case 5: return multiplyMatrix2x1x5(matrix1, matrix2, output); + default: return null; + } + case 3: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix3x1x1(matrix1, matrix2, output); + case 2: return multiplyMatrix3x1x2(matrix1, matrix2, output); + case 3: return multiplyMatrix3x1x3(matrix1, matrix2, output); + case 4: return multiplyMatrix3x1x4(matrix1, matrix2, output); + case 5: return multiplyMatrix3x1x5(matrix1, matrix2, output); + default: return null; + } + case 4: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix4x1x1(matrix1, matrix2, output); + case 2: return multiplyMatrix4x1x2(matrix1, matrix2, output); + case 3: return multiplyMatrix4x1x3(matrix1, matrix2, output); + case 4: return multiplyMatrix4x1x4(matrix1, matrix2, output); + case 5: return multiplyMatrix4x1x5(matrix1, matrix2, output); + default: return null; + } + case 5: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix5x1x1(matrix1, matrix2, output); + case 2: return multiplyMatrix5x1x2(matrix1, matrix2, output); + case 3: return multiplyMatrix5x1x3(matrix1, matrix2, output); + case 4: return multiplyMatrix5x1x4(matrix1, matrix2, output); + case 5: return multiplyMatrix5x1x5(matrix1, matrix2, output); + default: return null; + } + default: return null; + } + case 2: switch(matrix1.getRows()) { + case 1: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix1x2x1(matrix1, matrix2, output); + case 2: return multiplyMatrix1x2x2(matrix1, matrix2, output); + case 3: return multiplyMatrix1x2x3(matrix1, matrix2, output); + case 4: return multiplyMatrix1x2x4(matrix1, matrix2, output); + case 5: return multiplyMatrix1x2x5(matrix1, matrix2, output); + default: return null; + } + case 2: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix2x2x1(matrix1, matrix2, output); case 2: return multiplyMatrix2x2x2(matrix1, matrix2, output); case 3: return multiplyMatrix2x2x3(matrix1, matrix2, output); case 4: return multiplyMatrix2x2x4(matrix1, matrix2, output); case 5: return multiplyMatrix2x2x5(matrix1, matrix2, output); default: return null; } - case 3: switch (matrix2.getColumns()) { + case 3: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix3x2x1(matrix1, matrix2, output); case 2: return multiplyMatrix3x2x2(matrix1, matrix2, output); case 3: return multiplyMatrix3x2x3(matrix1, matrix2, output); case 4: return multiplyMatrix3x2x4(matrix1, matrix2, output); case 5: return multiplyMatrix3x2x5(matrix1, matrix2, output); default: return null; } - case 4: switch (matrix2.getColumns()) { + case 4: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix4x2x1(matrix1, matrix2, output); case 2: return multiplyMatrix4x2x2(matrix1, matrix2, output); case 3: return multiplyMatrix4x2x3(matrix1, matrix2, output); case 4: return multiplyMatrix4x2x4(matrix1, matrix2, output); case 5: return multiplyMatrix4x2x5(matrix1, matrix2, output); default: return null; } - case 5: switch (matrix2.getColumns()) { + case 5: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix5x2x1(matrix1, matrix2, output); case 2: return multiplyMatrix5x2x2(matrix1, matrix2, output); case 3: return multiplyMatrix5x2x3(matrix1, matrix2, output); case 4: return multiplyMatrix5x2x4(matrix1, matrix2, output); @@ -2925,29 +4458,41 @@ public final class MultiplicationsFloat { } default: return null; } - case 3: switch (matrix1.getRows()) { - case 2: switch (matrix2.getColumns()) { + case 3: switch(matrix1.getRows()) { + case 1: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix1x3x1(matrix1, matrix2, output); + case 2: return multiplyMatrix1x3x2(matrix1, matrix2, output); + case 3: return multiplyMatrix1x3x3(matrix1, matrix2, output); + case 4: return multiplyMatrix1x3x4(matrix1, matrix2, output); + case 5: return multiplyMatrix1x3x5(matrix1, matrix2, output); + default: return null; + } + case 2: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix2x3x1(matrix1, matrix2, output); case 2: return multiplyMatrix2x3x2(matrix1, matrix2, output); case 3: return multiplyMatrix2x3x3(matrix1, matrix2, output); case 4: return multiplyMatrix2x3x4(matrix1, matrix2, output); case 5: return multiplyMatrix2x3x5(matrix1, matrix2, output); default: return null; } - case 3: switch (matrix2.getColumns()) { + case 3: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix3x3x1(matrix1, matrix2, output); case 2: return multiplyMatrix3x3x2(matrix1, matrix2, output); case 3: return multiplyMatrix3x3x3(matrix1, matrix2, output); case 4: return multiplyMatrix3x3x4(matrix1, matrix2, output); case 5: return multiplyMatrix3x3x5(matrix1, matrix2, output); default: return null; } - case 4: switch (matrix2.getColumns()) { + case 4: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix4x3x1(matrix1, matrix2, output); case 2: return multiplyMatrix4x3x2(matrix1, matrix2, output); case 3: return multiplyMatrix4x3x3(matrix1, matrix2, output); case 4: return multiplyMatrix4x3x4(matrix1, matrix2, output); case 5: return multiplyMatrix4x3x5(matrix1, matrix2, output); default: return null; } - case 5: switch (matrix2.getColumns()) { + case 5: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix5x3x1(matrix1, matrix2, output); case 2: return multiplyMatrix5x3x2(matrix1, matrix2, output); case 3: return multiplyMatrix5x3x3(matrix1, matrix2, output); case 4: return multiplyMatrix5x3x4(matrix1, matrix2, output); @@ -2956,29 +4501,41 @@ public final class MultiplicationsFloat { } default: return null; } - case 4: switch (matrix1.getRows()) { - case 2: switch (matrix2.getColumns()) { + case 4: switch(matrix1.getRows()) { + case 1: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix1x4x1(matrix1, matrix2, output); + case 2: return multiplyMatrix1x4x2(matrix1, matrix2, output); + case 3: return multiplyMatrix1x4x3(matrix1, matrix2, output); + case 4: return multiplyMatrix1x4x4(matrix1, matrix2, output); + case 5: return multiplyMatrix1x4x5(matrix1, matrix2, output); + default: return null; + } + case 2: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix2x4x1(matrix1, matrix2, output); case 2: return multiplyMatrix2x4x2(matrix1, matrix2, output); case 3: return multiplyMatrix2x4x3(matrix1, matrix2, output); case 4: return multiplyMatrix2x4x4(matrix1, matrix2, output); case 5: return multiplyMatrix2x4x5(matrix1, matrix2, output); default: return null; } - case 3: switch (matrix2.getColumns()) { + case 3: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix3x4x1(matrix1, matrix2, output); case 2: return multiplyMatrix3x4x2(matrix1, matrix2, output); case 3: return multiplyMatrix3x4x3(matrix1, matrix2, output); case 4: return multiplyMatrix3x4x4(matrix1, matrix2, output); case 5: return multiplyMatrix3x4x5(matrix1, matrix2, output); default: return null; } - case 4: switch (matrix2.getColumns()) { + case 4: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix4x4x1(matrix1, matrix2, output); case 2: return multiplyMatrix4x4x2(matrix1, matrix2, output); case 3: return multiplyMatrix4x4x3(matrix1, matrix2, output); case 4: return multiplyMatrix4x4x4(matrix1, matrix2, output); case 5: return multiplyMatrix4x4x5(matrix1, matrix2, output); default: return null; } - case 5: switch (matrix2.getColumns()) { + case 5: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix5x4x1(matrix1, matrix2, output); case 2: return multiplyMatrix5x4x2(matrix1, matrix2, output); case 3: return multiplyMatrix5x4x3(matrix1, matrix2, output); case 4: return multiplyMatrix5x4x4(matrix1, matrix2, output); @@ -2987,29 +4544,41 @@ public final class MultiplicationsFloat { } default: return null; } - case 5: switch (matrix1.getRows()) { - case 2: switch (matrix2.getColumns()) { + case 5: switch(matrix1.getRows()) { + case 1: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix1x5x1(matrix1, matrix2, output); + case 2: return multiplyMatrix1x5x2(matrix1, matrix2, output); + case 3: return multiplyMatrix1x5x3(matrix1, matrix2, output); + case 4: return multiplyMatrix1x5x4(matrix1, matrix2, output); + case 5: return multiplyMatrix1x5x5(matrix1, matrix2, output); + default: return null; + } + case 2: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix2x5x1(matrix1, matrix2, output); case 2: return multiplyMatrix2x5x2(matrix1, matrix2, output); case 3: return multiplyMatrix2x5x3(matrix1, matrix2, output); case 4: return multiplyMatrix2x5x4(matrix1, matrix2, output); case 5: return multiplyMatrix2x5x5(matrix1, matrix2, output); default: return null; } - case 3: switch (matrix2.getColumns()) { + case 3: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix3x5x1(matrix1, matrix2, output); case 2: return multiplyMatrix3x5x2(matrix1, matrix2, output); case 3: return multiplyMatrix3x5x3(matrix1, matrix2, output); case 4: return multiplyMatrix3x5x4(matrix1, matrix2, output); case 5: return multiplyMatrix3x5x5(matrix1, matrix2, output); default: return null; } - case 4: switch (matrix2.getColumns()) { + case 4: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix4x5x1(matrix1, matrix2, output); case 2: return multiplyMatrix4x5x2(matrix1, matrix2, output); case 3: return multiplyMatrix4x5x3(matrix1, matrix2, output); case 4: return multiplyMatrix4x5x4(matrix1, matrix2, output); case 5: return multiplyMatrix4x5x5(matrix1, matrix2, output); default: return null; } - case 5: switch (matrix2.getColumns()) { + case 5: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix5x5x1(matrix1, matrix2, output); case 2: return multiplyMatrix5x5x2(matrix1, matrix2, output); case 3: return multiplyMatrix5x5x3(matrix1, matrix2, output); case 4: return multiplyMatrix5x5x4(matrix1, matrix2, output); diff --git a/src/kvector/java/ru/dbotthepony/kvector/matrix/generated/MultiplicationsInt.java b/src/kvector/java/ru/dbotthepony/kvector/matrix/generated/MultiplicationsInt.java index a5d283ce..6213535d 100644 --- a/src/kvector/java/ru/dbotthepony/kvector/matrix/generated/MultiplicationsInt.java +++ b/src/kvector/java/ru/dbotthepony/kvector/matrix/generated/MultiplicationsInt.java @@ -3,7 +3,6 @@ package ru.dbotthepony.kvector.matrix.generated; import ru.dbotthepony.kvector.api.*; import ru.dbotthepony.kvector.narray.*; -// Some metaprogramming ///////////////////////////////// // THIS FILE IS AUTO GENERATED // // DO NOT EDIT // @@ -11,2775 +10,4218 @@ import ru.dbotthepony.kvector.narray.*; public final class MultiplicationsInt { private MultiplicationsInt() {} + private static IMatrixSetterInt multiplyMatrix1x1x1(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final int f00 = matrix1.get(0, 0); + final int s00 = matrix2.get(0, 0); + output.set(0, 0, f00 * s00); + return output; + } + + private static IMatrixSetterInt multiplyMatrix1x1x2(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final int f00 = matrix1.get(0, 0); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + return output; + } + + private static IMatrixSetterInt multiplyMatrix1x1x3(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final int f00 = matrix1.get(0, 0); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(2, 0, f00 * s20); + return output; + } + + private static IMatrixSetterInt multiplyMatrix1x1x4(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final int f00 = matrix1.get(0, 0); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + final int s30 = matrix2.get(3, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(2, 0, f00 * s20); + output.set(3, 0, f00 * s30); + return output; + } + + private static IMatrixSetterInt multiplyMatrix1x1x5(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final int f00 = matrix1.get(0, 0); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + final int s30 = matrix2.get(3, 0); + final int s40 = matrix2.get(4, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(2, 0, f00 * s20); + output.set(3, 0, f00 * s30); + output.set(4, 0, f00 * s40); + return output; + } + + private static IMatrixSetterInt multiplyMatrix2x1x1(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final int f00 = matrix1.get(0, 0); + final int f01 = matrix1.get(0, 1); + final int s00 = matrix2.get(0, 0); + output.set(0, 0, f00 * s00); + output.set(0, 1, f01 * s00); + return output; + } + + private static IMatrixSetterInt multiplyMatrix2x1x2(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final int f00 = matrix1.get(0, 0); + final int f01 = matrix1.get(0, 1); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(0, 1, f01 * s00); + output.set(1, 1, f01 * s10); + return output; + } + + private static IMatrixSetterInt multiplyMatrix2x1x3(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final int f00 = matrix1.get(0, 0); + final int f01 = matrix1.get(0, 1); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(2, 0, f00 * s20); + output.set(0, 1, f01 * s00); + output.set(1, 1, f01 * s10); + output.set(2, 1, f01 * s20); + return output; + } + + private static IMatrixSetterInt multiplyMatrix2x1x4(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final int f00 = matrix1.get(0, 0); + final int f01 = matrix1.get(0, 1); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + final int s30 = matrix2.get(3, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(2, 0, f00 * s20); + output.set(3, 0, f00 * s30); + output.set(0, 1, f01 * s00); + output.set(1, 1, f01 * s10); + output.set(2, 1, f01 * s20); + output.set(3, 1, f01 * s30); + return output; + } + + private static IMatrixSetterInt multiplyMatrix2x1x5(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final int f00 = matrix1.get(0, 0); + final int f01 = matrix1.get(0, 1); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + final int s30 = matrix2.get(3, 0); + final int s40 = matrix2.get(4, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(2, 0, f00 * s20); + output.set(3, 0, f00 * s30); + output.set(4, 0, f00 * s40); + output.set(0, 1, f01 * s00); + output.set(1, 1, f01 * s10); + output.set(2, 1, f01 * s20); + output.set(3, 1, f01 * s30); + output.set(4, 1, f01 * s40); + return output; + } + + private static IMatrixSetterInt multiplyMatrix3x1x1(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final int f00 = matrix1.get(0, 0); + final int f01 = matrix1.get(0, 1); + final int f02 = matrix1.get(0, 2); + final int s00 = matrix2.get(0, 0); + output.set(0, 0, f00 * s00); + output.set(0, 1, f01 * s00); + output.set(0, 2, f02 * s00); + return output; + } + + private static IMatrixSetterInt multiplyMatrix3x1x2(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final int f00 = matrix1.get(0, 0); + final int f01 = matrix1.get(0, 1); + final int f02 = matrix1.get(0, 2); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(0, 1, f01 * s00); + output.set(1, 1, f01 * s10); + output.set(0, 2, f02 * s00); + output.set(1, 2, f02 * s10); + return output; + } + + private static IMatrixSetterInt multiplyMatrix3x1x3(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final int f00 = matrix1.get(0, 0); + final int f01 = matrix1.get(0, 1); + final int f02 = matrix1.get(0, 2); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(2, 0, f00 * s20); + output.set(0, 1, f01 * s00); + output.set(1, 1, f01 * s10); + output.set(2, 1, f01 * s20); + output.set(0, 2, f02 * s00); + output.set(1, 2, f02 * s10); + output.set(2, 2, f02 * s20); + return output; + } + + private static IMatrixSetterInt multiplyMatrix3x1x4(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final int f00 = matrix1.get(0, 0); + final int f01 = matrix1.get(0, 1); + final int f02 = matrix1.get(0, 2); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + final int s30 = matrix2.get(3, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(2, 0, f00 * s20); + output.set(3, 0, f00 * s30); + output.set(0, 1, f01 * s00); + output.set(1, 1, f01 * s10); + output.set(2, 1, f01 * s20); + output.set(3, 1, f01 * s30); + output.set(0, 2, f02 * s00); + output.set(1, 2, f02 * s10); + output.set(2, 2, f02 * s20); + output.set(3, 2, f02 * s30); + return output; + } + + private static IMatrixSetterInt multiplyMatrix3x1x5(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final int f00 = matrix1.get(0, 0); + final int f01 = matrix1.get(0, 1); + final int f02 = matrix1.get(0, 2); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + final int s30 = matrix2.get(3, 0); + final int s40 = matrix2.get(4, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(2, 0, f00 * s20); + output.set(3, 0, f00 * s30); + output.set(4, 0, f00 * s40); + output.set(0, 1, f01 * s00); + output.set(1, 1, f01 * s10); + output.set(2, 1, f01 * s20); + output.set(3, 1, f01 * s30); + output.set(4, 1, f01 * s40); + output.set(0, 2, f02 * s00); + output.set(1, 2, f02 * s10); + output.set(2, 2, f02 * s20); + output.set(3, 2, f02 * s30); + output.set(4, 2, f02 * s40); + return output; + } + + private static IMatrixSetterInt multiplyMatrix4x1x1(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final int f00 = matrix1.get(0, 0); + final int f01 = matrix1.get(0, 1); + final int f02 = matrix1.get(0, 2); + final int f03 = matrix1.get(0, 3); + final int s00 = matrix2.get(0, 0); + output.set(0, 0, f00 * s00); + output.set(0, 1, f01 * s00); + output.set(0, 2, f02 * s00); + output.set(0, 3, f03 * s00); + return output; + } + + private static IMatrixSetterInt multiplyMatrix4x1x2(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final int f00 = matrix1.get(0, 0); + final int f01 = matrix1.get(0, 1); + final int f02 = matrix1.get(0, 2); + final int f03 = matrix1.get(0, 3); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(0, 1, f01 * s00); + output.set(1, 1, f01 * s10); + output.set(0, 2, f02 * s00); + output.set(1, 2, f02 * s10); + output.set(0, 3, f03 * s00); + output.set(1, 3, f03 * s10); + return output; + } + + private static IMatrixSetterInt multiplyMatrix4x1x3(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final int f00 = matrix1.get(0, 0); + final int f01 = matrix1.get(0, 1); + final int f02 = matrix1.get(0, 2); + final int f03 = matrix1.get(0, 3); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(2, 0, f00 * s20); + output.set(0, 1, f01 * s00); + output.set(1, 1, f01 * s10); + output.set(2, 1, f01 * s20); + output.set(0, 2, f02 * s00); + output.set(1, 2, f02 * s10); + output.set(2, 2, f02 * s20); + output.set(0, 3, f03 * s00); + output.set(1, 3, f03 * s10); + output.set(2, 3, f03 * s20); + return output; + } + + private static IMatrixSetterInt multiplyMatrix4x1x4(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final int f00 = matrix1.get(0, 0); + final int f01 = matrix1.get(0, 1); + final int f02 = matrix1.get(0, 2); + final int f03 = matrix1.get(0, 3); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + final int s30 = matrix2.get(3, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(2, 0, f00 * s20); + output.set(3, 0, f00 * s30); + output.set(0, 1, f01 * s00); + output.set(1, 1, f01 * s10); + output.set(2, 1, f01 * s20); + output.set(3, 1, f01 * s30); + output.set(0, 2, f02 * s00); + output.set(1, 2, f02 * s10); + output.set(2, 2, f02 * s20); + output.set(3, 2, f02 * s30); + output.set(0, 3, f03 * s00); + output.set(1, 3, f03 * s10); + output.set(2, 3, f03 * s20); + output.set(3, 3, f03 * s30); + return output; + } + + private static IMatrixSetterInt multiplyMatrix4x1x5(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final int f00 = matrix1.get(0, 0); + final int f01 = matrix1.get(0, 1); + final int f02 = matrix1.get(0, 2); + final int f03 = matrix1.get(0, 3); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + final int s30 = matrix2.get(3, 0); + final int s40 = matrix2.get(4, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(2, 0, f00 * s20); + output.set(3, 0, f00 * s30); + output.set(4, 0, f00 * s40); + output.set(0, 1, f01 * s00); + output.set(1, 1, f01 * s10); + output.set(2, 1, f01 * s20); + output.set(3, 1, f01 * s30); + output.set(4, 1, f01 * s40); + output.set(0, 2, f02 * s00); + output.set(1, 2, f02 * s10); + output.set(2, 2, f02 * s20); + output.set(3, 2, f02 * s30); + output.set(4, 2, f02 * s40); + output.set(0, 3, f03 * s00); + output.set(1, 3, f03 * s10); + output.set(2, 3, f03 * s20); + output.set(3, 3, f03 * s30); + output.set(4, 3, f03 * s40); + return output; + } + + private static IMatrixSetterInt multiplyMatrix5x1x1(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final int f00 = matrix1.get(0, 0); + final int f01 = matrix1.get(0, 1); + final int f02 = matrix1.get(0, 2); + final int f03 = matrix1.get(0, 3); + final int f04 = matrix1.get(0, 4); + final int s00 = matrix2.get(0, 0); + output.set(0, 0, f00 * s00); + output.set(0, 1, f01 * s00); + output.set(0, 2, f02 * s00); + output.set(0, 3, f03 * s00); + output.set(0, 4, f04 * s00); + return output; + } + + private static IMatrixSetterInt multiplyMatrix5x1x2(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final int f00 = matrix1.get(0, 0); + final int f01 = matrix1.get(0, 1); + final int f02 = matrix1.get(0, 2); + final int f03 = matrix1.get(0, 3); + final int f04 = matrix1.get(0, 4); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(0, 1, f01 * s00); + output.set(1, 1, f01 * s10); + output.set(0, 2, f02 * s00); + output.set(1, 2, f02 * s10); + output.set(0, 3, f03 * s00); + output.set(1, 3, f03 * s10); + output.set(0, 4, f04 * s00); + output.set(1, 4, f04 * s10); + return output; + } + + private static IMatrixSetterInt multiplyMatrix5x1x3(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final int f00 = matrix1.get(0, 0); + final int f01 = matrix1.get(0, 1); + final int f02 = matrix1.get(0, 2); + final int f03 = matrix1.get(0, 3); + final int f04 = matrix1.get(0, 4); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(2, 0, f00 * s20); + output.set(0, 1, f01 * s00); + output.set(1, 1, f01 * s10); + output.set(2, 1, f01 * s20); + output.set(0, 2, f02 * s00); + output.set(1, 2, f02 * s10); + output.set(2, 2, f02 * s20); + output.set(0, 3, f03 * s00); + output.set(1, 3, f03 * s10); + output.set(2, 3, f03 * s20); + output.set(0, 4, f04 * s00); + output.set(1, 4, f04 * s10); + output.set(2, 4, f04 * s20); + return output; + } + + private static IMatrixSetterInt multiplyMatrix5x1x4(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final int f00 = matrix1.get(0, 0); + final int f01 = matrix1.get(0, 1); + final int f02 = matrix1.get(0, 2); + final int f03 = matrix1.get(0, 3); + final int f04 = matrix1.get(0, 4); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + final int s30 = matrix2.get(3, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(2, 0, f00 * s20); + output.set(3, 0, f00 * s30); + output.set(0, 1, f01 * s00); + output.set(1, 1, f01 * s10); + output.set(2, 1, f01 * s20); + output.set(3, 1, f01 * s30); + output.set(0, 2, f02 * s00); + output.set(1, 2, f02 * s10); + output.set(2, 2, f02 * s20); + output.set(3, 2, f02 * s30); + output.set(0, 3, f03 * s00); + output.set(1, 3, f03 * s10); + output.set(2, 3, f03 * s20); + output.set(3, 3, f03 * s30); + output.set(0, 4, f04 * s00); + output.set(1, 4, f04 * s10); + output.set(2, 4, f04 * s20); + output.set(3, 4, f04 * s30); + return output; + } + + private static IMatrixSetterInt multiplyMatrix5x1x5(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final int f00 = matrix1.get(0, 0); + final int f01 = matrix1.get(0, 1); + final int f02 = matrix1.get(0, 2); + final int f03 = matrix1.get(0, 3); + final int f04 = matrix1.get(0, 4); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + final int s30 = matrix2.get(3, 0); + final int s40 = matrix2.get(4, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(2, 0, f00 * s20); + output.set(3, 0, f00 * s30); + output.set(4, 0, f00 * s40); + output.set(0, 1, f01 * s00); + output.set(1, 1, f01 * s10); + output.set(2, 1, f01 * s20); + output.set(3, 1, f01 * s30); + output.set(4, 1, f01 * s40); + output.set(0, 2, f02 * s00); + output.set(1, 2, f02 * s10); + output.set(2, 2, f02 * s20); + output.set(3, 2, f02 * s30); + output.set(4, 2, f02 * s40); + output.set(0, 3, f03 * s00); + output.set(1, 3, f03 * s10); + output.set(2, 3, f03 * s20); + output.set(3, 3, f03 * s30); + output.set(4, 3, f03 * s40); + output.set(0, 4, f04 * s00); + output.set(1, 4, f04 * s10); + output.set(2, 4, f04 * s20); + output.set(3, 4, f04 * s30); + output.set(4, 4, f04 * s40); + return output; + } + + private static IMatrixSetterInt multiplyMatrix1x2x1(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int s00 = matrix2.get(0, 0); + final int s01 = matrix2.get(0, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + return output; + } + + private static IMatrixSetterInt multiplyMatrix1x2x2(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + return output; + } + + private static IMatrixSetterInt multiplyMatrix1x2x3(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s21 = matrix2.get(2, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(2, 0, f00 * s20 + f10 * s21); + return output; + } + + private static IMatrixSetterInt multiplyMatrix1x2x4(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + final int s30 = matrix2.get(3, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s21 = matrix2.get(2, 1); + final int s31 = matrix2.get(3, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(2, 0, f00 * s20 + f10 * s21); + output.set(3, 0, f00 * s30 + f10 * s31); + return output; + } + + private static IMatrixSetterInt multiplyMatrix1x2x5(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + final int s30 = matrix2.get(3, 0); + final int s40 = matrix2.get(4, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s21 = matrix2.get(2, 1); + final int s31 = matrix2.get(3, 1); + final int s41 = matrix2.get(4, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(2, 0, f00 * s20 + f10 * s21); + output.set(3, 0, f00 * s30 + f10 * s31); + output.set(4, 0, f00 * s40 + f10 * s41); + return output; + } + + private static IMatrixSetterInt multiplyMatrix2x2x1(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int s00 = matrix2.get(0, 0); + final int s01 = matrix2.get(0, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(0, 1, f01 * s00 + f11 * s01); + return output; + } private static IMatrixSetterInt multiplyMatrix2x2x2(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final int f_c00 = matrix1.get(0, 0); - final int f_c10 = matrix1.get(1, 0); - final int f_c01 = matrix1.get(0, 1); - final int f_c11 = matrix1.get(1, 1); - final int s_c00 = matrix2.get(0, 0); - final int s_c10 = matrix2.get(1, 0); - final int s_c01 = matrix2.get(0, 1); - final int s_c11 = matrix2.get(1, 1); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(1, 1, f01 * s10 + f11 * s11); return output; } private static IMatrixSetterInt multiplyMatrix2x2x3(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final int f_c00 = matrix1.get(0, 0); - final int f_c10 = matrix1.get(1, 0); - final int f_c01 = matrix1.get(0, 1); - final int f_c11 = matrix1.get(1, 1); - final int s_c00 = matrix2.get(0, 0); - final int s_c10 = matrix2.get(1, 0); - final int s_c20 = matrix2.get(2, 0); - final int s_c01 = matrix2.get(0, 1); - final int s_c11 = matrix2.get(1, 1); - final int s_c21 = matrix2.get(2, 1); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s21 = matrix2.get(2, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(2, 0, f00 * s20 + f10 * s21); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(1, 1, f01 * s10 + f11 * s11); + output.set(2, 1, f01 * s20 + f11 * s21); return output; } private static IMatrixSetterInt multiplyMatrix2x2x4(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final int f_c00 = matrix1.get(0, 0); - final int f_c10 = matrix1.get(1, 0); - final int f_c01 = matrix1.get(0, 1); - final int f_c11 = matrix1.get(1, 1); - final int s_c00 = matrix2.get(0, 0); - final int s_c10 = matrix2.get(1, 0); - final int s_c20 = matrix2.get(2, 0); - final int s_c30 = matrix2.get(3, 0); - final int s_c01 = matrix2.get(0, 1); - final int s_c11 = matrix2.get(1, 1); - final int s_c21 = matrix2.get(2, 1); - final int s_c31 = matrix2.get(3, 1); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + final int s30 = matrix2.get(3, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s21 = matrix2.get(2, 1); + final int s31 = matrix2.get(3, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(2, 0, f00 * s20 + f10 * s21); + output.set(3, 0, f00 * s30 + f10 * s31); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(1, 1, f01 * s10 + f11 * s11); + output.set(2, 1, f01 * s20 + f11 * s21); + output.set(3, 1, f01 * s30 + f11 * s31); return output; } private static IMatrixSetterInt multiplyMatrix2x2x5(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final int f_c00 = matrix1.get(0, 0); - final int f_c10 = matrix1.get(1, 0); - final int f_c01 = matrix1.get(0, 1); - final int f_c11 = matrix1.get(1, 1); - final int s_c00 = matrix2.get(0, 0); - final int s_c10 = matrix2.get(1, 0); - final int s_c20 = matrix2.get(2, 0); - final int s_c30 = matrix2.get(3, 0); - final int s_c40 = matrix2.get(4, 0); - final int s_c01 = matrix2.get(0, 1); - final int s_c11 = matrix2.get(1, 1); - final int s_c21 = matrix2.get(2, 1); - final int s_c31 = matrix2.get(3, 1); - final int s_c41 = matrix2.get(4, 1); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31); - output.set(4, 0, f_c00*s_c40 + f_c10*s_c41); - output.set(4, 1, f_c01*s_c40 + f_c11*s_c41); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + final int s30 = matrix2.get(3, 0); + final int s40 = matrix2.get(4, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s21 = matrix2.get(2, 1); + final int s31 = matrix2.get(3, 1); + final int s41 = matrix2.get(4, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(2, 0, f00 * s20 + f10 * s21); + output.set(3, 0, f00 * s30 + f10 * s31); + output.set(4, 0, f00 * s40 + f10 * s41); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(1, 1, f01 * s10 + f11 * s11); + output.set(2, 1, f01 * s20 + f11 * s21); + output.set(3, 1, f01 * s30 + f11 * s31); + output.set(4, 1, f01 * s40 + f11 * s41); + return output; + } + + private static IMatrixSetterInt multiplyMatrix3x2x1(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f02 = matrix1.get(0, 2); + final int f12 = matrix1.get(1, 2); + final int s00 = matrix2.get(0, 0); + final int s01 = matrix2.get(0, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(0, 2, f02 * s00 + f12 * s01); return output; } private static IMatrixSetterInt multiplyMatrix3x2x2(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final int f_c00 = matrix1.get(0, 0); - final int f_c10 = matrix1.get(1, 0); - final int f_c01 = matrix1.get(0, 1); - final int f_c11 = matrix1.get(1, 1); - final int f_c02 = matrix1.get(0, 2); - final int f_c12 = matrix1.get(1, 2); - final int s_c00 = matrix2.get(0, 0); - final int s_c10 = matrix2.get(1, 0); - final int s_c01 = matrix2.get(0, 1); - final int s_c11 = matrix2.get(1, 1); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f02 = matrix1.get(0, 2); + final int f12 = matrix1.get(1, 2); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(1, 1, f01 * s10 + f11 * s11); + output.set(0, 2, f02 * s00 + f12 * s01); + output.set(1, 2, f02 * s10 + f12 * s11); return output; } private static IMatrixSetterInt multiplyMatrix3x2x3(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final int f_c00 = matrix1.get(0, 0); - final int f_c10 = matrix1.get(1, 0); - final int f_c01 = matrix1.get(0, 1); - final int f_c11 = matrix1.get(1, 1); - final int f_c02 = matrix1.get(0, 2); - final int f_c12 = matrix1.get(1, 2); - final int s_c00 = matrix2.get(0, 0); - final int s_c10 = matrix2.get(1, 0); - final int s_c20 = matrix2.get(2, 0); - final int s_c01 = matrix2.get(0, 1); - final int s_c11 = matrix2.get(1, 1); - final int s_c21 = matrix2.get(2, 1); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f02 = matrix1.get(0, 2); + final int f12 = matrix1.get(1, 2); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s21 = matrix2.get(2, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(2, 0, f00 * s20 + f10 * s21); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(1, 1, f01 * s10 + f11 * s11); + output.set(2, 1, f01 * s20 + f11 * s21); + output.set(0, 2, f02 * s00 + f12 * s01); + output.set(1, 2, f02 * s10 + f12 * s11); + output.set(2, 2, f02 * s20 + f12 * s21); return output; } private static IMatrixSetterInt multiplyMatrix3x2x4(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final int f_c00 = matrix1.get(0, 0); - final int f_c10 = matrix1.get(1, 0); - final int f_c01 = matrix1.get(0, 1); - final int f_c11 = matrix1.get(1, 1); - final int f_c02 = matrix1.get(0, 2); - final int f_c12 = matrix1.get(1, 2); - final int s_c00 = matrix2.get(0, 0); - final int s_c10 = matrix2.get(1, 0); - final int s_c20 = matrix2.get(2, 0); - final int s_c30 = matrix2.get(3, 0); - final int s_c01 = matrix2.get(0, 1); - final int s_c11 = matrix2.get(1, 1); - final int s_c21 = matrix2.get(2, 1); - final int s_c31 = matrix2.get(3, 1); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f02 = matrix1.get(0, 2); + final int f12 = matrix1.get(1, 2); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + final int s30 = matrix2.get(3, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s21 = matrix2.get(2, 1); + final int s31 = matrix2.get(3, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(2, 0, f00 * s20 + f10 * s21); + output.set(3, 0, f00 * s30 + f10 * s31); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(1, 1, f01 * s10 + f11 * s11); + output.set(2, 1, f01 * s20 + f11 * s21); + output.set(3, 1, f01 * s30 + f11 * s31); + output.set(0, 2, f02 * s00 + f12 * s01); + output.set(1, 2, f02 * s10 + f12 * s11); + output.set(2, 2, f02 * s20 + f12 * s21); + output.set(3, 2, f02 * s30 + f12 * s31); return output; } private static IMatrixSetterInt multiplyMatrix3x2x5(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final int f_c00 = matrix1.get(0, 0); - final int f_c10 = matrix1.get(1, 0); - final int f_c01 = matrix1.get(0, 1); - final int f_c11 = matrix1.get(1, 1); - final int f_c02 = matrix1.get(0, 2); - final int f_c12 = matrix1.get(1, 2); - final int s_c00 = matrix2.get(0, 0); - final int s_c10 = matrix2.get(1, 0); - final int s_c20 = matrix2.get(2, 0); - final int s_c30 = matrix2.get(3, 0); - final int s_c40 = matrix2.get(4, 0); - final int s_c01 = matrix2.get(0, 1); - final int s_c11 = matrix2.get(1, 1); - final int s_c21 = matrix2.get(2, 1); - final int s_c31 = matrix2.get(3, 1); - final int s_c41 = matrix2.get(4, 1); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31); - output.set(4, 0, f_c00*s_c40 + f_c10*s_c41); - output.set(4, 1, f_c01*s_c40 + f_c11*s_c41); - output.set(4, 2, f_c02*s_c40 + f_c12*s_c41); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f02 = matrix1.get(0, 2); + final int f12 = matrix1.get(1, 2); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + final int s30 = matrix2.get(3, 0); + final int s40 = matrix2.get(4, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s21 = matrix2.get(2, 1); + final int s31 = matrix2.get(3, 1); + final int s41 = matrix2.get(4, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(2, 0, f00 * s20 + f10 * s21); + output.set(3, 0, f00 * s30 + f10 * s31); + output.set(4, 0, f00 * s40 + f10 * s41); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(1, 1, f01 * s10 + f11 * s11); + output.set(2, 1, f01 * s20 + f11 * s21); + output.set(3, 1, f01 * s30 + f11 * s31); + output.set(4, 1, f01 * s40 + f11 * s41); + output.set(0, 2, f02 * s00 + f12 * s01); + output.set(1, 2, f02 * s10 + f12 * s11); + output.set(2, 2, f02 * s20 + f12 * s21); + output.set(3, 2, f02 * s30 + f12 * s31); + output.set(4, 2, f02 * s40 + f12 * s41); + return output; + } + + private static IMatrixSetterInt multiplyMatrix4x2x1(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f02 = matrix1.get(0, 2); + final int f12 = matrix1.get(1, 2); + final int f03 = matrix1.get(0, 3); + final int f13 = matrix1.get(1, 3); + final int s00 = matrix2.get(0, 0); + final int s01 = matrix2.get(0, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(0, 2, f02 * s00 + f12 * s01); + output.set(0, 3, f03 * s00 + f13 * s01); return output; } private static IMatrixSetterInt multiplyMatrix4x2x2(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final int f_c00 = matrix1.get(0, 0); - final int f_c10 = matrix1.get(1, 0); - final int f_c01 = matrix1.get(0, 1); - final int f_c11 = matrix1.get(1, 1); - final int f_c02 = matrix1.get(0, 2); - final int f_c12 = matrix1.get(1, 2); - final int f_c03 = matrix1.get(0, 3); - final int f_c13 = matrix1.get(1, 3); - final int s_c00 = matrix2.get(0, 0); - final int s_c10 = matrix2.get(1, 0); - final int s_c01 = matrix2.get(0, 1); - final int s_c11 = matrix2.get(1, 1); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f02 = matrix1.get(0, 2); + final int f12 = matrix1.get(1, 2); + final int f03 = matrix1.get(0, 3); + final int f13 = matrix1.get(1, 3); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(1, 1, f01 * s10 + f11 * s11); + output.set(0, 2, f02 * s00 + f12 * s01); + output.set(1, 2, f02 * s10 + f12 * s11); + output.set(0, 3, f03 * s00 + f13 * s01); + output.set(1, 3, f03 * s10 + f13 * s11); return output; } private static IMatrixSetterInt multiplyMatrix4x2x3(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final int f_c00 = matrix1.get(0, 0); - final int f_c10 = matrix1.get(1, 0); - final int f_c01 = matrix1.get(0, 1); - final int f_c11 = matrix1.get(1, 1); - final int f_c02 = matrix1.get(0, 2); - final int f_c12 = matrix1.get(1, 2); - final int f_c03 = matrix1.get(0, 3); - final int f_c13 = matrix1.get(1, 3); - final int s_c00 = matrix2.get(0, 0); - final int s_c10 = matrix2.get(1, 0); - final int s_c20 = matrix2.get(2, 0); - final int s_c01 = matrix2.get(0, 1); - final int s_c11 = matrix2.get(1, 1); - final int s_c21 = matrix2.get(2, 1); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f02 = matrix1.get(0, 2); + final int f12 = matrix1.get(1, 2); + final int f03 = matrix1.get(0, 3); + final int f13 = matrix1.get(1, 3); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s21 = matrix2.get(2, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(2, 0, f00 * s20 + f10 * s21); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(1, 1, f01 * s10 + f11 * s11); + output.set(2, 1, f01 * s20 + f11 * s21); + output.set(0, 2, f02 * s00 + f12 * s01); + output.set(1, 2, f02 * s10 + f12 * s11); + output.set(2, 2, f02 * s20 + f12 * s21); + output.set(0, 3, f03 * s00 + f13 * s01); + output.set(1, 3, f03 * s10 + f13 * s11); + output.set(2, 3, f03 * s20 + f13 * s21); return output; } private static IMatrixSetterInt multiplyMatrix4x2x4(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final int f_c00 = matrix1.get(0, 0); - final int f_c10 = matrix1.get(1, 0); - final int f_c01 = matrix1.get(0, 1); - final int f_c11 = matrix1.get(1, 1); - final int f_c02 = matrix1.get(0, 2); - final int f_c12 = matrix1.get(1, 2); - final int f_c03 = matrix1.get(0, 3); - final int f_c13 = matrix1.get(1, 3); - final int s_c00 = matrix2.get(0, 0); - final int s_c10 = matrix2.get(1, 0); - final int s_c20 = matrix2.get(2, 0); - final int s_c30 = matrix2.get(3, 0); - final int s_c01 = matrix2.get(0, 1); - final int s_c11 = matrix2.get(1, 1); - final int s_c21 = matrix2.get(2, 1); - final int s_c31 = matrix2.get(3, 1); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31); - output.set(3, 3, f_c03*s_c30 + f_c13*s_c31); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f02 = matrix1.get(0, 2); + final int f12 = matrix1.get(1, 2); + final int f03 = matrix1.get(0, 3); + final int f13 = matrix1.get(1, 3); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + final int s30 = matrix2.get(3, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s21 = matrix2.get(2, 1); + final int s31 = matrix2.get(3, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(2, 0, f00 * s20 + f10 * s21); + output.set(3, 0, f00 * s30 + f10 * s31); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(1, 1, f01 * s10 + f11 * s11); + output.set(2, 1, f01 * s20 + f11 * s21); + output.set(3, 1, f01 * s30 + f11 * s31); + output.set(0, 2, f02 * s00 + f12 * s01); + output.set(1, 2, f02 * s10 + f12 * s11); + output.set(2, 2, f02 * s20 + f12 * s21); + output.set(3, 2, f02 * s30 + f12 * s31); + output.set(0, 3, f03 * s00 + f13 * s01); + output.set(1, 3, f03 * s10 + f13 * s11); + output.set(2, 3, f03 * s20 + f13 * s21); + output.set(3, 3, f03 * s30 + f13 * s31); return output; } private static IMatrixSetterInt multiplyMatrix4x2x5(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final int f_c00 = matrix1.get(0, 0); - final int f_c10 = matrix1.get(1, 0); - final int f_c01 = matrix1.get(0, 1); - final int f_c11 = matrix1.get(1, 1); - final int f_c02 = matrix1.get(0, 2); - final int f_c12 = matrix1.get(1, 2); - final int f_c03 = matrix1.get(0, 3); - final int f_c13 = matrix1.get(1, 3); - final int s_c00 = matrix2.get(0, 0); - final int s_c10 = matrix2.get(1, 0); - final int s_c20 = matrix2.get(2, 0); - final int s_c30 = matrix2.get(3, 0); - final int s_c40 = matrix2.get(4, 0); - final int s_c01 = matrix2.get(0, 1); - final int s_c11 = matrix2.get(1, 1); - final int s_c21 = matrix2.get(2, 1); - final int s_c31 = matrix2.get(3, 1); - final int s_c41 = matrix2.get(4, 1); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31); - output.set(3, 3, f_c03*s_c30 + f_c13*s_c31); - output.set(4, 0, f_c00*s_c40 + f_c10*s_c41); - output.set(4, 1, f_c01*s_c40 + f_c11*s_c41); - output.set(4, 2, f_c02*s_c40 + f_c12*s_c41); - output.set(4, 3, f_c03*s_c40 + f_c13*s_c41); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f02 = matrix1.get(0, 2); + final int f12 = matrix1.get(1, 2); + final int f03 = matrix1.get(0, 3); + final int f13 = matrix1.get(1, 3); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + final int s30 = matrix2.get(3, 0); + final int s40 = matrix2.get(4, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s21 = matrix2.get(2, 1); + final int s31 = matrix2.get(3, 1); + final int s41 = matrix2.get(4, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(2, 0, f00 * s20 + f10 * s21); + output.set(3, 0, f00 * s30 + f10 * s31); + output.set(4, 0, f00 * s40 + f10 * s41); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(1, 1, f01 * s10 + f11 * s11); + output.set(2, 1, f01 * s20 + f11 * s21); + output.set(3, 1, f01 * s30 + f11 * s31); + output.set(4, 1, f01 * s40 + f11 * s41); + output.set(0, 2, f02 * s00 + f12 * s01); + output.set(1, 2, f02 * s10 + f12 * s11); + output.set(2, 2, f02 * s20 + f12 * s21); + output.set(3, 2, f02 * s30 + f12 * s31); + output.set(4, 2, f02 * s40 + f12 * s41); + output.set(0, 3, f03 * s00 + f13 * s01); + output.set(1, 3, f03 * s10 + f13 * s11); + output.set(2, 3, f03 * s20 + f13 * s21); + output.set(3, 3, f03 * s30 + f13 * s31); + output.set(4, 3, f03 * s40 + f13 * s41); + return output; + } + + private static IMatrixSetterInt multiplyMatrix5x2x1(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f02 = matrix1.get(0, 2); + final int f12 = matrix1.get(1, 2); + final int f03 = matrix1.get(0, 3); + final int f13 = matrix1.get(1, 3); + final int f04 = matrix1.get(0, 4); + final int f14 = matrix1.get(1, 4); + final int s00 = matrix2.get(0, 0); + final int s01 = matrix2.get(0, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(0, 2, f02 * s00 + f12 * s01); + output.set(0, 3, f03 * s00 + f13 * s01); + output.set(0, 4, f04 * s00 + f14 * s01); return output; } private static IMatrixSetterInt multiplyMatrix5x2x2(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final int f_c00 = matrix1.get(0, 0); - final int f_c10 = matrix1.get(1, 0); - final int f_c01 = matrix1.get(0, 1); - final int f_c11 = matrix1.get(1, 1); - final int f_c02 = matrix1.get(0, 2); - final int f_c12 = matrix1.get(1, 2); - final int f_c03 = matrix1.get(0, 3); - final int f_c13 = matrix1.get(1, 3); - final int f_c04 = matrix1.get(0, 4); - final int f_c14 = matrix1.get(1, 4); - final int s_c00 = matrix2.get(0, 0); - final int s_c10 = matrix2.get(1, 0); - final int s_c01 = matrix2.get(0, 1); - final int s_c11 = matrix2.get(1, 1); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01); - output.set(0, 4, f_c04*s_c00 + f_c14*s_c01); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11); - output.set(1, 4, f_c04*s_c10 + f_c14*s_c11); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f02 = matrix1.get(0, 2); + final int f12 = matrix1.get(1, 2); + final int f03 = matrix1.get(0, 3); + final int f13 = matrix1.get(1, 3); + final int f04 = matrix1.get(0, 4); + final int f14 = matrix1.get(1, 4); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(1, 1, f01 * s10 + f11 * s11); + output.set(0, 2, f02 * s00 + f12 * s01); + output.set(1, 2, f02 * s10 + f12 * s11); + output.set(0, 3, f03 * s00 + f13 * s01); + output.set(1, 3, f03 * s10 + f13 * s11); + output.set(0, 4, f04 * s00 + f14 * s01); + output.set(1, 4, f04 * s10 + f14 * s11); return output; } private static IMatrixSetterInt multiplyMatrix5x2x3(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final int f_c00 = matrix1.get(0, 0); - final int f_c10 = matrix1.get(1, 0); - final int f_c01 = matrix1.get(0, 1); - final int f_c11 = matrix1.get(1, 1); - final int f_c02 = matrix1.get(0, 2); - final int f_c12 = matrix1.get(1, 2); - final int f_c03 = matrix1.get(0, 3); - final int f_c13 = matrix1.get(1, 3); - final int f_c04 = matrix1.get(0, 4); - final int f_c14 = matrix1.get(1, 4); - final int s_c00 = matrix2.get(0, 0); - final int s_c10 = matrix2.get(1, 0); - final int s_c20 = matrix2.get(2, 0); - final int s_c01 = matrix2.get(0, 1); - final int s_c11 = matrix2.get(1, 1); - final int s_c21 = matrix2.get(2, 1); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01); - output.set(0, 4, f_c04*s_c00 + f_c14*s_c01); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11); - output.set(1, 4, f_c04*s_c10 + f_c14*s_c11); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21); - output.set(2, 4, f_c04*s_c20 + f_c14*s_c21); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f02 = matrix1.get(0, 2); + final int f12 = matrix1.get(1, 2); + final int f03 = matrix1.get(0, 3); + final int f13 = matrix1.get(1, 3); + final int f04 = matrix1.get(0, 4); + final int f14 = matrix1.get(1, 4); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s21 = matrix2.get(2, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(2, 0, f00 * s20 + f10 * s21); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(1, 1, f01 * s10 + f11 * s11); + output.set(2, 1, f01 * s20 + f11 * s21); + output.set(0, 2, f02 * s00 + f12 * s01); + output.set(1, 2, f02 * s10 + f12 * s11); + output.set(2, 2, f02 * s20 + f12 * s21); + output.set(0, 3, f03 * s00 + f13 * s01); + output.set(1, 3, f03 * s10 + f13 * s11); + output.set(2, 3, f03 * s20 + f13 * s21); + output.set(0, 4, f04 * s00 + f14 * s01); + output.set(1, 4, f04 * s10 + f14 * s11); + output.set(2, 4, f04 * s20 + f14 * s21); return output; } private static IMatrixSetterInt multiplyMatrix5x2x4(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final int f_c00 = matrix1.get(0, 0); - final int f_c10 = matrix1.get(1, 0); - final int f_c01 = matrix1.get(0, 1); - final int f_c11 = matrix1.get(1, 1); - final int f_c02 = matrix1.get(0, 2); - final int f_c12 = matrix1.get(1, 2); - final int f_c03 = matrix1.get(0, 3); - final int f_c13 = matrix1.get(1, 3); - final int f_c04 = matrix1.get(0, 4); - final int f_c14 = matrix1.get(1, 4); - final int s_c00 = matrix2.get(0, 0); - final int s_c10 = matrix2.get(1, 0); - final int s_c20 = matrix2.get(2, 0); - final int s_c30 = matrix2.get(3, 0); - final int s_c01 = matrix2.get(0, 1); - final int s_c11 = matrix2.get(1, 1); - final int s_c21 = matrix2.get(2, 1); - final int s_c31 = matrix2.get(3, 1); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01); - output.set(0, 4, f_c04*s_c00 + f_c14*s_c01); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11); - output.set(1, 4, f_c04*s_c10 + f_c14*s_c11); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21); - output.set(2, 4, f_c04*s_c20 + f_c14*s_c21); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31); - output.set(3, 3, f_c03*s_c30 + f_c13*s_c31); - output.set(3, 4, f_c04*s_c30 + f_c14*s_c31); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f02 = matrix1.get(0, 2); + final int f12 = matrix1.get(1, 2); + final int f03 = matrix1.get(0, 3); + final int f13 = matrix1.get(1, 3); + final int f04 = matrix1.get(0, 4); + final int f14 = matrix1.get(1, 4); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + final int s30 = matrix2.get(3, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s21 = matrix2.get(2, 1); + final int s31 = matrix2.get(3, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(2, 0, f00 * s20 + f10 * s21); + output.set(3, 0, f00 * s30 + f10 * s31); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(1, 1, f01 * s10 + f11 * s11); + output.set(2, 1, f01 * s20 + f11 * s21); + output.set(3, 1, f01 * s30 + f11 * s31); + output.set(0, 2, f02 * s00 + f12 * s01); + output.set(1, 2, f02 * s10 + f12 * s11); + output.set(2, 2, f02 * s20 + f12 * s21); + output.set(3, 2, f02 * s30 + f12 * s31); + output.set(0, 3, f03 * s00 + f13 * s01); + output.set(1, 3, f03 * s10 + f13 * s11); + output.set(2, 3, f03 * s20 + f13 * s21); + output.set(3, 3, f03 * s30 + f13 * s31); + output.set(0, 4, f04 * s00 + f14 * s01); + output.set(1, 4, f04 * s10 + f14 * s11); + output.set(2, 4, f04 * s20 + f14 * s21); + output.set(3, 4, f04 * s30 + f14 * s31); return output; } private static IMatrixSetterInt multiplyMatrix5x2x5(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final int f_c00 = matrix1.get(0, 0); - final int f_c10 = matrix1.get(1, 0); - final int f_c01 = matrix1.get(0, 1); - final int f_c11 = matrix1.get(1, 1); - final int f_c02 = matrix1.get(0, 2); - final int f_c12 = matrix1.get(1, 2); - final int f_c03 = matrix1.get(0, 3); - final int f_c13 = matrix1.get(1, 3); - final int f_c04 = matrix1.get(0, 4); - final int f_c14 = matrix1.get(1, 4); - final int s_c00 = matrix2.get(0, 0); - final int s_c10 = matrix2.get(1, 0); - final int s_c20 = matrix2.get(2, 0); - final int s_c30 = matrix2.get(3, 0); - final int s_c40 = matrix2.get(4, 0); - final int s_c01 = matrix2.get(0, 1); - final int s_c11 = matrix2.get(1, 1); - final int s_c21 = matrix2.get(2, 1); - final int s_c31 = matrix2.get(3, 1); - final int s_c41 = matrix2.get(4, 1); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01); - output.set(0, 4, f_c04*s_c00 + f_c14*s_c01); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11); - output.set(1, 4, f_c04*s_c10 + f_c14*s_c11); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21); - output.set(2, 4, f_c04*s_c20 + f_c14*s_c21); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31); - output.set(3, 3, f_c03*s_c30 + f_c13*s_c31); - output.set(3, 4, f_c04*s_c30 + f_c14*s_c31); - output.set(4, 0, f_c00*s_c40 + f_c10*s_c41); - output.set(4, 1, f_c01*s_c40 + f_c11*s_c41); - output.set(4, 2, f_c02*s_c40 + f_c12*s_c41); - output.set(4, 3, f_c03*s_c40 + f_c13*s_c41); - output.set(4, 4, f_c04*s_c40 + f_c14*s_c41); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f02 = matrix1.get(0, 2); + final int f12 = matrix1.get(1, 2); + final int f03 = matrix1.get(0, 3); + final int f13 = matrix1.get(1, 3); + final int f04 = matrix1.get(0, 4); + final int f14 = matrix1.get(1, 4); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + final int s30 = matrix2.get(3, 0); + final int s40 = matrix2.get(4, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s21 = matrix2.get(2, 1); + final int s31 = matrix2.get(3, 1); + final int s41 = matrix2.get(4, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(2, 0, f00 * s20 + f10 * s21); + output.set(3, 0, f00 * s30 + f10 * s31); + output.set(4, 0, f00 * s40 + f10 * s41); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(1, 1, f01 * s10 + f11 * s11); + output.set(2, 1, f01 * s20 + f11 * s21); + output.set(3, 1, f01 * s30 + f11 * s31); + output.set(4, 1, f01 * s40 + f11 * s41); + output.set(0, 2, f02 * s00 + f12 * s01); + output.set(1, 2, f02 * s10 + f12 * s11); + output.set(2, 2, f02 * s20 + f12 * s21); + output.set(3, 2, f02 * s30 + f12 * s31); + output.set(4, 2, f02 * s40 + f12 * s41); + output.set(0, 3, f03 * s00 + f13 * s01); + output.set(1, 3, f03 * s10 + f13 * s11); + output.set(2, 3, f03 * s20 + f13 * s21); + output.set(3, 3, f03 * s30 + f13 * s31); + output.set(4, 3, f03 * s40 + f13 * s41); + output.set(0, 4, f04 * s00 + f14 * s01); + output.set(1, 4, f04 * s10 + f14 * s11); + output.set(2, 4, f04 * s20 + f14 * s21); + output.set(3, 4, f04 * s30 + f14 * s31); + output.set(4, 4, f04 * s40 + f14 * s41); + return output; + } + + private static IMatrixSetterInt multiplyMatrix1x3x1(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int s00 = matrix2.get(0, 0); + final int s01 = matrix2.get(0, 1); + final int s02 = matrix2.get(0, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + return output; + } + + private static IMatrixSetterInt multiplyMatrix1x3x2(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s02 = matrix2.get(0, 2); + final int s12 = matrix2.get(1, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + return output; + } + + private static IMatrixSetterInt multiplyMatrix1x3x3(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s21 = matrix2.get(2, 1); + final int s02 = matrix2.get(0, 2); + final int s12 = matrix2.get(1, 2); + final int s22 = matrix2.get(2, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22); + return output; + } + + private static IMatrixSetterInt multiplyMatrix1x3x4(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + final int s30 = matrix2.get(3, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s21 = matrix2.get(2, 1); + final int s31 = matrix2.get(3, 1); + final int s02 = matrix2.get(0, 2); + final int s12 = matrix2.get(1, 2); + final int s22 = matrix2.get(2, 2); + final int s32 = matrix2.get(3, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32); + return output; + } + + private static IMatrixSetterInt multiplyMatrix1x3x5(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + final int s30 = matrix2.get(3, 0); + final int s40 = matrix2.get(4, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s21 = matrix2.get(2, 1); + final int s31 = matrix2.get(3, 1); + final int s41 = matrix2.get(4, 1); + final int s02 = matrix2.get(0, 2); + final int s12 = matrix2.get(1, 2); + final int s22 = matrix2.get(2, 2); + final int s32 = matrix2.get(3, 2); + final int s42 = matrix2.get(4, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32); + output.set(4, 0, f00 * s40 + f10 * s41 + f20 * s42); + return output; + } + + private static IMatrixSetterInt multiplyMatrix2x3x1(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f21 = matrix1.get(2, 1); + final int s00 = matrix2.get(0, 0); + final int s01 = matrix2.get(0, 1); + final int s02 = matrix2.get(0, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); return output; } private static IMatrixSetterInt multiplyMatrix2x3x2(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final int f_c00 = matrix1.get(0, 0); - final int f_c10 = matrix1.get(1, 0); - final int f_c20 = matrix1.get(2, 0); - final int f_c01 = matrix1.get(0, 1); - final int f_c11 = matrix1.get(1, 1); - final int f_c21 = matrix1.get(2, 1); - final int s_c00 = matrix2.get(0, 0); - final int s_c10 = matrix2.get(1, 0); - final int s_c01 = matrix2.get(0, 1); - final int s_c11 = matrix2.get(1, 1); - final int s_c02 = matrix2.get(0, 2); - final int s_c12 = matrix2.get(1, 2); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f21 = matrix1.get(2, 1); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s02 = matrix2.get(0, 2); + final int s12 = matrix2.get(1, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12); return output; } private static IMatrixSetterInt multiplyMatrix2x3x3(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final int f_c00 = matrix1.get(0, 0); - final int f_c10 = matrix1.get(1, 0); - final int f_c20 = matrix1.get(2, 0); - final int f_c01 = matrix1.get(0, 1); - final int f_c11 = matrix1.get(1, 1); - final int f_c21 = matrix1.get(2, 1); - final int s_c00 = matrix2.get(0, 0); - final int s_c10 = matrix2.get(1, 0); - final int s_c20 = matrix2.get(2, 0); - final int s_c01 = matrix2.get(0, 1); - final int s_c11 = matrix2.get(1, 1); - final int s_c21 = matrix2.get(2, 1); - final int s_c02 = matrix2.get(0, 2); - final int s_c12 = matrix2.get(1, 2); - final int s_c22 = matrix2.get(2, 2); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f21 = matrix1.get(2, 1); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s21 = matrix2.get(2, 1); + final int s02 = matrix2.get(0, 2); + final int s12 = matrix2.get(1, 2); + final int s22 = matrix2.get(2, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22); return output; } private static IMatrixSetterInt multiplyMatrix2x3x4(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final int f_c00 = matrix1.get(0, 0); - final int f_c10 = matrix1.get(1, 0); - final int f_c20 = matrix1.get(2, 0); - final int f_c01 = matrix1.get(0, 1); - final int f_c11 = matrix1.get(1, 1); - final int f_c21 = matrix1.get(2, 1); - final int s_c00 = matrix2.get(0, 0); - final int s_c10 = matrix2.get(1, 0); - final int s_c20 = matrix2.get(2, 0); - final int s_c30 = matrix2.get(3, 0); - final int s_c01 = matrix2.get(0, 1); - final int s_c11 = matrix2.get(1, 1); - final int s_c21 = matrix2.get(2, 1); - final int s_c31 = matrix2.get(3, 1); - final int s_c02 = matrix2.get(0, 2); - final int s_c12 = matrix2.get(1, 2); - final int s_c22 = matrix2.get(2, 2); - final int s_c32 = matrix2.get(3, 2); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f21 = matrix1.get(2, 1); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + final int s30 = matrix2.get(3, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s21 = matrix2.get(2, 1); + final int s31 = matrix2.get(3, 1); + final int s02 = matrix2.get(0, 2); + final int s12 = matrix2.get(1, 2); + final int s22 = matrix2.get(2, 2); + final int s32 = matrix2.get(3, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32); return output; } private static IMatrixSetterInt multiplyMatrix2x3x5(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final int f_c00 = matrix1.get(0, 0); - final int f_c10 = matrix1.get(1, 0); - final int f_c20 = matrix1.get(2, 0); - final int f_c01 = matrix1.get(0, 1); - final int f_c11 = matrix1.get(1, 1); - final int f_c21 = matrix1.get(2, 1); - final int s_c00 = matrix2.get(0, 0); - final int s_c10 = matrix2.get(1, 0); - final int s_c20 = matrix2.get(2, 0); - final int s_c30 = matrix2.get(3, 0); - final int s_c40 = matrix2.get(4, 0); - final int s_c01 = matrix2.get(0, 1); - final int s_c11 = matrix2.get(1, 1); - final int s_c21 = matrix2.get(2, 1); - final int s_c31 = matrix2.get(3, 1); - final int s_c41 = matrix2.get(4, 1); - final int s_c02 = matrix2.get(0, 2); - final int s_c12 = matrix2.get(1, 2); - final int s_c22 = matrix2.get(2, 2); - final int s_c32 = matrix2.get(3, 2); - final int s_c42 = matrix2.get(4, 2); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32); - output.set(4, 0, f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42); - output.set(4, 1, f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f21 = matrix1.get(2, 1); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + final int s30 = matrix2.get(3, 0); + final int s40 = matrix2.get(4, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s21 = matrix2.get(2, 1); + final int s31 = matrix2.get(3, 1); + final int s41 = matrix2.get(4, 1); + final int s02 = matrix2.get(0, 2); + final int s12 = matrix2.get(1, 2); + final int s22 = matrix2.get(2, 2); + final int s32 = matrix2.get(3, 2); + final int s42 = matrix2.get(4, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32); + output.set(4, 0, f00 * s40 + f10 * s41 + f20 * s42); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32); + output.set(4, 1, f01 * s40 + f11 * s41 + f21 * s42); + return output; + } + + private static IMatrixSetterInt multiplyMatrix3x3x1(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f21 = matrix1.get(2, 1); + final int f02 = matrix1.get(0, 2); + final int f12 = matrix1.get(1, 2); + final int f22 = matrix1.get(2, 2); + final int s00 = matrix2.get(0, 0); + final int s01 = matrix2.get(0, 1); + final int s02 = matrix2.get(0, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02); return output; } private static IMatrixSetterInt multiplyMatrix3x3x2(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final int f_c00 = matrix1.get(0, 0); - final int f_c10 = matrix1.get(1, 0); - final int f_c20 = matrix1.get(2, 0); - final int f_c01 = matrix1.get(0, 1); - final int f_c11 = matrix1.get(1, 1); - final int f_c21 = matrix1.get(2, 1); - final int f_c02 = matrix1.get(0, 2); - final int f_c12 = matrix1.get(1, 2); - final int f_c22 = matrix1.get(2, 2); - final int s_c00 = matrix2.get(0, 0); - final int s_c10 = matrix2.get(1, 0); - final int s_c01 = matrix2.get(0, 1); - final int s_c11 = matrix2.get(1, 1); - final int s_c02 = matrix2.get(0, 2); - final int s_c12 = matrix2.get(1, 2); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f21 = matrix1.get(2, 1); + final int f02 = matrix1.get(0, 2); + final int f12 = matrix1.get(1, 2); + final int f22 = matrix1.get(2, 2); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s02 = matrix2.get(0, 2); + final int s12 = matrix2.get(1, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12); return output; } private static IMatrixSetterInt multiplyMatrix3x3x3(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final int f_c00 = matrix1.get(0, 0); - final int f_c10 = matrix1.get(1, 0); - final int f_c20 = matrix1.get(2, 0); - final int f_c01 = matrix1.get(0, 1); - final int f_c11 = matrix1.get(1, 1); - final int f_c21 = matrix1.get(2, 1); - final int f_c02 = matrix1.get(0, 2); - final int f_c12 = matrix1.get(1, 2); - final int f_c22 = matrix1.get(2, 2); - final int s_c00 = matrix2.get(0, 0); - final int s_c10 = matrix2.get(1, 0); - final int s_c20 = matrix2.get(2, 0); - final int s_c01 = matrix2.get(0, 1); - final int s_c11 = matrix2.get(1, 1); - final int s_c21 = matrix2.get(2, 1); - final int s_c02 = matrix2.get(0, 2); - final int s_c12 = matrix2.get(1, 2); - final int s_c22 = matrix2.get(2, 2); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f21 = matrix1.get(2, 1); + final int f02 = matrix1.get(0, 2); + final int f12 = matrix1.get(1, 2); + final int f22 = matrix1.get(2, 2); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s21 = matrix2.get(2, 1); + final int s02 = matrix2.get(0, 2); + final int s12 = matrix2.get(1, 2); + final int s22 = matrix2.get(2, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22); return output; } private static IMatrixSetterInt multiplyMatrix3x3x4(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final int f_c00 = matrix1.get(0, 0); - final int f_c10 = matrix1.get(1, 0); - final int f_c20 = matrix1.get(2, 0); - final int f_c01 = matrix1.get(0, 1); - final int f_c11 = matrix1.get(1, 1); - final int f_c21 = matrix1.get(2, 1); - final int f_c02 = matrix1.get(0, 2); - final int f_c12 = matrix1.get(1, 2); - final int f_c22 = matrix1.get(2, 2); - final int s_c00 = matrix2.get(0, 0); - final int s_c10 = matrix2.get(1, 0); - final int s_c20 = matrix2.get(2, 0); - final int s_c30 = matrix2.get(3, 0); - final int s_c01 = matrix2.get(0, 1); - final int s_c11 = matrix2.get(1, 1); - final int s_c21 = matrix2.get(2, 1); - final int s_c31 = matrix2.get(3, 1); - final int s_c02 = matrix2.get(0, 2); - final int s_c12 = matrix2.get(1, 2); - final int s_c22 = matrix2.get(2, 2); - final int s_c32 = matrix2.get(3, 2); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f21 = matrix1.get(2, 1); + final int f02 = matrix1.get(0, 2); + final int f12 = matrix1.get(1, 2); + final int f22 = matrix1.get(2, 2); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + final int s30 = matrix2.get(3, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s21 = matrix2.get(2, 1); + final int s31 = matrix2.get(3, 1); + final int s02 = matrix2.get(0, 2); + final int s12 = matrix2.get(1, 2); + final int s22 = matrix2.get(2, 2); + final int s32 = matrix2.get(3, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32); return output; } private static IMatrixSetterInt multiplyMatrix3x3x5(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final int f_c00 = matrix1.get(0, 0); - final int f_c10 = matrix1.get(1, 0); - final int f_c20 = matrix1.get(2, 0); - final int f_c01 = matrix1.get(0, 1); - final int f_c11 = matrix1.get(1, 1); - final int f_c21 = matrix1.get(2, 1); - final int f_c02 = matrix1.get(0, 2); - final int f_c12 = matrix1.get(1, 2); - final int f_c22 = matrix1.get(2, 2); - final int s_c00 = matrix2.get(0, 0); - final int s_c10 = matrix2.get(1, 0); - final int s_c20 = matrix2.get(2, 0); - final int s_c30 = matrix2.get(3, 0); - final int s_c40 = matrix2.get(4, 0); - final int s_c01 = matrix2.get(0, 1); - final int s_c11 = matrix2.get(1, 1); - final int s_c21 = matrix2.get(2, 1); - final int s_c31 = matrix2.get(3, 1); - final int s_c41 = matrix2.get(4, 1); - final int s_c02 = matrix2.get(0, 2); - final int s_c12 = matrix2.get(1, 2); - final int s_c22 = matrix2.get(2, 2); - final int s_c32 = matrix2.get(3, 2); - final int s_c42 = matrix2.get(4, 2); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32); - output.set(4, 0, f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42); - output.set(4, 1, f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42); - output.set(4, 2, f_c02*s_c40 + f_c12*s_c41 + f_c22*s_c42); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f21 = matrix1.get(2, 1); + final int f02 = matrix1.get(0, 2); + final int f12 = matrix1.get(1, 2); + final int f22 = matrix1.get(2, 2); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + final int s30 = matrix2.get(3, 0); + final int s40 = matrix2.get(4, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s21 = matrix2.get(2, 1); + final int s31 = matrix2.get(3, 1); + final int s41 = matrix2.get(4, 1); + final int s02 = matrix2.get(0, 2); + final int s12 = matrix2.get(1, 2); + final int s22 = matrix2.get(2, 2); + final int s32 = matrix2.get(3, 2); + final int s42 = matrix2.get(4, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32); + output.set(4, 0, f00 * s40 + f10 * s41 + f20 * s42); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32); + output.set(4, 1, f01 * s40 + f11 * s41 + f21 * s42); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32); + output.set(4, 2, f02 * s40 + f12 * s41 + f22 * s42); + return output; + } + + private static IMatrixSetterInt multiplyMatrix4x3x1(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f21 = matrix1.get(2, 1); + final int f02 = matrix1.get(0, 2); + final int f12 = matrix1.get(1, 2); + final int f22 = matrix1.get(2, 2); + final int f03 = matrix1.get(0, 3); + final int f13 = matrix1.get(1, 3); + final int f23 = matrix1.get(2, 3); + final int s00 = matrix2.get(0, 0); + final int s01 = matrix2.get(0, 1); + final int s02 = matrix2.get(0, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02); return output; } private static IMatrixSetterInt multiplyMatrix4x3x2(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final int f_c00 = matrix1.get(0, 0); - final int f_c10 = matrix1.get(1, 0); - final int f_c20 = matrix1.get(2, 0); - final int f_c01 = matrix1.get(0, 1); - final int f_c11 = matrix1.get(1, 1); - final int f_c21 = matrix1.get(2, 1); - final int f_c02 = matrix1.get(0, 2); - final int f_c12 = matrix1.get(1, 2); - final int f_c22 = matrix1.get(2, 2); - final int f_c03 = matrix1.get(0, 3); - final int f_c13 = matrix1.get(1, 3); - final int f_c23 = matrix1.get(2, 3); - final int s_c00 = matrix2.get(0, 0); - final int s_c10 = matrix2.get(1, 0); - final int s_c01 = matrix2.get(0, 1); - final int s_c11 = matrix2.get(1, 1); - final int s_c02 = matrix2.get(0, 2); - final int s_c12 = matrix2.get(1, 2); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f21 = matrix1.get(2, 1); + final int f02 = matrix1.get(0, 2); + final int f12 = matrix1.get(1, 2); + final int f22 = matrix1.get(2, 2); + final int f03 = matrix1.get(0, 3); + final int f13 = matrix1.get(1, 3); + final int f23 = matrix1.get(2, 3); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s02 = matrix2.get(0, 2); + final int s12 = matrix2.get(1, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12); return output; } private static IMatrixSetterInt multiplyMatrix4x3x3(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final int f_c00 = matrix1.get(0, 0); - final int f_c10 = matrix1.get(1, 0); - final int f_c20 = matrix1.get(2, 0); - final int f_c01 = matrix1.get(0, 1); - final int f_c11 = matrix1.get(1, 1); - final int f_c21 = matrix1.get(2, 1); - final int f_c02 = matrix1.get(0, 2); - final int f_c12 = matrix1.get(1, 2); - final int f_c22 = matrix1.get(2, 2); - final int f_c03 = matrix1.get(0, 3); - final int f_c13 = matrix1.get(1, 3); - final int f_c23 = matrix1.get(2, 3); - final int s_c00 = matrix2.get(0, 0); - final int s_c10 = matrix2.get(1, 0); - final int s_c20 = matrix2.get(2, 0); - final int s_c01 = matrix2.get(0, 1); - final int s_c11 = matrix2.get(1, 1); - final int s_c21 = matrix2.get(2, 1); - final int s_c02 = matrix2.get(0, 2); - final int s_c12 = matrix2.get(1, 2); - final int s_c22 = matrix2.get(2, 2); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f21 = matrix1.get(2, 1); + final int f02 = matrix1.get(0, 2); + final int f12 = matrix1.get(1, 2); + final int f22 = matrix1.get(2, 2); + final int f03 = matrix1.get(0, 3); + final int f13 = matrix1.get(1, 3); + final int f23 = matrix1.get(2, 3); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s21 = matrix2.get(2, 1); + final int s02 = matrix2.get(0, 2); + final int s12 = matrix2.get(1, 2); + final int s22 = matrix2.get(2, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22); return output; } private static IMatrixSetterInt multiplyMatrix4x3x4(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final int f_c00 = matrix1.get(0, 0); - final int f_c10 = matrix1.get(1, 0); - final int f_c20 = matrix1.get(2, 0); - final int f_c01 = matrix1.get(0, 1); - final int f_c11 = matrix1.get(1, 1); - final int f_c21 = matrix1.get(2, 1); - final int f_c02 = matrix1.get(0, 2); - final int f_c12 = matrix1.get(1, 2); - final int f_c22 = matrix1.get(2, 2); - final int f_c03 = matrix1.get(0, 3); - final int f_c13 = matrix1.get(1, 3); - final int f_c23 = matrix1.get(2, 3); - final int s_c00 = matrix2.get(0, 0); - final int s_c10 = matrix2.get(1, 0); - final int s_c20 = matrix2.get(2, 0); - final int s_c30 = matrix2.get(3, 0); - final int s_c01 = matrix2.get(0, 1); - final int s_c11 = matrix2.get(1, 1); - final int s_c21 = matrix2.get(2, 1); - final int s_c31 = matrix2.get(3, 1); - final int s_c02 = matrix2.get(0, 2); - final int s_c12 = matrix2.get(1, 2); - final int s_c22 = matrix2.get(2, 2); - final int s_c32 = matrix2.get(3, 2); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32); - output.set(3, 3, f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f21 = matrix1.get(2, 1); + final int f02 = matrix1.get(0, 2); + final int f12 = matrix1.get(1, 2); + final int f22 = matrix1.get(2, 2); + final int f03 = matrix1.get(0, 3); + final int f13 = matrix1.get(1, 3); + final int f23 = matrix1.get(2, 3); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + final int s30 = matrix2.get(3, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s21 = matrix2.get(2, 1); + final int s31 = matrix2.get(3, 1); + final int s02 = matrix2.get(0, 2); + final int s12 = matrix2.get(1, 2); + final int s22 = matrix2.get(2, 2); + final int s32 = matrix2.get(3, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22); + output.set(3, 3, f03 * s30 + f13 * s31 + f23 * s32); return output; } private static IMatrixSetterInt multiplyMatrix4x3x5(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final int f_c00 = matrix1.get(0, 0); - final int f_c10 = matrix1.get(1, 0); - final int f_c20 = matrix1.get(2, 0); - final int f_c01 = matrix1.get(0, 1); - final int f_c11 = matrix1.get(1, 1); - final int f_c21 = matrix1.get(2, 1); - final int f_c02 = matrix1.get(0, 2); - final int f_c12 = matrix1.get(1, 2); - final int f_c22 = matrix1.get(2, 2); - final int f_c03 = matrix1.get(0, 3); - final int f_c13 = matrix1.get(1, 3); - final int f_c23 = matrix1.get(2, 3); - final int s_c00 = matrix2.get(0, 0); - final int s_c10 = matrix2.get(1, 0); - final int s_c20 = matrix2.get(2, 0); - final int s_c30 = matrix2.get(3, 0); - final int s_c40 = matrix2.get(4, 0); - final int s_c01 = matrix2.get(0, 1); - final int s_c11 = matrix2.get(1, 1); - final int s_c21 = matrix2.get(2, 1); - final int s_c31 = matrix2.get(3, 1); - final int s_c41 = matrix2.get(4, 1); - final int s_c02 = matrix2.get(0, 2); - final int s_c12 = matrix2.get(1, 2); - final int s_c22 = matrix2.get(2, 2); - final int s_c32 = matrix2.get(3, 2); - final int s_c42 = matrix2.get(4, 2); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32); - output.set(3, 3, f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32); - output.set(4, 0, f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42); - output.set(4, 1, f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42); - output.set(4, 2, f_c02*s_c40 + f_c12*s_c41 + f_c22*s_c42); - output.set(4, 3, f_c03*s_c40 + f_c13*s_c41 + f_c23*s_c42); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f21 = matrix1.get(2, 1); + final int f02 = matrix1.get(0, 2); + final int f12 = matrix1.get(1, 2); + final int f22 = matrix1.get(2, 2); + final int f03 = matrix1.get(0, 3); + final int f13 = matrix1.get(1, 3); + final int f23 = matrix1.get(2, 3); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + final int s30 = matrix2.get(3, 0); + final int s40 = matrix2.get(4, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s21 = matrix2.get(2, 1); + final int s31 = matrix2.get(3, 1); + final int s41 = matrix2.get(4, 1); + final int s02 = matrix2.get(0, 2); + final int s12 = matrix2.get(1, 2); + final int s22 = matrix2.get(2, 2); + final int s32 = matrix2.get(3, 2); + final int s42 = matrix2.get(4, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32); + output.set(4, 0, f00 * s40 + f10 * s41 + f20 * s42); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32); + output.set(4, 1, f01 * s40 + f11 * s41 + f21 * s42); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32); + output.set(4, 2, f02 * s40 + f12 * s41 + f22 * s42); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22); + output.set(3, 3, f03 * s30 + f13 * s31 + f23 * s32); + output.set(4, 3, f03 * s40 + f13 * s41 + f23 * s42); + return output; + } + + private static IMatrixSetterInt multiplyMatrix5x3x1(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f21 = matrix1.get(2, 1); + final int f02 = matrix1.get(0, 2); + final int f12 = matrix1.get(1, 2); + final int f22 = matrix1.get(2, 2); + final int f03 = matrix1.get(0, 3); + final int f13 = matrix1.get(1, 3); + final int f23 = matrix1.get(2, 3); + final int f04 = matrix1.get(0, 4); + final int f14 = matrix1.get(1, 4); + final int f24 = matrix1.get(2, 4); + final int s00 = matrix2.get(0, 0); + final int s01 = matrix2.get(0, 1); + final int s02 = matrix2.get(0, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02); + output.set(0, 4, f04 * s00 + f14 * s01 + f24 * s02); return output; } private static IMatrixSetterInt multiplyMatrix5x3x2(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final int f_c00 = matrix1.get(0, 0); - final int f_c10 = matrix1.get(1, 0); - final int f_c20 = matrix1.get(2, 0); - final int f_c01 = matrix1.get(0, 1); - final int f_c11 = matrix1.get(1, 1); - final int f_c21 = matrix1.get(2, 1); - final int f_c02 = matrix1.get(0, 2); - final int f_c12 = matrix1.get(1, 2); - final int f_c22 = matrix1.get(2, 2); - final int f_c03 = matrix1.get(0, 3); - final int f_c13 = matrix1.get(1, 3); - final int f_c23 = matrix1.get(2, 3); - final int f_c04 = matrix1.get(0, 4); - final int f_c14 = matrix1.get(1, 4); - final int f_c24 = matrix1.get(2, 4); - final int s_c00 = matrix2.get(0, 0); - final int s_c10 = matrix2.get(1, 0); - final int s_c01 = matrix2.get(0, 1); - final int s_c11 = matrix2.get(1, 1); - final int s_c02 = matrix2.get(0, 2); - final int s_c12 = matrix2.get(1, 2); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02); - output.set(0, 4, f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12); - output.set(1, 4, f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f21 = matrix1.get(2, 1); + final int f02 = matrix1.get(0, 2); + final int f12 = matrix1.get(1, 2); + final int f22 = matrix1.get(2, 2); + final int f03 = matrix1.get(0, 3); + final int f13 = matrix1.get(1, 3); + final int f23 = matrix1.get(2, 3); + final int f04 = matrix1.get(0, 4); + final int f14 = matrix1.get(1, 4); + final int f24 = matrix1.get(2, 4); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s02 = matrix2.get(0, 2); + final int s12 = matrix2.get(1, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12); + output.set(0, 4, f04 * s00 + f14 * s01 + f24 * s02); + output.set(1, 4, f04 * s10 + f14 * s11 + f24 * s12); return output; } private static IMatrixSetterInt multiplyMatrix5x3x3(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final int f_c00 = matrix1.get(0, 0); - final int f_c10 = matrix1.get(1, 0); - final int f_c20 = matrix1.get(2, 0); - final int f_c01 = matrix1.get(0, 1); - final int f_c11 = matrix1.get(1, 1); - final int f_c21 = matrix1.get(2, 1); - final int f_c02 = matrix1.get(0, 2); - final int f_c12 = matrix1.get(1, 2); - final int f_c22 = matrix1.get(2, 2); - final int f_c03 = matrix1.get(0, 3); - final int f_c13 = matrix1.get(1, 3); - final int f_c23 = matrix1.get(2, 3); - final int f_c04 = matrix1.get(0, 4); - final int f_c14 = matrix1.get(1, 4); - final int f_c24 = matrix1.get(2, 4); - final int s_c00 = matrix2.get(0, 0); - final int s_c10 = matrix2.get(1, 0); - final int s_c20 = matrix2.get(2, 0); - final int s_c01 = matrix2.get(0, 1); - final int s_c11 = matrix2.get(1, 1); - final int s_c21 = matrix2.get(2, 1); - final int s_c02 = matrix2.get(0, 2); - final int s_c12 = matrix2.get(1, 2); - final int s_c22 = matrix2.get(2, 2); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02); - output.set(0, 4, f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12); - output.set(1, 4, f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22); - output.set(2, 4, f_c04*s_c20 + f_c14*s_c21 + f_c24*s_c22); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f21 = matrix1.get(2, 1); + final int f02 = matrix1.get(0, 2); + final int f12 = matrix1.get(1, 2); + final int f22 = matrix1.get(2, 2); + final int f03 = matrix1.get(0, 3); + final int f13 = matrix1.get(1, 3); + final int f23 = matrix1.get(2, 3); + final int f04 = matrix1.get(0, 4); + final int f14 = matrix1.get(1, 4); + final int f24 = matrix1.get(2, 4); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s21 = matrix2.get(2, 1); + final int s02 = matrix2.get(0, 2); + final int s12 = matrix2.get(1, 2); + final int s22 = matrix2.get(2, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22); + output.set(0, 4, f04 * s00 + f14 * s01 + f24 * s02); + output.set(1, 4, f04 * s10 + f14 * s11 + f24 * s12); + output.set(2, 4, f04 * s20 + f14 * s21 + f24 * s22); return output; } private static IMatrixSetterInt multiplyMatrix5x3x4(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final int f_c00 = matrix1.get(0, 0); - final int f_c10 = matrix1.get(1, 0); - final int f_c20 = matrix1.get(2, 0); - final int f_c01 = matrix1.get(0, 1); - final int f_c11 = matrix1.get(1, 1); - final int f_c21 = matrix1.get(2, 1); - final int f_c02 = matrix1.get(0, 2); - final int f_c12 = matrix1.get(1, 2); - final int f_c22 = matrix1.get(2, 2); - final int f_c03 = matrix1.get(0, 3); - final int f_c13 = matrix1.get(1, 3); - final int f_c23 = matrix1.get(2, 3); - final int f_c04 = matrix1.get(0, 4); - final int f_c14 = matrix1.get(1, 4); - final int f_c24 = matrix1.get(2, 4); - final int s_c00 = matrix2.get(0, 0); - final int s_c10 = matrix2.get(1, 0); - final int s_c20 = matrix2.get(2, 0); - final int s_c30 = matrix2.get(3, 0); - final int s_c01 = matrix2.get(0, 1); - final int s_c11 = matrix2.get(1, 1); - final int s_c21 = matrix2.get(2, 1); - final int s_c31 = matrix2.get(3, 1); - final int s_c02 = matrix2.get(0, 2); - final int s_c12 = matrix2.get(1, 2); - final int s_c22 = matrix2.get(2, 2); - final int s_c32 = matrix2.get(3, 2); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02); - output.set(0, 4, f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12); - output.set(1, 4, f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22); - output.set(2, 4, f_c04*s_c20 + f_c14*s_c21 + f_c24*s_c22); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32); - output.set(3, 3, f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32); - output.set(3, 4, f_c04*s_c30 + f_c14*s_c31 + f_c24*s_c32); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f21 = matrix1.get(2, 1); + final int f02 = matrix1.get(0, 2); + final int f12 = matrix1.get(1, 2); + final int f22 = matrix1.get(2, 2); + final int f03 = matrix1.get(0, 3); + final int f13 = matrix1.get(1, 3); + final int f23 = matrix1.get(2, 3); + final int f04 = matrix1.get(0, 4); + final int f14 = matrix1.get(1, 4); + final int f24 = matrix1.get(2, 4); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + final int s30 = matrix2.get(3, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s21 = matrix2.get(2, 1); + final int s31 = matrix2.get(3, 1); + final int s02 = matrix2.get(0, 2); + final int s12 = matrix2.get(1, 2); + final int s22 = matrix2.get(2, 2); + final int s32 = matrix2.get(3, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22); + output.set(3, 3, f03 * s30 + f13 * s31 + f23 * s32); + output.set(0, 4, f04 * s00 + f14 * s01 + f24 * s02); + output.set(1, 4, f04 * s10 + f14 * s11 + f24 * s12); + output.set(2, 4, f04 * s20 + f14 * s21 + f24 * s22); + output.set(3, 4, f04 * s30 + f14 * s31 + f24 * s32); return output; } private static IMatrixSetterInt multiplyMatrix5x3x5(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final int f_c00 = matrix1.get(0, 0); - final int f_c10 = matrix1.get(1, 0); - final int f_c20 = matrix1.get(2, 0); - final int f_c01 = matrix1.get(0, 1); - final int f_c11 = matrix1.get(1, 1); - final int f_c21 = matrix1.get(2, 1); - final int f_c02 = matrix1.get(0, 2); - final int f_c12 = matrix1.get(1, 2); - final int f_c22 = matrix1.get(2, 2); - final int f_c03 = matrix1.get(0, 3); - final int f_c13 = matrix1.get(1, 3); - final int f_c23 = matrix1.get(2, 3); - final int f_c04 = matrix1.get(0, 4); - final int f_c14 = matrix1.get(1, 4); - final int f_c24 = matrix1.get(2, 4); - final int s_c00 = matrix2.get(0, 0); - final int s_c10 = matrix2.get(1, 0); - final int s_c20 = matrix2.get(2, 0); - final int s_c30 = matrix2.get(3, 0); - final int s_c40 = matrix2.get(4, 0); - final int s_c01 = matrix2.get(0, 1); - final int s_c11 = matrix2.get(1, 1); - final int s_c21 = matrix2.get(2, 1); - final int s_c31 = matrix2.get(3, 1); - final int s_c41 = matrix2.get(4, 1); - final int s_c02 = matrix2.get(0, 2); - final int s_c12 = matrix2.get(1, 2); - final int s_c22 = matrix2.get(2, 2); - final int s_c32 = matrix2.get(3, 2); - final int s_c42 = matrix2.get(4, 2); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02); - output.set(0, 4, f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12); - output.set(1, 4, f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22); - output.set(2, 4, f_c04*s_c20 + f_c14*s_c21 + f_c24*s_c22); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32); - output.set(3, 3, f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32); - output.set(3, 4, f_c04*s_c30 + f_c14*s_c31 + f_c24*s_c32); - output.set(4, 0, f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42); - output.set(4, 1, f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42); - output.set(4, 2, f_c02*s_c40 + f_c12*s_c41 + f_c22*s_c42); - output.set(4, 3, f_c03*s_c40 + f_c13*s_c41 + f_c23*s_c42); - output.set(4, 4, f_c04*s_c40 + f_c14*s_c41 + f_c24*s_c42); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f21 = matrix1.get(2, 1); + final int f02 = matrix1.get(0, 2); + final int f12 = matrix1.get(1, 2); + final int f22 = matrix1.get(2, 2); + final int f03 = matrix1.get(0, 3); + final int f13 = matrix1.get(1, 3); + final int f23 = matrix1.get(2, 3); + final int f04 = matrix1.get(0, 4); + final int f14 = matrix1.get(1, 4); + final int f24 = matrix1.get(2, 4); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + final int s30 = matrix2.get(3, 0); + final int s40 = matrix2.get(4, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s21 = matrix2.get(2, 1); + final int s31 = matrix2.get(3, 1); + final int s41 = matrix2.get(4, 1); + final int s02 = matrix2.get(0, 2); + final int s12 = matrix2.get(1, 2); + final int s22 = matrix2.get(2, 2); + final int s32 = matrix2.get(3, 2); + final int s42 = matrix2.get(4, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32); + output.set(4, 0, f00 * s40 + f10 * s41 + f20 * s42); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32); + output.set(4, 1, f01 * s40 + f11 * s41 + f21 * s42); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32); + output.set(4, 2, f02 * s40 + f12 * s41 + f22 * s42); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22); + output.set(3, 3, f03 * s30 + f13 * s31 + f23 * s32); + output.set(4, 3, f03 * s40 + f13 * s41 + f23 * s42); + output.set(0, 4, f04 * s00 + f14 * s01 + f24 * s02); + output.set(1, 4, f04 * s10 + f14 * s11 + f24 * s12); + output.set(2, 4, f04 * s20 + f14 * s21 + f24 * s22); + output.set(3, 4, f04 * s30 + f14 * s31 + f24 * s32); + output.set(4, 4, f04 * s40 + f14 * s41 + f24 * s42); + return output; + } + + private static IMatrixSetterInt multiplyMatrix1x4x1(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int f30 = matrix1.get(3, 0); + final int s00 = matrix2.get(0, 0); + final int s01 = matrix2.get(0, 1); + final int s02 = matrix2.get(0, 2); + final int s03 = matrix2.get(0, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + return output; + } + + private static IMatrixSetterInt multiplyMatrix1x4x2(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int f30 = matrix1.get(3, 0); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s02 = matrix2.get(0, 2); + final int s12 = matrix2.get(1, 2); + final int s03 = matrix2.get(0, 3); + final int s13 = matrix2.get(1, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + return output; + } + + private static IMatrixSetterInt multiplyMatrix1x4x3(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int f30 = matrix1.get(3, 0); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s21 = matrix2.get(2, 1); + final int s02 = matrix2.get(0, 2); + final int s12 = matrix2.get(1, 2); + final int s22 = matrix2.get(2, 2); + final int s03 = matrix2.get(0, 3); + final int s13 = matrix2.get(1, 3); + final int s23 = matrix2.get(2, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23); + return output; + } + + private static IMatrixSetterInt multiplyMatrix1x4x4(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int f30 = matrix1.get(3, 0); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + final int s30 = matrix2.get(3, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s21 = matrix2.get(2, 1); + final int s31 = matrix2.get(3, 1); + final int s02 = matrix2.get(0, 2); + final int s12 = matrix2.get(1, 2); + final int s22 = matrix2.get(2, 2); + final int s32 = matrix2.get(3, 2); + final int s03 = matrix2.get(0, 3); + final int s13 = matrix2.get(1, 3); + final int s23 = matrix2.get(2, 3); + final int s33 = matrix2.get(3, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33); + return output; + } + + private static IMatrixSetterInt multiplyMatrix1x4x5(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int f30 = matrix1.get(3, 0); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + final int s30 = matrix2.get(3, 0); + final int s40 = matrix2.get(4, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s21 = matrix2.get(2, 1); + final int s31 = matrix2.get(3, 1); + final int s41 = matrix2.get(4, 1); + final int s02 = matrix2.get(0, 2); + final int s12 = matrix2.get(1, 2); + final int s22 = matrix2.get(2, 2); + final int s32 = matrix2.get(3, 2); + final int s42 = matrix2.get(4, 2); + final int s03 = matrix2.get(0, 3); + final int s13 = matrix2.get(1, 3); + final int s23 = matrix2.get(2, 3); + final int s33 = matrix2.get(3, 3); + final int s43 = matrix2.get(4, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33); + output.set(4, 0, f00 * s40 + f10 * s41 + f20 * s42 + f30 * s43); + return output; + } + + private static IMatrixSetterInt multiplyMatrix2x4x1(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int f30 = matrix1.get(3, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f21 = matrix1.get(2, 1); + final int f31 = matrix1.get(3, 1); + final int s00 = matrix2.get(0, 0); + final int s01 = matrix2.get(0, 1); + final int s02 = matrix2.get(0, 2); + final int s03 = matrix2.get(0, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); return output; } private static IMatrixSetterInt multiplyMatrix2x4x2(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final int f_c00 = matrix1.get(0, 0); - final int f_c10 = matrix1.get(1, 0); - final int f_c20 = matrix1.get(2, 0); - final int f_c30 = matrix1.get(3, 0); - final int f_c01 = matrix1.get(0, 1); - final int f_c11 = matrix1.get(1, 1); - final int f_c21 = matrix1.get(2, 1); - final int f_c31 = matrix1.get(3, 1); - final int s_c00 = matrix2.get(0, 0); - final int s_c10 = matrix2.get(1, 0); - final int s_c01 = matrix2.get(0, 1); - final int s_c11 = matrix2.get(1, 1); - final int s_c02 = matrix2.get(0, 2); - final int s_c12 = matrix2.get(1, 2); - final int s_c03 = matrix2.get(0, 3); - final int s_c13 = matrix2.get(1, 3); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int f30 = matrix1.get(3, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f21 = matrix1.get(2, 1); + final int f31 = matrix1.get(3, 1); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s02 = matrix2.get(0, 2); + final int s12 = matrix2.get(1, 2); + final int s03 = matrix2.get(0, 3); + final int s13 = matrix2.get(1, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13); return output; } private static IMatrixSetterInt multiplyMatrix2x4x3(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final int f_c00 = matrix1.get(0, 0); - final int f_c10 = matrix1.get(1, 0); - final int f_c20 = matrix1.get(2, 0); - final int f_c30 = matrix1.get(3, 0); - final int f_c01 = matrix1.get(0, 1); - final int f_c11 = matrix1.get(1, 1); - final int f_c21 = matrix1.get(2, 1); - final int f_c31 = matrix1.get(3, 1); - final int s_c00 = matrix2.get(0, 0); - final int s_c10 = matrix2.get(1, 0); - final int s_c20 = matrix2.get(2, 0); - final int s_c01 = matrix2.get(0, 1); - final int s_c11 = matrix2.get(1, 1); - final int s_c21 = matrix2.get(2, 1); - final int s_c02 = matrix2.get(0, 2); - final int s_c12 = matrix2.get(1, 2); - final int s_c22 = matrix2.get(2, 2); - final int s_c03 = matrix2.get(0, 3); - final int s_c13 = matrix2.get(1, 3); - final int s_c23 = matrix2.get(2, 3); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int f30 = matrix1.get(3, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f21 = matrix1.get(2, 1); + final int f31 = matrix1.get(3, 1); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s21 = matrix2.get(2, 1); + final int s02 = matrix2.get(0, 2); + final int s12 = matrix2.get(1, 2); + final int s22 = matrix2.get(2, 2); + final int s03 = matrix2.get(0, 3); + final int s13 = matrix2.get(1, 3); + final int s23 = matrix2.get(2, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23); return output; } private static IMatrixSetterInt multiplyMatrix2x4x4(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final int f_c00 = matrix1.get(0, 0); - final int f_c10 = matrix1.get(1, 0); - final int f_c20 = matrix1.get(2, 0); - final int f_c30 = matrix1.get(3, 0); - final int f_c01 = matrix1.get(0, 1); - final int f_c11 = matrix1.get(1, 1); - final int f_c21 = matrix1.get(2, 1); - final int f_c31 = matrix1.get(3, 1); - final int s_c00 = matrix2.get(0, 0); - final int s_c10 = matrix2.get(1, 0); - final int s_c20 = matrix2.get(2, 0); - final int s_c30 = matrix2.get(3, 0); - final int s_c01 = matrix2.get(0, 1); - final int s_c11 = matrix2.get(1, 1); - final int s_c21 = matrix2.get(2, 1); - final int s_c31 = matrix2.get(3, 1); - final int s_c02 = matrix2.get(0, 2); - final int s_c12 = matrix2.get(1, 2); - final int s_c22 = matrix2.get(2, 2); - final int s_c32 = matrix2.get(3, 2); - final int s_c03 = matrix2.get(0, 3); - final int s_c13 = matrix2.get(1, 3); - final int s_c23 = matrix2.get(2, 3); - final int s_c33 = matrix2.get(3, 3); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int f30 = matrix1.get(3, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f21 = matrix1.get(2, 1); + final int f31 = matrix1.get(3, 1); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + final int s30 = matrix2.get(3, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s21 = matrix2.get(2, 1); + final int s31 = matrix2.get(3, 1); + final int s02 = matrix2.get(0, 2); + final int s12 = matrix2.get(1, 2); + final int s22 = matrix2.get(2, 2); + final int s32 = matrix2.get(3, 2); + final int s03 = matrix2.get(0, 3); + final int s13 = matrix2.get(1, 3); + final int s23 = matrix2.get(2, 3); + final int s33 = matrix2.get(3, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33); return output; } private static IMatrixSetterInt multiplyMatrix2x4x5(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final int f_c00 = matrix1.get(0, 0); - final int f_c10 = matrix1.get(1, 0); - final int f_c20 = matrix1.get(2, 0); - final int f_c30 = matrix1.get(3, 0); - final int f_c01 = matrix1.get(0, 1); - final int f_c11 = matrix1.get(1, 1); - final int f_c21 = matrix1.get(2, 1); - final int f_c31 = matrix1.get(3, 1); - final int s_c00 = matrix2.get(0, 0); - final int s_c10 = matrix2.get(1, 0); - final int s_c20 = matrix2.get(2, 0); - final int s_c30 = matrix2.get(3, 0); - final int s_c40 = matrix2.get(4, 0); - final int s_c01 = matrix2.get(0, 1); - final int s_c11 = matrix2.get(1, 1); - final int s_c21 = matrix2.get(2, 1); - final int s_c31 = matrix2.get(3, 1); - final int s_c41 = matrix2.get(4, 1); - final int s_c02 = matrix2.get(0, 2); - final int s_c12 = matrix2.get(1, 2); - final int s_c22 = matrix2.get(2, 2); - final int s_c32 = matrix2.get(3, 2); - final int s_c42 = matrix2.get(4, 2); - final int s_c03 = matrix2.get(0, 3); - final int s_c13 = matrix2.get(1, 3); - final int s_c23 = matrix2.get(2, 3); - final int s_c33 = matrix2.get(3, 3); - final int s_c43 = matrix2.get(4, 3); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33); - output.set(4, 0, f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42 + f_c30*s_c43); - output.set(4, 1, f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42 + f_c31*s_c43); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int f30 = matrix1.get(3, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f21 = matrix1.get(2, 1); + final int f31 = matrix1.get(3, 1); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + final int s30 = matrix2.get(3, 0); + final int s40 = matrix2.get(4, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s21 = matrix2.get(2, 1); + final int s31 = matrix2.get(3, 1); + final int s41 = matrix2.get(4, 1); + final int s02 = matrix2.get(0, 2); + final int s12 = matrix2.get(1, 2); + final int s22 = matrix2.get(2, 2); + final int s32 = matrix2.get(3, 2); + final int s42 = matrix2.get(4, 2); + final int s03 = matrix2.get(0, 3); + final int s13 = matrix2.get(1, 3); + final int s23 = matrix2.get(2, 3); + final int s33 = matrix2.get(3, 3); + final int s43 = matrix2.get(4, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33); + output.set(4, 0, f00 * s40 + f10 * s41 + f20 * s42 + f30 * s43); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33); + output.set(4, 1, f01 * s40 + f11 * s41 + f21 * s42 + f31 * s43); + return output; + } + + private static IMatrixSetterInt multiplyMatrix3x4x1(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int f30 = matrix1.get(3, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f21 = matrix1.get(2, 1); + final int f31 = matrix1.get(3, 1); + final int f02 = matrix1.get(0, 2); + final int f12 = matrix1.get(1, 2); + final int f22 = matrix1.get(2, 2); + final int f32 = matrix1.get(3, 2); + final int s00 = matrix2.get(0, 0); + final int s01 = matrix2.get(0, 1); + final int s02 = matrix2.get(0, 2); + final int s03 = matrix2.get(0, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03); return output; } private static IMatrixSetterInt multiplyMatrix3x4x2(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final int f_c00 = matrix1.get(0, 0); - final int f_c10 = matrix1.get(1, 0); - final int f_c20 = matrix1.get(2, 0); - final int f_c30 = matrix1.get(3, 0); - final int f_c01 = matrix1.get(0, 1); - final int f_c11 = matrix1.get(1, 1); - final int f_c21 = matrix1.get(2, 1); - final int f_c31 = matrix1.get(3, 1); - final int f_c02 = matrix1.get(0, 2); - final int f_c12 = matrix1.get(1, 2); - final int f_c22 = matrix1.get(2, 2); - final int f_c32 = matrix1.get(3, 2); - final int s_c00 = matrix2.get(0, 0); - final int s_c10 = matrix2.get(1, 0); - final int s_c01 = matrix2.get(0, 1); - final int s_c11 = matrix2.get(1, 1); - final int s_c02 = matrix2.get(0, 2); - final int s_c12 = matrix2.get(1, 2); - final int s_c03 = matrix2.get(0, 3); - final int s_c13 = matrix2.get(1, 3); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int f30 = matrix1.get(3, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f21 = matrix1.get(2, 1); + final int f31 = matrix1.get(3, 1); + final int f02 = matrix1.get(0, 2); + final int f12 = matrix1.get(1, 2); + final int f22 = matrix1.get(2, 2); + final int f32 = matrix1.get(3, 2); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s02 = matrix2.get(0, 2); + final int s12 = matrix2.get(1, 2); + final int s03 = matrix2.get(0, 3); + final int s13 = matrix2.get(1, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13); return output; } private static IMatrixSetterInt multiplyMatrix3x4x3(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final int f_c00 = matrix1.get(0, 0); - final int f_c10 = matrix1.get(1, 0); - final int f_c20 = matrix1.get(2, 0); - final int f_c30 = matrix1.get(3, 0); - final int f_c01 = matrix1.get(0, 1); - final int f_c11 = matrix1.get(1, 1); - final int f_c21 = matrix1.get(2, 1); - final int f_c31 = matrix1.get(3, 1); - final int f_c02 = matrix1.get(0, 2); - final int f_c12 = matrix1.get(1, 2); - final int f_c22 = matrix1.get(2, 2); - final int f_c32 = matrix1.get(3, 2); - final int s_c00 = matrix2.get(0, 0); - final int s_c10 = matrix2.get(1, 0); - final int s_c20 = matrix2.get(2, 0); - final int s_c01 = matrix2.get(0, 1); - final int s_c11 = matrix2.get(1, 1); - final int s_c21 = matrix2.get(2, 1); - final int s_c02 = matrix2.get(0, 2); - final int s_c12 = matrix2.get(1, 2); - final int s_c22 = matrix2.get(2, 2); - final int s_c03 = matrix2.get(0, 3); - final int s_c13 = matrix2.get(1, 3); - final int s_c23 = matrix2.get(2, 3); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int f30 = matrix1.get(3, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f21 = matrix1.get(2, 1); + final int f31 = matrix1.get(3, 1); + final int f02 = matrix1.get(0, 2); + final int f12 = matrix1.get(1, 2); + final int f22 = matrix1.get(2, 2); + final int f32 = matrix1.get(3, 2); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s21 = matrix2.get(2, 1); + final int s02 = matrix2.get(0, 2); + final int s12 = matrix2.get(1, 2); + final int s22 = matrix2.get(2, 2); + final int s03 = matrix2.get(0, 3); + final int s13 = matrix2.get(1, 3); + final int s23 = matrix2.get(2, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23); return output; } private static IMatrixSetterInt multiplyMatrix3x4x4(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final int f_c00 = matrix1.get(0, 0); - final int f_c10 = matrix1.get(1, 0); - final int f_c20 = matrix1.get(2, 0); - final int f_c30 = matrix1.get(3, 0); - final int f_c01 = matrix1.get(0, 1); - final int f_c11 = matrix1.get(1, 1); - final int f_c21 = matrix1.get(2, 1); - final int f_c31 = matrix1.get(3, 1); - final int f_c02 = matrix1.get(0, 2); - final int f_c12 = matrix1.get(1, 2); - final int f_c22 = matrix1.get(2, 2); - final int f_c32 = matrix1.get(3, 2); - final int s_c00 = matrix2.get(0, 0); - final int s_c10 = matrix2.get(1, 0); - final int s_c20 = matrix2.get(2, 0); - final int s_c30 = matrix2.get(3, 0); - final int s_c01 = matrix2.get(0, 1); - final int s_c11 = matrix2.get(1, 1); - final int s_c21 = matrix2.get(2, 1); - final int s_c31 = matrix2.get(3, 1); - final int s_c02 = matrix2.get(0, 2); - final int s_c12 = matrix2.get(1, 2); - final int s_c22 = matrix2.get(2, 2); - final int s_c32 = matrix2.get(3, 2); - final int s_c03 = matrix2.get(0, 3); - final int s_c13 = matrix2.get(1, 3); - final int s_c23 = matrix2.get(2, 3); - final int s_c33 = matrix2.get(3, 3); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int f30 = matrix1.get(3, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f21 = matrix1.get(2, 1); + final int f31 = matrix1.get(3, 1); + final int f02 = matrix1.get(0, 2); + final int f12 = matrix1.get(1, 2); + final int f22 = matrix1.get(2, 2); + final int f32 = matrix1.get(3, 2); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + final int s30 = matrix2.get(3, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s21 = matrix2.get(2, 1); + final int s31 = matrix2.get(3, 1); + final int s02 = matrix2.get(0, 2); + final int s12 = matrix2.get(1, 2); + final int s22 = matrix2.get(2, 2); + final int s32 = matrix2.get(3, 2); + final int s03 = matrix2.get(0, 3); + final int s13 = matrix2.get(1, 3); + final int s23 = matrix2.get(2, 3); + final int s33 = matrix2.get(3, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33); return output; } private static IMatrixSetterInt multiplyMatrix3x4x5(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final int f_c00 = matrix1.get(0, 0); - final int f_c10 = matrix1.get(1, 0); - final int f_c20 = matrix1.get(2, 0); - final int f_c30 = matrix1.get(3, 0); - final int f_c01 = matrix1.get(0, 1); - final int f_c11 = matrix1.get(1, 1); - final int f_c21 = matrix1.get(2, 1); - final int f_c31 = matrix1.get(3, 1); - final int f_c02 = matrix1.get(0, 2); - final int f_c12 = matrix1.get(1, 2); - final int f_c22 = matrix1.get(2, 2); - final int f_c32 = matrix1.get(3, 2); - final int s_c00 = matrix2.get(0, 0); - final int s_c10 = matrix2.get(1, 0); - final int s_c20 = matrix2.get(2, 0); - final int s_c30 = matrix2.get(3, 0); - final int s_c40 = matrix2.get(4, 0); - final int s_c01 = matrix2.get(0, 1); - final int s_c11 = matrix2.get(1, 1); - final int s_c21 = matrix2.get(2, 1); - final int s_c31 = matrix2.get(3, 1); - final int s_c41 = matrix2.get(4, 1); - final int s_c02 = matrix2.get(0, 2); - final int s_c12 = matrix2.get(1, 2); - final int s_c22 = matrix2.get(2, 2); - final int s_c32 = matrix2.get(3, 2); - final int s_c42 = matrix2.get(4, 2); - final int s_c03 = matrix2.get(0, 3); - final int s_c13 = matrix2.get(1, 3); - final int s_c23 = matrix2.get(2, 3); - final int s_c33 = matrix2.get(3, 3); - final int s_c43 = matrix2.get(4, 3); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33); - output.set(4, 0, f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42 + f_c30*s_c43); - output.set(4, 1, f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42 + f_c31*s_c43); - output.set(4, 2, f_c02*s_c40 + f_c12*s_c41 + f_c22*s_c42 + f_c32*s_c43); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int f30 = matrix1.get(3, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f21 = matrix1.get(2, 1); + final int f31 = matrix1.get(3, 1); + final int f02 = matrix1.get(0, 2); + final int f12 = matrix1.get(1, 2); + final int f22 = matrix1.get(2, 2); + final int f32 = matrix1.get(3, 2); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + final int s30 = matrix2.get(3, 0); + final int s40 = matrix2.get(4, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s21 = matrix2.get(2, 1); + final int s31 = matrix2.get(3, 1); + final int s41 = matrix2.get(4, 1); + final int s02 = matrix2.get(0, 2); + final int s12 = matrix2.get(1, 2); + final int s22 = matrix2.get(2, 2); + final int s32 = matrix2.get(3, 2); + final int s42 = matrix2.get(4, 2); + final int s03 = matrix2.get(0, 3); + final int s13 = matrix2.get(1, 3); + final int s23 = matrix2.get(2, 3); + final int s33 = matrix2.get(3, 3); + final int s43 = matrix2.get(4, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33); + output.set(4, 0, f00 * s40 + f10 * s41 + f20 * s42 + f30 * s43); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33); + output.set(4, 1, f01 * s40 + f11 * s41 + f21 * s42 + f31 * s43); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33); + output.set(4, 2, f02 * s40 + f12 * s41 + f22 * s42 + f32 * s43); + return output; + } + + private static IMatrixSetterInt multiplyMatrix4x4x1(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int f30 = matrix1.get(3, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f21 = matrix1.get(2, 1); + final int f31 = matrix1.get(3, 1); + final int f02 = matrix1.get(0, 2); + final int f12 = matrix1.get(1, 2); + final int f22 = matrix1.get(2, 2); + final int f32 = matrix1.get(3, 2); + final int f03 = matrix1.get(0, 3); + final int f13 = matrix1.get(1, 3); + final int f23 = matrix1.get(2, 3); + final int f33 = matrix1.get(3, 3); + final int s00 = matrix2.get(0, 0); + final int s01 = matrix2.get(0, 1); + final int s02 = matrix2.get(0, 2); + final int s03 = matrix2.get(0, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03); return output; } private static IMatrixSetterInt multiplyMatrix4x4x2(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final int f_c00 = matrix1.get(0, 0); - final int f_c10 = matrix1.get(1, 0); - final int f_c20 = matrix1.get(2, 0); - final int f_c30 = matrix1.get(3, 0); - final int f_c01 = matrix1.get(0, 1); - final int f_c11 = matrix1.get(1, 1); - final int f_c21 = matrix1.get(2, 1); - final int f_c31 = matrix1.get(3, 1); - final int f_c02 = matrix1.get(0, 2); - final int f_c12 = matrix1.get(1, 2); - final int f_c22 = matrix1.get(2, 2); - final int f_c32 = matrix1.get(3, 2); - final int f_c03 = matrix1.get(0, 3); - final int f_c13 = matrix1.get(1, 3); - final int f_c23 = matrix1.get(2, 3); - final int f_c33 = matrix1.get(3, 3); - final int s_c00 = matrix2.get(0, 0); - final int s_c10 = matrix2.get(1, 0); - final int s_c01 = matrix2.get(0, 1); - final int s_c11 = matrix2.get(1, 1); - final int s_c02 = matrix2.get(0, 2); - final int s_c12 = matrix2.get(1, 2); - final int s_c03 = matrix2.get(0, 3); - final int s_c13 = matrix2.get(1, 3); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int f30 = matrix1.get(3, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f21 = matrix1.get(2, 1); + final int f31 = matrix1.get(3, 1); + final int f02 = matrix1.get(0, 2); + final int f12 = matrix1.get(1, 2); + final int f22 = matrix1.get(2, 2); + final int f32 = matrix1.get(3, 2); + final int f03 = matrix1.get(0, 3); + final int f13 = matrix1.get(1, 3); + final int f23 = matrix1.get(2, 3); + final int f33 = matrix1.get(3, 3); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s02 = matrix2.get(0, 2); + final int s12 = matrix2.get(1, 2); + final int s03 = matrix2.get(0, 3); + final int s13 = matrix2.get(1, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13); return output; } private static IMatrixSetterInt multiplyMatrix4x4x3(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final int f_c00 = matrix1.get(0, 0); - final int f_c10 = matrix1.get(1, 0); - final int f_c20 = matrix1.get(2, 0); - final int f_c30 = matrix1.get(3, 0); - final int f_c01 = matrix1.get(0, 1); - final int f_c11 = matrix1.get(1, 1); - final int f_c21 = matrix1.get(2, 1); - final int f_c31 = matrix1.get(3, 1); - final int f_c02 = matrix1.get(0, 2); - final int f_c12 = matrix1.get(1, 2); - final int f_c22 = matrix1.get(2, 2); - final int f_c32 = matrix1.get(3, 2); - final int f_c03 = matrix1.get(0, 3); - final int f_c13 = matrix1.get(1, 3); - final int f_c23 = matrix1.get(2, 3); - final int f_c33 = matrix1.get(3, 3); - final int s_c00 = matrix2.get(0, 0); - final int s_c10 = matrix2.get(1, 0); - final int s_c20 = matrix2.get(2, 0); - final int s_c01 = matrix2.get(0, 1); - final int s_c11 = matrix2.get(1, 1); - final int s_c21 = matrix2.get(2, 1); - final int s_c02 = matrix2.get(0, 2); - final int s_c12 = matrix2.get(1, 2); - final int s_c22 = matrix2.get(2, 2); - final int s_c03 = matrix2.get(0, 3); - final int s_c13 = matrix2.get(1, 3); - final int s_c23 = matrix2.get(2, 3); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int f30 = matrix1.get(3, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f21 = matrix1.get(2, 1); + final int f31 = matrix1.get(3, 1); + final int f02 = matrix1.get(0, 2); + final int f12 = matrix1.get(1, 2); + final int f22 = matrix1.get(2, 2); + final int f32 = matrix1.get(3, 2); + final int f03 = matrix1.get(0, 3); + final int f13 = matrix1.get(1, 3); + final int f23 = matrix1.get(2, 3); + final int f33 = matrix1.get(3, 3); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s21 = matrix2.get(2, 1); + final int s02 = matrix2.get(0, 2); + final int s12 = matrix2.get(1, 2); + final int s22 = matrix2.get(2, 2); + final int s03 = matrix2.get(0, 3); + final int s13 = matrix2.get(1, 3); + final int s23 = matrix2.get(2, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23); return output; } private static IMatrixSetterInt multiplyMatrix4x4x4(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final int f_c00 = matrix1.get(0, 0); - final int f_c10 = matrix1.get(1, 0); - final int f_c20 = matrix1.get(2, 0); - final int f_c30 = matrix1.get(3, 0); - final int f_c01 = matrix1.get(0, 1); - final int f_c11 = matrix1.get(1, 1); - final int f_c21 = matrix1.get(2, 1); - final int f_c31 = matrix1.get(3, 1); - final int f_c02 = matrix1.get(0, 2); - final int f_c12 = matrix1.get(1, 2); - final int f_c22 = matrix1.get(2, 2); - final int f_c32 = matrix1.get(3, 2); - final int f_c03 = matrix1.get(0, 3); - final int f_c13 = matrix1.get(1, 3); - final int f_c23 = matrix1.get(2, 3); - final int f_c33 = matrix1.get(3, 3); - final int s_c00 = matrix2.get(0, 0); - final int s_c10 = matrix2.get(1, 0); - final int s_c20 = matrix2.get(2, 0); - final int s_c30 = matrix2.get(3, 0); - final int s_c01 = matrix2.get(0, 1); - final int s_c11 = matrix2.get(1, 1); - final int s_c21 = matrix2.get(2, 1); - final int s_c31 = matrix2.get(3, 1); - final int s_c02 = matrix2.get(0, 2); - final int s_c12 = matrix2.get(1, 2); - final int s_c22 = matrix2.get(2, 2); - final int s_c32 = matrix2.get(3, 2); - final int s_c03 = matrix2.get(0, 3); - final int s_c13 = matrix2.get(1, 3); - final int s_c23 = matrix2.get(2, 3); - final int s_c33 = matrix2.get(3, 3); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33); - output.set(3, 3, f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32 + f_c33*s_c33); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int f30 = matrix1.get(3, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f21 = matrix1.get(2, 1); + final int f31 = matrix1.get(3, 1); + final int f02 = matrix1.get(0, 2); + final int f12 = matrix1.get(1, 2); + final int f22 = matrix1.get(2, 2); + final int f32 = matrix1.get(3, 2); + final int f03 = matrix1.get(0, 3); + final int f13 = matrix1.get(1, 3); + final int f23 = matrix1.get(2, 3); + final int f33 = matrix1.get(3, 3); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + final int s30 = matrix2.get(3, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s21 = matrix2.get(2, 1); + final int s31 = matrix2.get(3, 1); + final int s02 = matrix2.get(0, 2); + final int s12 = matrix2.get(1, 2); + final int s22 = matrix2.get(2, 2); + final int s32 = matrix2.get(3, 2); + final int s03 = matrix2.get(0, 3); + final int s13 = matrix2.get(1, 3); + final int s23 = matrix2.get(2, 3); + final int s33 = matrix2.get(3, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23); + output.set(3, 3, f03 * s30 + f13 * s31 + f23 * s32 + f33 * s33); return output; } private static IMatrixSetterInt multiplyMatrix4x4x5(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final int f_c00 = matrix1.get(0, 0); - final int f_c10 = matrix1.get(1, 0); - final int f_c20 = matrix1.get(2, 0); - final int f_c30 = matrix1.get(3, 0); - final int f_c01 = matrix1.get(0, 1); - final int f_c11 = matrix1.get(1, 1); - final int f_c21 = matrix1.get(2, 1); - final int f_c31 = matrix1.get(3, 1); - final int f_c02 = matrix1.get(0, 2); - final int f_c12 = matrix1.get(1, 2); - final int f_c22 = matrix1.get(2, 2); - final int f_c32 = matrix1.get(3, 2); - final int f_c03 = matrix1.get(0, 3); - final int f_c13 = matrix1.get(1, 3); - final int f_c23 = matrix1.get(2, 3); - final int f_c33 = matrix1.get(3, 3); - final int s_c00 = matrix2.get(0, 0); - final int s_c10 = matrix2.get(1, 0); - final int s_c20 = matrix2.get(2, 0); - final int s_c30 = matrix2.get(3, 0); - final int s_c40 = matrix2.get(4, 0); - final int s_c01 = matrix2.get(0, 1); - final int s_c11 = matrix2.get(1, 1); - final int s_c21 = matrix2.get(2, 1); - final int s_c31 = matrix2.get(3, 1); - final int s_c41 = matrix2.get(4, 1); - final int s_c02 = matrix2.get(0, 2); - final int s_c12 = matrix2.get(1, 2); - final int s_c22 = matrix2.get(2, 2); - final int s_c32 = matrix2.get(3, 2); - final int s_c42 = matrix2.get(4, 2); - final int s_c03 = matrix2.get(0, 3); - final int s_c13 = matrix2.get(1, 3); - final int s_c23 = matrix2.get(2, 3); - final int s_c33 = matrix2.get(3, 3); - final int s_c43 = matrix2.get(4, 3); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33); - output.set(3, 3, f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32 + f_c33*s_c33); - output.set(4, 0, f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42 + f_c30*s_c43); - output.set(4, 1, f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42 + f_c31*s_c43); - output.set(4, 2, f_c02*s_c40 + f_c12*s_c41 + f_c22*s_c42 + f_c32*s_c43); - output.set(4, 3, f_c03*s_c40 + f_c13*s_c41 + f_c23*s_c42 + f_c33*s_c43); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int f30 = matrix1.get(3, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f21 = matrix1.get(2, 1); + final int f31 = matrix1.get(3, 1); + final int f02 = matrix1.get(0, 2); + final int f12 = matrix1.get(1, 2); + final int f22 = matrix1.get(2, 2); + final int f32 = matrix1.get(3, 2); + final int f03 = matrix1.get(0, 3); + final int f13 = matrix1.get(1, 3); + final int f23 = matrix1.get(2, 3); + final int f33 = matrix1.get(3, 3); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + final int s30 = matrix2.get(3, 0); + final int s40 = matrix2.get(4, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s21 = matrix2.get(2, 1); + final int s31 = matrix2.get(3, 1); + final int s41 = matrix2.get(4, 1); + final int s02 = matrix2.get(0, 2); + final int s12 = matrix2.get(1, 2); + final int s22 = matrix2.get(2, 2); + final int s32 = matrix2.get(3, 2); + final int s42 = matrix2.get(4, 2); + final int s03 = matrix2.get(0, 3); + final int s13 = matrix2.get(1, 3); + final int s23 = matrix2.get(2, 3); + final int s33 = matrix2.get(3, 3); + final int s43 = matrix2.get(4, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33); + output.set(4, 0, f00 * s40 + f10 * s41 + f20 * s42 + f30 * s43); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33); + output.set(4, 1, f01 * s40 + f11 * s41 + f21 * s42 + f31 * s43); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33); + output.set(4, 2, f02 * s40 + f12 * s41 + f22 * s42 + f32 * s43); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23); + output.set(3, 3, f03 * s30 + f13 * s31 + f23 * s32 + f33 * s33); + output.set(4, 3, f03 * s40 + f13 * s41 + f23 * s42 + f33 * s43); + return output; + } + + private static IMatrixSetterInt multiplyMatrix5x4x1(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int f30 = matrix1.get(3, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f21 = matrix1.get(2, 1); + final int f31 = matrix1.get(3, 1); + final int f02 = matrix1.get(0, 2); + final int f12 = matrix1.get(1, 2); + final int f22 = matrix1.get(2, 2); + final int f32 = matrix1.get(3, 2); + final int f03 = matrix1.get(0, 3); + final int f13 = matrix1.get(1, 3); + final int f23 = matrix1.get(2, 3); + final int f33 = matrix1.get(3, 3); + final int f04 = matrix1.get(0, 4); + final int f14 = matrix1.get(1, 4); + final int f24 = matrix1.get(2, 4); + final int f34 = matrix1.get(3, 4); + final int s00 = matrix2.get(0, 0); + final int s01 = matrix2.get(0, 1); + final int s02 = matrix2.get(0, 2); + final int s03 = matrix2.get(0, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03); + output.set(0, 4, f04 * s00 + f14 * s01 + f24 * s02 + f34 * s03); return output; } private static IMatrixSetterInt multiplyMatrix5x4x2(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final int f_c00 = matrix1.get(0, 0); - final int f_c10 = matrix1.get(1, 0); - final int f_c20 = matrix1.get(2, 0); - final int f_c30 = matrix1.get(3, 0); - final int f_c01 = matrix1.get(0, 1); - final int f_c11 = matrix1.get(1, 1); - final int f_c21 = matrix1.get(2, 1); - final int f_c31 = matrix1.get(3, 1); - final int f_c02 = matrix1.get(0, 2); - final int f_c12 = matrix1.get(1, 2); - final int f_c22 = matrix1.get(2, 2); - final int f_c32 = matrix1.get(3, 2); - final int f_c03 = matrix1.get(0, 3); - final int f_c13 = matrix1.get(1, 3); - final int f_c23 = matrix1.get(2, 3); - final int f_c33 = matrix1.get(3, 3); - final int f_c04 = matrix1.get(0, 4); - final int f_c14 = matrix1.get(1, 4); - final int f_c24 = matrix1.get(2, 4); - final int f_c34 = matrix1.get(3, 4); - final int s_c00 = matrix2.get(0, 0); - final int s_c10 = matrix2.get(1, 0); - final int s_c01 = matrix2.get(0, 1); - final int s_c11 = matrix2.get(1, 1); - final int s_c02 = matrix2.get(0, 2); - final int s_c12 = matrix2.get(1, 2); - final int s_c03 = matrix2.get(0, 3); - final int s_c13 = matrix2.get(1, 3); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03); - output.set(0, 4, f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02 + f_c34*s_c03); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13); - output.set(1, 4, f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12 + f_c34*s_c13); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int f30 = matrix1.get(3, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f21 = matrix1.get(2, 1); + final int f31 = matrix1.get(3, 1); + final int f02 = matrix1.get(0, 2); + final int f12 = matrix1.get(1, 2); + final int f22 = matrix1.get(2, 2); + final int f32 = matrix1.get(3, 2); + final int f03 = matrix1.get(0, 3); + final int f13 = matrix1.get(1, 3); + final int f23 = matrix1.get(2, 3); + final int f33 = matrix1.get(3, 3); + final int f04 = matrix1.get(0, 4); + final int f14 = matrix1.get(1, 4); + final int f24 = matrix1.get(2, 4); + final int f34 = matrix1.get(3, 4); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s02 = matrix2.get(0, 2); + final int s12 = matrix2.get(1, 2); + final int s03 = matrix2.get(0, 3); + final int s13 = matrix2.get(1, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13); + output.set(0, 4, f04 * s00 + f14 * s01 + f24 * s02 + f34 * s03); + output.set(1, 4, f04 * s10 + f14 * s11 + f24 * s12 + f34 * s13); return output; } private static IMatrixSetterInt multiplyMatrix5x4x3(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final int f_c00 = matrix1.get(0, 0); - final int f_c10 = matrix1.get(1, 0); - final int f_c20 = matrix1.get(2, 0); - final int f_c30 = matrix1.get(3, 0); - final int f_c01 = matrix1.get(0, 1); - final int f_c11 = matrix1.get(1, 1); - final int f_c21 = matrix1.get(2, 1); - final int f_c31 = matrix1.get(3, 1); - final int f_c02 = matrix1.get(0, 2); - final int f_c12 = matrix1.get(1, 2); - final int f_c22 = matrix1.get(2, 2); - final int f_c32 = matrix1.get(3, 2); - final int f_c03 = matrix1.get(0, 3); - final int f_c13 = matrix1.get(1, 3); - final int f_c23 = matrix1.get(2, 3); - final int f_c33 = matrix1.get(3, 3); - final int f_c04 = matrix1.get(0, 4); - final int f_c14 = matrix1.get(1, 4); - final int f_c24 = matrix1.get(2, 4); - final int f_c34 = matrix1.get(3, 4); - final int s_c00 = matrix2.get(0, 0); - final int s_c10 = matrix2.get(1, 0); - final int s_c20 = matrix2.get(2, 0); - final int s_c01 = matrix2.get(0, 1); - final int s_c11 = matrix2.get(1, 1); - final int s_c21 = matrix2.get(2, 1); - final int s_c02 = matrix2.get(0, 2); - final int s_c12 = matrix2.get(1, 2); - final int s_c22 = matrix2.get(2, 2); - final int s_c03 = matrix2.get(0, 3); - final int s_c13 = matrix2.get(1, 3); - final int s_c23 = matrix2.get(2, 3); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03); - output.set(0, 4, f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02 + f_c34*s_c03); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13); - output.set(1, 4, f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12 + f_c34*s_c13); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23); - output.set(2, 4, f_c04*s_c20 + f_c14*s_c21 + f_c24*s_c22 + f_c34*s_c23); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int f30 = matrix1.get(3, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f21 = matrix1.get(2, 1); + final int f31 = matrix1.get(3, 1); + final int f02 = matrix1.get(0, 2); + final int f12 = matrix1.get(1, 2); + final int f22 = matrix1.get(2, 2); + final int f32 = matrix1.get(3, 2); + final int f03 = matrix1.get(0, 3); + final int f13 = matrix1.get(1, 3); + final int f23 = matrix1.get(2, 3); + final int f33 = matrix1.get(3, 3); + final int f04 = matrix1.get(0, 4); + final int f14 = matrix1.get(1, 4); + final int f24 = matrix1.get(2, 4); + final int f34 = matrix1.get(3, 4); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s21 = matrix2.get(2, 1); + final int s02 = matrix2.get(0, 2); + final int s12 = matrix2.get(1, 2); + final int s22 = matrix2.get(2, 2); + final int s03 = matrix2.get(0, 3); + final int s13 = matrix2.get(1, 3); + final int s23 = matrix2.get(2, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23); + output.set(0, 4, f04 * s00 + f14 * s01 + f24 * s02 + f34 * s03); + output.set(1, 4, f04 * s10 + f14 * s11 + f24 * s12 + f34 * s13); + output.set(2, 4, f04 * s20 + f14 * s21 + f24 * s22 + f34 * s23); return output; } private static IMatrixSetterInt multiplyMatrix5x4x4(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final int f_c00 = matrix1.get(0, 0); - final int f_c10 = matrix1.get(1, 0); - final int f_c20 = matrix1.get(2, 0); - final int f_c30 = matrix1.get(3, 0); - final int f_c01 = matrix1.get(0, 1); - final int f_c11 = matrix1.get(1, 1); - final int f_c21 = matrix1.get(2, 1); - final int f_c31 = matrix1.get(3, 1); - final int f_c02 = matrix1.get(0, 2); - final int f_c12 = matrix1.get(1, 2); - final int f_c22 = matrix1.get(2, 2); - final int f_c32 = matrix1.get(3, 2); - final int f_c03 = matrix1.get(0, 3); - final int f_c13 = matrix1.get(1, 3); - final int f_c23 = matrix1.get(2, 3); - final int f_c33 = matrix1.get(3, 3); - final int f_c04 = matrix1.get(0, 4); - final int f_c14 = matrix1.get(1, 4); - final int f_c24 = matrix1.get(2, 4); - final int f_c34 = matrix1.get(3, 4); - final int s_c00 = matrix2.get(0, 0); - final int s_c10 = matrix2.get(1, 0); - final int s_c20 = matrix2.get(2, 0); - final int s_c30 = matrix2.get(3, 0); - final int s_c01 = matrix2.get(0, 1); - final int s_c11 = matrix2.get(1, 1); - final int s_c21 = matrix2.get(2, 1); - final int s_c31 = matrix2.get(3, 1); - final int s_c02 = matrix2.get(0, 2); - final int s_c12 = matrix2.get(1, 2); - final int s_c22 = matrix2.get(2, 2); - final int s_c32 = matrix2.get(3, 2); - final int s_c03 = matrix2.get(0, 3); - final int s_c13 = matrix2.get(1, 3); - final int s_c23 = matrix2.get(2, 3); - final int s_c33 = matrix2.get(3, 3); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03); - output.set(0, 4, f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02 + f_c34*s_c03); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13); - output.set(1, 4, f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12 + f_c34*s_c13); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23); - output.set(2, 4, f_c04*s_c20 + f_c14*s_c21 + f_c24*s_c22 + f_c34*s_c23); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33); - output.set(3, 3, f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32 + f_c33*s_c33); - output.set(3, 4, f_c04*s_c30 + f_c14*s_c31 + f_c24*s_c32 + f_c34*s_c33); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int f30 = matrix1.get(3, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f21 = matrix1.get(2, 1); + final int f31 = matrix1.get(3, 1); + final int f02 = matrix1.get(0, 2); + final int f12 = matrix1.get(1, 2); + final int f22 = matrix1.get(2, 2); + final int f32 = matrix1.get(3, 2); + final int f03 = matrix1.get(0, 3); + final int f13 = matrix1.get(1, 3); + final int f23 = matrix1.get(2, 3); + final int f33 = matrix1.get(3, 3); + final int f04 = matrix1.get(0, 4); + final int f14 = matrix1.get(1, 4); + final int f24 = matrix1.get(2, 4); + final int f34 = matrix1.get(3, 4); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + final int s30 = matrix2.get(3, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s21 = matrix2.get(2, 1); + final int s31 = matrix2.get(3, 1); + final int s02 = matrix2.get(0, 2); + final int s12 = matrix2.get(1, 2); + final int s22 = matrix2.get(2, 2); + final int s32 = matrix2.get(3, 2); + final int s03 = matrix2.get(0, 3); + final int s13 = matrix2.get(1, 3); + final int s23 = matrix2.get(2, 3); + final int s33 = matrix2.get(3, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23); + output.set(3, 3, f03 * s30 + f13 * s31 + f23 * s32 + f33 * s33); + output.set(0, 4, f04 * s00 + f14 * s01 + f24 * s02 + f34 * s03); + output.set(1, 4, f04 * s10 + f14 * s11 + f24 * s12 + f34 * s13); + output.set(2, 4, f04 * s20 + f14 * s21 + f24 * s22 + f34 * s23); + output.set(3, 4, f04 * s30 + f14 * s31 + f24 * s32 + f34 * s33); return output; } private static IMatrixSetterInt multiplyMatrix5x4x5(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final int f_c00 = matrix1.get(0, 0); - final int f_c10 = matrix1.get(1, 0); - final int f_c20 = matrix1.get(2, 0); - final int f_c30 = matrix1.get(3, 0); - final int f_c01 = matrix1.get(0, 1); - final int f_c11 = matrix1.get(1, 1); - final int f_c21 = matrix1.get(2, 1); - final int f_c31 = matrix1.get(3, 1); - final int f_c02 = matrix1.get(0, 2); - final int f_c12 = matrix1.get(1, 2); - final int f_c22 = matrix1.get(2, 2); - final int f_c32 = matrix1.get(3, 2); - final int f_c03 = matrix1.get(0, 3); - final int f_c13 = matrix1.get(1, 3); - final int f_c23 = matrix1.get(2, 3); - final int f_c33 = matrix1.get(3, 3); - final int f_c04 = matrix1.get(0, 4); - final int f_c14 = matrix1.get(1, 4); - final int f_c24 = matrix1.get(2, 4); - final int f_c34 = matrix1.get(3, 4); - final int s_c00 = matrix2.get(0, 0); - final int s_c10 = matrix2.get(1, 0); - final int s_c20 = matrix2.get(2, 0); - final int s_c30 = matrix2.get(3, 0); - final int s_c40 = matrix2.get(4, 0); - final int s_c01 = matrix2.get(0, 1); - final int s_c11 = matrix2.get(1, 1); - final int s_c21 = matrix2.get(2, 1); - final int s_c31 = matrix2.get(3, 1); - final int s_c41 = matrix2.get(4, 1); - final int s_c02 = matrix2.get(0, 2); - final int s_c12 = matrix2.get(1, 2); - final int s_c22 = matrix2.get(2, 2); - final int s_c32 = matrix2.get(3, 2); - final int s_c42 = matrix2.get(4, 2); - final int s_c03 = matrix2.get(0, 3); - final int s_c13 = matrix2.get(1, 3); - final int s_c23 = matrix2.get(2, 3); - final int s_c33 = matrix2.get(3, 3); - final int s_c43 = matrix2.get(4, 3); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03); - output.set(0, 4, f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02 + f_c34*s_c03); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13); - output.set(1, 4, f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12 + f_c34*s_c13); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23); - output.set(2, 4, f_c04*s_c20 + f_c14*s_c21 + f_c24*s_c22 + f_c34*s_c23); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33); - output.set(3, 3, f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32 + f_c33*s_c33); - output.set(3, 4, f_c04*s_c30 + f_c14*s_c31 + f_c24*s_c32 + f_c34*s_c33); - output.set(4, 0, f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42 + f_c30*s_c43); - output.set(4, 1, f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42 + f_c31*s_c43); - output.set(4, 2, f_c02*s_c40 + f_c12*s_c41 + f_c22*s_c42 + f_c32*s_c43); - output.set(4, 3, f_c03*s_c40 + f_c13*s_c41 + f_c23*s_c42 + f_c33*s_c43); - output.set(4, 4, f_c04*s_c40 + f_c14*s_c41 + f_c24*s_c42 + f_c34*s_c43); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int f30 = matrix1.get(3, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f21 = matrix1.get(2, 1); + final int f31 = matrix1.get(3, 1); + final int f02 = matrix1.get(0, 2); + final int f12 = matrix1.get(1, 2); + final int f22 = matrix1.get(2, 2); + final int f32 = matrix1.get(3, 2); + final int f03 = matrix1.get(0, 3); + final int f13 = matrix1.get(1, 3); + final int f23 = matrix1.get(2, 3); + final int f33 = matrix1.get(3, 3); + final int f04 = matrix1.get(0, 4); + final int f14 = matrix1.get(1, 4); + final int f24 = matrix1.get(2, 4); + final int f34 = matrix1.get(3, 4); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + final int s30 = matrix2.get(3, 0); + final int s40 = matrix2.get(4, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s21 = matrix2.get(2, 1); + final int s31 = matrix2.get(3, 1); + final int s41 = matrix2.get(4, 1); + final int s02 = matrix2.get(0, 2); + final int s12 = matrix2.get(1, 2); + final int s22 = matrix2.get(2, 2); + final int s32 = matrix2.get(3, 2); + final int s42 = matrix2.get(4, 2); + final int s03 = matrix2.get(0, 3); + final int s13 = matrix2.get(1, 3); + final int s23 = matrix2.get(2, 3); + final int s33 = matrix2.get(3, 3); + final int s43 = matrix2.get(4, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33); + output.set(4, 0, f00 * s40 + f10 * s41 + f20 * s42 + f30 * s43); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33); + output.set(4, 1, f01 * s40 + f11 * s41 + f21 * s42 + f31 * s43); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33); + output.set(4, 2, f02 * s40 + f12 * s41 + f22 * s42 + f32 * s43); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23); + output.set(3, 3, f03 * s30 + f13 * s31 + f23 * s32 + f33 * s33); + output.set(4, 3, f03 * s40 + f13 * s41 + f23 * s42 + f33 * s43); + output.set(0, 4, f04 * s00 + f14 * s01 + f24 * s02 + f34 * s03); + output.set(1, 4, f04 * s10 + f14 * s11 + f24 * s12 + f34 * s13); + output.set(2, 4, f04 * s20 + f14 * s21 + f24 * s22 + f34 * s23); + output.set(3, 4, f04 * s30 + f14 * s31 + f24 * s32 + f34 * s33); + output.set(4, 4, f04 * s40 + f14 * s41 + f24 * s42 + f34 * s43); + return output; + } + + private static IMatrixSetterInt multiplyMatrix1x5x1(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int f30 = matrix1.get(3, 0); + final int f40 = matrix1.get(4, 0); + final int s00 = matrix2.get(0, 0); + final int s01 = matrix2.get(0, 1); + final int s02 = matrix2.get(0, 2); + final int s03 = matrix2.get(0, 3); + final int s04 = matrix2.get(0, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + return output; + } + + private static IMatrixSetterInt multiplyMatrix1x5x2(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int f30 = matrix1.get(3, 0); + final int f40 = matrix1.get(4, 0); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s02 = matrix2.get(0, 2); + final int s12 = matrix2.get(1, 2); + final int s03 = matrix2.get(0, 3); + final int s13 = matrix2.get(1, 3); + final int s04 = matrix2.get(0, 4); + final int s14 = matrix2.get(1, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + return output; + } + + private static IMatrixSetterInt multiplyMatrix1x5x3(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int f30 = matrix1.get(3, 0); + final int f40 = matrix1.get(4, 0); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s21 = matrix2.get(2, 1); + final int s02 = matrix2.get(0, 2); + final int s12 = matrix2.get(1, 2); + final int s22 = matrix2.get(2, 2); + final int s03 = matrix2.get(0, 3); + final int s13 = matrix2.get(1, 3); + final int s23 = matrix2.get(2, 3); + final int s04 = matrix2.get(0, 4); + final int s14 = matrix2.get(1, 4); + final int s24 = matrix2.get(2, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24); + return output; + } + + private static IMatrixSetterInt multiplyMatrix1x5x4(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int f30 = matrix1.get(3, 0); + final int f40 = matrix1.get(4, 0); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + final int s30 = matrix2.get(3, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s21 = matrix2.get(2, 1); + final int s31 = matrix2.get(3, 1); + final int s02 = matrix2.get(0, 2); + final int s12 = matrix2.get(1, 2); + final int s22 = matrix2.get(2, 2); + final int s32 = matrix2.get(3, 2); + final int s03 = matrix2.get(0, 3); + final int s13 = matrix2.get(1, 3); + final int s23 = matrix2.get(2, 3); + final int s33 = matrix2.get(3, 3); + final int s04 = matrix2.get(0, 4); + final int s14 = matrix2.get(1, 4); + final int s24 = matrix2.get(2, 4); + final int s34 = matrix2.get(3, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33 + f40 * s34); + return output; + } + + private static IMatrixSetterInt multiplyMatrix1x5x5(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int f30 = matrix1.get(3, 0); + final int f40 = matrix1.get(4, 0); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + final int s30 = matrix2.get(3, 0); + final int s40 = matrix2.get(4, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s21 = matrix2.get(2, 1); + final int s31 = matrix2.get(3, 1); + final int s41 = matrix2.get(4, 1); + final int s02 = matrix2.get(0, 2); + final int s12 = matrix2.get(1, 2); + final int s22 = matrix2.get(2, 2); + final int s32 = matrix2.get(3, 2); + final int s42 = matrix2.get(4, 2); + final int s03 = matrix2.get(0, 3); + final int s13 = matrix2.get(1, 3); + final int s23 = matrix2.get(2, 3); + final int s33 = matrix2.get(3, 3); + final int s43 = matrix2.get(4, 3); + final int s04 = matrix2.get(0, 4); + final int s14 = matrix2.get(1, 4); + final int s24 = matrix2.get(2, 4); + final int s34 = matrix2.get(3, 4); + final int s44 = matrix2.get(4, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33 + f40 * s34); + output.set(4, 0, f00 * s40 + f10 * s41 + f20 * s42 + f30 * s43 + f40 * s44); + return output; + } + + private static IMatrixSetterInt multiplyMatrix2x5x1(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int f30 = matrix1.get(3, 0); + final int f40 = matrix1.get(4, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f21 = matrix1.get(2, 1); + final int f31 = matrix1.get(3, 1); + final int f41 = matrix1.get(4, 1); + final int s00 = matrix2.get(0, 0); + final int s01 = matrix2.get(0, 1); + final int s02 = matrix2.get(0, 2); + final int s03 = matrix2.get(0, 3); + final int s04 = matrix2.get(0, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); return output; } private static IMatrixSetterInt multiplyMatrix2x5x2(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final int f_c00 = matrix1.get(0, 0); - final int f_c10 = matrix1.get(1, 0); - final int f_c20 = matrix1.get(2, 0); - final int f_c30 = matrix1.get(3, 0); - final int f_c40 = matrix1.get(4, 0); - final int f_c01 = matrix1.get(0, 1); - final int f_c11 = matrix1.get(1, 1); - final int f_c21 = matrix1.get(2, 1); - final int f_c31 = matrix1.get(3, 1); - final int f_c41 = matrix1.get(4, 1); - final int s_c00 = matrix2.get(0, 0); - final int s_c10 = matrix2.get(1, 0); - final int s_c01 = matrix2.get(0, 1); - final int s_c11 = matrix2.get(1, 1); - final int s_c02 = matrix2.get(0, 2); - final int s_c12 = matrix2.get(1, 2); - final int s_c03 = matrix2.get(0, 3); - final int s_c13 = matrix2.get(1, 3); - final int s_c04 = matrix2.get(0, 4); - final int s_c14 = matrix2.get(1, 4); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int f30 = matrix1.get(3, 0); + final int f40 = matrix1.get(4, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f21 = matrix1.get(2, 1); + final int f31 = matrix1.get(3, 1); + final int f41 = matrix1.get(4, 1); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s02 = matrix2.get(0, 2); + final int s12 = matrix2.get(1, 2); + final int s03 = matrix2.get(0, 3); + final int s13 = matrix2.get(1, 3); + final int s04 = matrix2.get(0, 4); + final int s14 = matrix2.get(1, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14); return output; } private static IMatrixSetterInt multiplyMatrix2x5x3(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final int f_c00 = matrix1.get(0, 0); - final int f_c10 = matrix1.get(1, 0); - final int f_c20 = matrix1.get(2, 0); - final int f_c30 = matrix1.get(3, 0); - final int f_c40 = matrix1.get(4, 0); - final int f_c01 = matrix1.get(0, 1); - final int f_c11 = matrix1.get(1, 1); - final int f_c21 = matrix1.get(2, 1); - final int f_c31 = matrix1.get(3, 1); - final int f_c41 = matrix1.get(4, 1); - final int s_c00 = matrix2.get(0, 0); - final int s_c10 = matrix2.get(1, 0); - final int s_c20 = matrix2.get(2, 0); - final int s_c01 = matrix2.get(0, 1); - final int s_c11 = matrix2.get(1, 1); - final int s_c21 = matrix2.get(2, 1); - final int s_c02 = matrix2.get(0, 2); - final int s_c12 = matrix2.get(1, 2); - final int s_c22 = matrix2.get(2, 2); - final int s_c03 = matrix2.get(0, 3); - final int s_c13 = matrix2.get(1, 3); - final int s_c23 = matrix2.get(2, 3); - final int s_c04 = matrix2.get(0, 4); - final int s_c14 = matrix2.get(1, 4); - final int s_c24 = matrix2.get(2, 4); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int f30 = matrix1.get(3, 0); + final int f40 = matrix1.get(4, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f21 = matrix1.get(2, 1); + final int f31 = matrix1.get(3, 1); + final int f41 = matrix1.get(4, 1); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s21 = matrix2.get(2, 1); + final int s02 = matrix2.get(0, 2); + final int s12 = matrix2.get(1, 2); + final int s22 = matrix2.get(2, 2); + final int s03 = matrix2.get(0, 3); + final int s13 = matrix2.get(1, 3); + final int s23 = matrix2.get(2, 3); + final int s04 = matrix2.get(0, 4); + final int s14 = matrix2.get(1, 4); + final int s24 = matrix2.get(2, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24); return output; } private static IMatrixSetterInt multiplyMatrix2x5x4(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final int f_c00 = matrix1.get(0, 0); - final int f_c10 = matrix1.get(1, 0); - final int f_c20 = matrix1.get(2, 0); - final int f_c30 = matrix1.get(3, 0); - final int f_c40 = matrix1.get(4, 0); - final int f_c01 = matrix1.get(0, 1); - final int f_c11 = matrix1.get(1, 1); - final int f_c21 = matrix1.get(2, 1); - final int f_c31 = matrix1.get(3, 1); - final int f_c41 = matrix1.get(4, 1); - final int s_c00 = matrix2.get(0, 0); - final int s_c10 = matrix2.get(1, 0); - final int s_c20 = matrix2.get(2, 0); - final int s_c30 = matrix2.get(3, 0); - final int s_c01 = matrix2.get(0, 1); - final int s_c11 = matrix2.get(1, 1); - final int s_c21 = matrix2.get(2, 1); - final int s_c31 = matrix2.get(3, 1); - final int s_c02 = matrix2.get(0, 2); - final int s_c12 = matrix2.get(1, 2); - final int s_c22 = matrix2.get(2, 2); - final int s_c32 = matrix2.get(3, 2); - final int s_c03 = matrix2.get(0, 3); - final int s_c13 = matrix2.get(1, 3); - final int s_c23 = matrix2.get(2, 3); - final int s_c33 = matrix2.get(3, 3); - final int s_c04 = matrix2.get(0, 4); - final int s_c14 = matrix2.get(1, 4); - final int s_c24 = matrix2.get(2, 4); - final int s_c34 = matrix2.get(3, 4); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33 + f_c40*s_c34); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33 + f_c41*s_c34); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int f30 = matrix1.get(3, 0); + final int f40 = matrix1.get(4, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f21 = matrix1.get(2, 1); + final int f31 = matrix1.get(3, 1); + final int f41 = matrix1.get(4, 1); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + final int s30 = matrix2.get(3, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s21 = matrix2.get(2, 1); + final int s31 = matrix2.get(3, 1); + final int s02 = matrix2.get(0, 2); + final int s12 = matrix2.get(1, 2); + final int s22 = matrix2.get(2, 2); + final int s32 = matrix2.get(3, 2); + final int s03 = matrix2.get(0, 3); + final int s13 = matrix2.get(1, 3); + final int s23 = matrix2.get(2, 3); + final int s33 = matrix2.get(3, 3); + final int s04 = matrix2.get(0, 4); + final int s14 = matrix2.get(1, 4); + final int s24 = matrix2.get(2, 4); + final int s34 = matrix2.get(3, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33 + f40 * s34); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33 + f41 * s34); return output; } private static IMatrixSetterInt multiplyMatrix2x5x5(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final int f_c00 = matrix1.get(0, 0); - final int f_c10 = matrix1.get(1, 0); - final int f_c20 = matrix1.get(2, 0); - final int f_c30 = matrix1.get(3, 0); - final int f_c40 = matrix1.get(4, 0); - final int f_c01 = matrix1.get(0, 1); - final int f_c11 = matrix1.get(1, 1); - final int f_c21 = matrix1.get(2, 1); - final int f_c31 = matrix1.get(3, 1); - final int f_c41 = matrix1.get(4, 1); - final int s_c00 = matrix2.get(0, 0); - final int s_c10 = matrix2.get(1, 0); - final int s_c20 = matrix2.get(2, 0); - final int s_c30 = matrix2.get(3, 0); - final int s_c40 = matrix2.get(4, 0); - final int s_c01 = matrix2.get(0, 1); - final int s_c11 = matrix2.get(1, 1); - final int s_c21 = matrix2.get(2, 1); - final int s_c31 = matrix2.get(3, 1); - final int s_c41 = matrix2.get(4, 1); - final int s_c02 = matrix2.get(0, 2); - final int s_c12 = matrix2.get(1, 2); - final int s_c22 = matrix2.get(2, 2); - final int s_c32 = matrix2.get(3, 2); - final int s_c42 = matrix2.get(4, 2); - final int s_c03 = matrix2.get(0, 3); - final int s_c13 = matrix2.get(1, 3); - final int s_c23 = matrix2.get(2, 3); - final int s_c33 = matrix2.get(3, 3); - final int s_c43 = matrix2.get(4, 3); - final int s_c04 = matrix2.get(0, 4); - final int s_c14 = matrix2.get(1, 4); - final int s_c24 = matrix2.get(2, 4); - final int s_c34 = matrix2.get(3, 4); - final int s_c44 = matrix2.get(4, 4); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33 + f_c40*s_c34); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33 + f_c41*s_c34); - output.set(4, 0, f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42 + f_c30*s_c43 + f_c40*s_c44); - output.set(4, 1, f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42 + f_c31*s_c43 + f_c41*s_c44); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int f30 = matrix1.get(3, 0); + final int f40 = matrix1.get(4, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f21 = matrix1.get(2, 1); + final int f31 = matrix1.get(3, 1); + final int f41 = matrix1.get(4, 1); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + final int s30 = matrix2.get(3, 0); + final int s40 = matrix2.get(4, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s21 = matrix2.get(2, 1); + final int s31 = matrix2.get(3, 1); + final int s41 = matrix2.get(4, 1); + final int s02 = matrix2.get(0, 2); + final int s12 = matrix2.get(1, 2); + final int s22 = matrix2.get(2, 2); + final int s32 = matrix2.get(3, 2); + final int s42 = matrix2.get(4, 2); + final int s03 = matrix2.get(0, 3); + final int s13 = matrix2.get(1, 3); + final int s23 = matrix2.get(2, 3); + final int s33 = matrix2.get(3, 3); + final int s43 = matrix2.get(4, 3); + final int s04 = matrix2.get(0, 4); + final int s14 = matrix2.get(1, 4); + final int s24 = matrix2.get(2, 4); + final int s34 = matrix2.get(3, 4); + final int s44 = matrix2.get(4, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33 + f40 * s34); + output.set(4, 0, f00 * s40 + f10 * s41 + f20 * s42 + f30 * s43 + f40 * s44); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33 + f41 * s34); + output.set(4, 1, f01 * s40 + f11 * s41 + f21 * s42 + f31 * s43 + f41 * s44); + return output; + } + + private static IMatrixSetterInt multiplyMatrix3x5x1(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int f30 = matrix1.get(3, 0); + final int f40 = matrix1.get(4, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f21 = matrix1.get(2, 1); + final int f31 = matrix1.get(3, 1); + final int f41 = matrix1.get(4, 1); + final int f02 = matrix1.get(0, 2); + final int f12 = matrix1.get(1, 2); + final int f22 = matrix1.get(2, 2); + final int f32 = matrix1.get(3, 2); + final int f42 = matrix1.get(4, 2); + final int s00 = matrix2.get(0, 0); + final int s01 = matrix2.get(0, 1); + final int s02 = matrix2.get(0, 2); + final int s03 = matrix2.get(0, 3); + final int s04 = matrix2.get(0, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04); return output; } private static IMatrixSetterInt multiplyMatrix3x5x2(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final int f_c00 = matrix1.get(0, 0); - final int f_c10 = matrix1.get(1, 0); - final int f_c20 = matrix1.get(2, 0); - final int f_c30 = matrix1.get(3, 0); - final int f_c40 = matrix1.get(4, 0); - final int f_c01 = matrix1.get(0, 1); - final int f_c11 = matrix1.get(1, 1); - final int f_c21 = matrix1.get(2, 1); - final int f_c31 = matrix1.get(3, 1); - final int f_c41 = matrix1.get(4, 1); - final int f_c02 = matrix1.get(0, 2); - final int f_c12 = matrix1.get(1, 2); - final int f_c22 = matrix1.get(2, 2); - final int f_c32 = matrix1.get(3, 2); - final int f_c42 = matrix1.get(4, 2); - final int s_c00 = matrix2.get(0, 0); - final int s_c10 = matrix2.get(1, 0); - final int s_c01 = matrix2.get(0, 1); - final int s_c11 = matrix2.get(1, 1); - final int s_c02 = matrix2.get(0, 2); - final int s_c12 = matrix2.get(1, 2); - final int s_c03 = matrix2.get(0, 3); - final int s_c13 = matrix2.get(1, 3); - final int s_c04 = matrix2.get(0, 4); - final int s_c14 = matrix2.get(1, 4); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int f30 = matrix1.get(3, 0); + final int f40 = matrix1.get(4, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f21 = matrix1.get(2, 1); + final int f31 = matrix1.get(3, 1); + final int f41 = matrix1.get(4, 1); + final int f02 = matrix1.get(0, 2); + final int f12 = matrix1.get(1, 2); + final int f22 = matrix1.get(2, 2); + final int f32 = matrix1.get(3, 2); + final int f42 = matrix1.get(4, 2); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s02 = matrix2.get(0, 2); + final int s12 = matrix2.get(1, 2); + final int s03 = matrix2.get(0, 3); + final int s13 = matrix2.get(1, 3); + final int s04 = matrix2.get(0, 4); + final int s14 = matrix2.get(1, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14); return output; } private static IMatrixSetterInt multiplyMatrix3x5x3(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final int f_c00 = matrix1.get(0, 0); - final int f_c10 = matrix1.get(1, 0); - final int f_c20 = matrix1.get(2, 0); - final int f_c30 = matrix1.get(3, 0); - final int f_c40 = matrix1.get(4, 0); - final int f_c01 = matrix1.get(0, 1); - final int f_c11 = matrix1.get(1, 1); - final int f_c21 = matrix1.get(2, 1); - final int f_c31 = matrix1.get(3, 1); - final int f_c41 = matrix1.get(4, 1); - final int f_c02 = matrix1.get(0, 2); - final int f_c12 = matrix1.get(1, 2); - final int f_c22 = matrix1.get(2, 2); - final int f_c32 = matrix1.get(3, 2); - final int f_c42 = matrix1.get(4, 2); - final int s_c00 = matrix2.get(0, 0); - final int s_c10 = matrix2.get(1, 0); - final int s_c20 = matrix2.get(2, 0); - final int s_c01 = matrix2.get(0, 1); - final int s_c11 = matrix2.get(1, 1); - final int s_c21 = matrix2.get(2, 1); - final int s_c02 = matrix2.get(0, 2); - final int s_c12 = matrix2.get(1, 2); - final int s_c22 = matrix2.get(2, 2); - final int s_c03 = matrix2.get(0, 3); - final int s_c13 = matrix2.get(1, 3); - final int s_c23 = matrix2.get(2, 3); - final int s_c04 = matrix2.get(0, 4); - final int s_c14 = matrix2.get(1, 4); - final int s_c24 = matrix2.get(2, 4); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23 + f_c42*s_c24); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int f30 = matrix1.get(3, 0); + final int f40 = matrix1.get(4, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f21 = matrix1.get(2, 1); + final int f31 = matrix1.get(3, 1); + final int f41 = matrix1.get(4, 1); + final int f02 = matrix1.get(0, 2); + final int f12 = matrix1.get(1, 2); + final int f22 = matrix1.get(2, 2); + final int f32 = matrix1.get(3, 2); + final int f42 = matrix1.get(4, 2); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s21 = matrix2.get(2, 1); + final int s02 = matrix2.get(0, 2); + final int s12 = matrix2.get(1, 2); + final int s22 = matrix2.get(2, 2); + final int s03 = matrix2.get(0, 3); + final int s13 = matrix2.get(1, 3); + final int s23 = matrix2.get(2, 3); + final int s04 = matrix2.get(0, 4); + final int s14 = matrix2.get(1, 4); + final int s24 = matrix2.get(2, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23 + f42 * s24); return output; } private static IMatrixSetterInt multiplyMatrix3x5x4(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final int f_c00 = matrix1.get(0, 0); - final int f_c10 = matrix1.get(1, 0); - final int f_c20 = matrix1.get(2, 0); - final int f_c30 = matrix1.get(3, 0); - final int f_c40 = matrix1.get(4, 0); - final int f_c01 = matrix1.get(0, 1); - final int f_c11 = matrix1.get(1, 1); - final int f_c21 = matrix1.get(2, 1); - final int f_c31 = matrix1.get(3, 1); - final int f_c41 = matrix1.get(4, 1); - final int f_c02 = matrix1.get(0, 2); - final int f_c12 = matrix1.get(1, 2); - final int f_c22 = matrix1.get(2, 2); - final int f_c32 = matrix1.get(3, 2); - final int f_c42 = matrix1.get(4, 2); - final int s_c00 = matrix2.get(0, 0); - final int s_c10 = matrix2.get(1, 0); - final int s_c20 = matrix2.get(2, 0); - final int s_c30 = matrix2.get(3, 0); - final int s_c01 = matrix2.get(0, 1); - final int s_c11 = matrix2.get(1, 1); - final int s_c21 = matrix2.get(2, 1); - final int s_c31 = matrix2.get(3, 1); - final int s_c02 = matrix2.get(0, 2); - final int s_c12 = matrix2.get(1, 2); - final int s_c22 = matrix2.get(2, 2); - final int s_c32 = matrix2.get(3, 2); - final int s_c03 = matrix2.get(0, 3); - final int s_c13 = matrix2.get(1, 3); - final int s_c23 = matrix2.get(2, 3); - final int s_c33 = matrix2.get(3, 3); - final int s_c04 = matrix2.get(0, 4); - final int s_c14 = matrix2.get(1, 4); - final int s_c24 = matrix2.get(2, 4); - final int s_c34 = matrix2.get(3, 4); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23 + f_c42*s_c24); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33 + f_c40*s_c34); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33 + f_c41*s_c34); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33 + f_c42*s_c34); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int f30 = matrix1.get(3, 0); + final int f40 = matrix1.get(4, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f21 = matrix1.get(2, 1); + final int f31 = matrix1.get(3, 1); + final int f41 = matrix1.get(4, 1); + final int f02 = matrix1.get(0, 2); + final int f12 = matrix1.get(1, 2); + final int f22 = matrix1.get(2, 2); + final int f32 = matrix1.get(3, 2); + final int f42 = matrix1.get(4, 2); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + final int s30 = matrix2.get(3, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s21 = matrix2.get(2, 1); + final int s31 = matrix2.get(3, 1); + final int s02 = matrix2.get(0, 2); + final int s12 = matrix2.get(1, 2); + final int s22 = matrix2.get(2, 2); + final int s32 = matrix2.get(3, 2); + final int s03 = matrix2.get(0, 3); + final int s13 = matrix2.get(1, 3); + final int s23 = matrix2.get(2, 3); + final int s33 = matrix2.get(3, 3); + final int s04 = matrix2.get(0, 4); + final int s14 = matrix2.get(1, 4); + final int s24 = matrix2.get(2, 4); + final int s34 = matrix2.get(3, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33 + f40 * s34); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33 + f41 * s34); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23 + f42 * s24); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33 + f42 * s34); return output; } private static IMatrixSetterInt multiplyMatrix3x5x5(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final int f_c00 = matrix1.get(0, 0); - final int f_c10 = matrix1.get(1, 0); - final int f_c20 = matrix1.get(2, 0); - final int f_c30 = matrix1.get(3, 0); - final int f_c40 = matrix1.get(4, 0); - final int f_c01 = matrix1.get(0, 1); - final int f_c11 = matrix1.get(1, 1); - final int f_c21 = matrix1.get(2, 1); - final int f_c31 = matrix1.get(3, 1); - final int f_c41 = matrix1.get(4, 1); - final int f_c02 = matrix1.get(0, 2); - final int f_c12 = matrix1.get(1, 2); - final int f_c22 = matrix1.get(2, 2); - final int f_c32 = matrix1.get(3, 2); - final int f_c42 = matrix1.get(4, 2); - final int s_c00 = matrix2.get(0, 0); - final int s_c10 = matrix2.get(1, 0); - final int s_c20 = matrix2.get(2, 0); - final int s_c30 = matrix2.get(3, 0); - final int s_c40 = matrix2.get(4, 0); - final int s_c01 = matrix2.get(0, 1); - final int s_c11 = matrix2.get(1, 1); - final int s_c21 = matrix2.get(2, 1); - final int s_c31 = matrix2.get(3, 1); - final int s_c41 = matrix2.get(4, 1); - final int s_c02 = matrix2.get(0, 2); - final int s_c12 = matrix2.get(1, 2); - final int s_c22 = matrix2.get(2, 2); - final int s_c32 = matrix2.get(3, 2); - final int s_c42 = matrix2.get(4, 2); - final int s_c03 = matrix2.get(0, 3); - final int s_c13 = matrix2.get(1, 3); - final int s_c23 = matrix2.get(2, 3); - final int s_c33 = matrix2.get(3, 3); - final int s_c43 = matrix2.get(4, 3); - final int s_c04 = matrix2.get(0, 4); - final int s_c14 = matrix2.get(1, 4); - final int s_c24 = matrix2.get(2, 4); - final int s_c34 = matrix2.get(3, 4); - final int s_c44 = matrix2.get(4, 4); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23 + f_c42*s_c24); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33 + f_c40*s_c34); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33 + f_c41*s_c34); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33 + f_c42*s_c34); - output.set(4, 0, f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42 + f_c30*s_c43 + f_c40*s_c44); - output.set(4, 1, f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42 + f_c31*s_c43 + f_c41*s_c44); - output.set(4, 2, f_c02*s_c40 + f_c12*s_c41 + f_c22*s_c42 + f_c32*s_c43 + f_c42*s_c44); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int f30 = matrix1.get(3, 0); + final int f40 = matrix1.get(4, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f21 = matrix1.get(2, 1); + final int f31 = matrix1.get(3, 1); + final int f41 = matrix1.get(4, 1); + final int f02 = matrix1.get(0, 2); + final int f12 = matrix1.get(1, 2); + final int f22 = matrix1.get(2, 2); + final int f32 = matrix1.get(3, 2); + final int f42 = matrix1.get(4, 2); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + final int s30 = matrix2.get(3, 0); + final int s40 = matrix2.get(4, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s21 = matrix2.get(2, 1); + final int s31 = matrix2.get(3, 1); + final int s41 = matrix2.get(4, 1); + final int s02 = matrix2.get(0, 2); + final int s12 = matrix2.get(1, 2); + final int s22 = matrix2.get(2, 2); + final int s32 = matrix2.get(3, 2); + final int s42 = matrix2.get(4, 2); + final int s03 = matrix2.get(0, 3); + final int s13 = matrix2.get(1, 3); + final int s23 = matrix2.get(2, 3); + final int s33 = matrix2.get(3, 3); + final int s43 = matrix2.get(4, 3); + final int s04 = matrix2.get(0, 4); + final int s14 = matrix2.get(1, 4); + final int s24 = matrix2.get(2, 4); + final int s34 = matrix2.get(3, 4); + final int s44 = matrix2.get(4, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33 + f40 * s34); + output.set(4, 0, f00 * s40 + f10 * s41 + f20 * s42 + f30 * s43 + f40 * s44); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33 + f41 * s34); + output.set(4, 1, f01 * s40 + f11 * s41 + f21 * s42 + f31 * s43 + f41 * s44); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23 + f42 * s24); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33 + f42 * s34); + output.set(4, 2, f02 * s40 + f12 * s41 + f22 * s42 + f32 * s43 + f42 * s44); + return output; + } + + private static IMatrixSetterInt multiplyMatrix4x5x1(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int f30 = matrix1.get(3, 0); + final int f40 = matrix1.get(4, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f21 = matrix1.get(2, 1); + final int f31 = matrix1.get(3, 1); + final int f41 = matrix1.get(4, 1); + final int f02 = matrix1.get(0, 2); + final int f12 = matrix1.get(1, 2); + final int f22 = matrix1.get(2, 2); + final int f32 = matrix1.get(3, 2); + final int f42 = matrix1.get(4, 2); + final int f03 = matrix1.get(0, 3); + final int f13 = matrix1.get(1, 3); + final int f23 = matrix1.get(2, 3); + final int f33 = matrix1.get(3, 3); + final int f43 = matrix1.get(4, 3); + final int s00 = matrix2.get(0, 0); + final int s01 = matrix2.get(0, 1); + final int s02 = matrix2.get(0, 2); + final int s03 = matrix2.get(0, 3); + final int s04 = matrix2.get(0, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03 + f43 * s04); return output; } private static IMatrixSetterInt multiplyMatrix4x5x2(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final int f_c00 = matrix1.get(0, 0); - final int f_c10 = matrix1.get(1, 0); - final int f_c20 = matrix1.get(2, 0); - final int f_c30 = matrix1.get(3, 0); - final int f_c40 = matrix1.get(4, 0); - final int f_c01 = matrix1.get(0, 1); - final int f_c11 = matrix1.get(1, 1); - final int f_c21 = matrix1.get(2, 1); - final int f_c31 = matrix1.get(3, 1); - final int f_c41 = matrix1.get(4, 1); - final int f_c02 = matrix1.get(0, 2); - final int f_c12 = matrix1.get(1, 2); - final int f_c22 = matrix1.get(2, 2); - final int f_c32 = matrix1.get(3, 2); - final int f_c42 = matrix1.get(4, 2); - final int f_c03 = matrix1.get(0, 3); - final int f_c13 = matrix1.get(1, 3); - final int f_c23 = matrix1.get(2, 3); - final int f_c33 = matrix1.get(3, 3); - final int f_c43 = matrix1.get(4, 3); - final int s_c00 = matrix2.get(0, 0); - final int s_c10 = matrix2.get(1, 0); - final int s_c01 = matrix2.get(0, 1); - final int s_c11 = matrix2.get(1, 1); - final int s_c02 = matrix2.get(0, 2); - final int s_c12 = matrix2.get(1, 2); - final int s_c03 = matrix2.get(0, 3); - final int s_c13 = matrix2.get(1, 3); - final int s_c04 = matrix2.get(0, 4); - final int s_c14 = matrix2.get(1, 4); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03 + f_c43*s_c04); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13 + f_c43*s_c14); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int f30 = matrix1.get(3, 0); + final int f40 = matrix1.get(4, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f21 = matrix1.get(2, 1); + final int f31 = matrix1.get(3, 1); + final int f41 = matrix1.get(4, 1); + final int f02 = matrix1.get(0, 2); + final int f12 = matrix1.get(1, 2); + final int f22 = matrix1.get(2, 2); + final int f32 = matrix1.get(3, 2); + final int f42 = matrix1.get(4, 2); + final int f03 = matrix1.get(0, 3); + final int f13 = matrix1.get(1, 3); + final int f23 = matrix1.get(2, 3); + final int f33 = matrix1.get(3, 3); + final int f43 = matrix1.get(4, 3); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s02 = matrix2.get(0, 2); + final int s12 = matrix2.get(1, 2); + final int s03 = matrix2.get(0, 3); + final int s13 = matrix2.get(1, 3); + final int s04 = matrix2.get(0, 4); + final int s14 = matrix2.get(1, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03 + f43 * s04); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13 + f43 * s14); return output; } private static IMatrixSetterInt multiplyMatrix4x5x3(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final int f_c00 = matrix1.get(0, 0); - final int f_c10 = matrix1.get(1, 0); - final int f_c20 = matrix1.get(2, 0); - final int f_c30 = matrix1.get(3, 0); - final int f_c40 = matrix1.get(4, 0); - final int f_c01 = matrix1.get(0, 1); - final int f_c11 = matrix1.get(1, 1); - final int f_c21 = matrix1.get(2, 1); - final int f_c31 = matrix1.get(3, 1); - final int f_c41 = matrix1.get(4, 1); - final int f_c02 = matrix1.get(0, 2); - final int f_c12 = matrix1.get(1, 2); - final int f_c22 = matrix1.get(2, 2); - final int f_c32 = matrix1.get(3, 2); - final int f_c42 = matrix1.get(4, 2); - final int f_c03 = matrix1.get(0, 3); - final int f_c13 = matrix1.get(1, 3); - final int f_c23 = matrix1.get(2, 3); - final int f_c33 = matrix1.get(3, 3); - final int f_c43 = matrix1.get(4, 3); - final int s_c00 = matrix2.get(0, 0); - final int s_c10 = matrix2.get(1, 0); - final int s_c20 = matrix2.get(2, 0); - final int s_c01 = matrix2.get(0, 1); - final int s_c11 = matrix2.get(1, 1); - final int s_c21 = matrix2.get(2, 1); - final int s_c02 = matrix2.get(0, 2); - final int s_c12 = matrix2.get(1, 2); - final int s_c22 = matrix2.get(2, 2); - final int s_c03 = matrix2.get(0, 3); - final int s_c13 = matrix2.get(1, 3); - final int s_c23 = matrix2.get(2, 3); - final int s_c04 = matrix2.get(0, 4); - final int s_c14 = matrix2.get(1, 4); - final int s_c24 = matrix2.get(2, 4); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03 + f_c43*s_c04); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13 + f_c43*s_c14); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23 + f_c42*s_c24); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23 + f_c43*s_c24); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int f30 = matrix1.get(3, 0); + final int f40 = matrix1.get(4, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f21 = matrix1.get(2, 1); + final int f31 = matrix1.get(3, 1); + final int f41 = matrix1.get(4, 1); + final int f02 = matrix1.get(0, 2); + final int f12 = matrix1.get(1, 2); + final int f22 = matrix1.get(2, 2); + final int f32 = matrix1.get(3, 2); + final int f42 = matrix1.get(4, 2); + final int f03 = matrix1.get(0, 3); + final int f13 = matrix1.get(1, 3); + final int f23 = matrix1.get(2, 3); + final int f33 = matrix1.get(3, 3); + final int f43 = matrix1.get(4, 3); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s21 = matrix2.get(2, 1); + final int s02 = matrix2.get(0, 2); + final int s12 = matrix2.get(1, 2); + final int s22 = matrix2.get(2, 2); + final int s03 = matrix2.get(0, 3); + final int s13 = matrix2.get(1, 3); + final int s23 = matrix2.get(2, 3); + final int s04 = matrix2.get(0, 4); + final int s14 = matrix2.get(1, 4); + final int s24 = matrix2.get(2, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23 + f42 * s24); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03 + f43 * s04); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13 + f43 * s14); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23 + f43 * s24); return output; } private static IMatrixSetterInt multiplyMatrix4x5x4(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final int f_c00 = matrix1.get(0, 0); - final int f_c10 = matrix1.get(1, 0); - final int f_c20 = matrix1.get(2, 0); - final int f_c30 = matrix1.get(3, 0); - final int f_c40 = matrix1.get(4, 0); - final int f_c01 = matrix1.get(0, 1); - final int f_c11 = matrix1.get(1, 1); - final int f_c21 = matrix1.get(2, 1); - final int f_c31 = matrix1.get(3, 1); - final int f_c41 = matrix1.get(4, 1); - final int f_c02 = matrix1.get(0, 2); - final int f_c12 = matrix1.get(1, 2); - final int f_c22 = matrix1.get(2, 2); - final int f_c32 = matrix1.get(3, 2); - final int f_c42 = matrix1.get(4, 2); - final int f_c03 = matrix1.get(0, 3); - final int f_c13 = matrix1.get(1, 3); - final int f_c23 = matrix1.get(2, 3); - final int f_c33 = matrix1.get(3, 3); - final int f_c43 = matrix1.get(4, 3); - final int s_c00 = matrix2.get(0, 0); - final int s_c10 = matrix2.get(1, 0); - final int s_c20 = matrix2.get(2, 0); - final int s_c30 = matrix2.get(3, 0); - final int s_c01 = matrix2.get(0, 1); - final int s_c11 = matrix2.get(1, 1); - final int s_c21 = matrix2.get(2, 1); - final int s_c31 = matrix2.get(3, 1); - final int s_c02 = matrix2.get(0, 2); - final int s_c12 = matrix2.get(1, 2); - final int s_c22 = matrix2.get(2, 2); - final int s_c32 = matrix2.get(3, 2); - final int s_c03 = matrix2.get(0, 3); - final int s_c13 = matrix2.get(1, 3); - final int s_c23 = matrix2.get(2, 3); - final int s_c33 = matrix2.get(3, 3); - final int s_c04 = matrix2.get(0, 4); - final int s_c14 = matrix2.get(1, 4); - final int s_c24 = matrix2.get(2, 4); - final int s_c34 = matrix2.get(3, 4); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03 + f_c43*s_c04); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13 + f_c43*s_c14); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23 + f_c42*s_c24); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23 + f_c43*s_c24); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33 + f_c40*s_c34); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33 + f_c41*s_c34); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33 + f_c42*s_c34); - output.set(3, 3, f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32 + f_c33*s_c33 + f_c43*s_c34); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int f30 = matrix1.get(3, 0); + final int f40 = matrix1.get(4, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f21 = matrix1.get(2, 1); + final int f31 = matrix1.get(3, 1); + final int f41 = matrix1.get(4, 1); + final int f02 = matrix1.get(0, 2); + final int f12 = matrix1.get(1, 2); + final int f22 = matrix1.get(2, 2); + final int f32 = matrix1.get(3, 2); + final int f42 = matrix1.get(4, 2); + final int f03 = matrix1.get(0, 3); + final int f13 = matrix1.get(1, 3); + final int f23 = matrix1.get(2, 3); + final int f33 = matrix1.get(3, 3); + final int f43 = matrix1.get(4, 3); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + final int s30 = matrix2.get(3, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s21 = matrix2.get(2, 1); + final int s31 = matrix2.get(3, 1); + final int s02 = matrix2.get(0, 2); + final int s12 = matrix2.get(1, 2); + final int s22 = matrix2.get(2, 2); + final int s32 = matrix2.get(3, 2); + final int s03 = matrix2.get(0, 3); + final int s13 = matrix2.get(1, 3); + final int s23 = matrix2.get(2, 3); + final int s33 = matrix2.get(3, 3); + final int s04 = matrix2.get(0, 4); + final int s14 = matrix2.get(1, 4); + final int s24 = matrix2.get(2, 4); + final int s34 = matrix2.get(3, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33 + f40 * s34); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33 + f41 * s34); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23 + f42 * s24); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33 + f42 * s34); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03 + f43 * s04); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13 + f43 * s14); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23 + f43 * s24); + output.set(3, 3, f03 * s30 + f13 * s31 + f23 * s32 + f33 * s33 + f43 * s34); return output; } private static IMatrixSetterInt multiplyMatrix4x5x5(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final int f_c00 = matrix1.get(0, 0); - final int f_c10 = matrix1.get(1, 0); - final int f_c20 = matrix1.get(2, 0); - final int f_c30 = matrix1.get(3, 0); - final int f_c40 = matrix1.get(4, 0); - final int f_c01 = matrix1.get(0, 1); - final int f_c11 = matrix1.get(1, 1); - final int f_c21 = matrix1.get(2, 1); - final int f_c31 = matrix1.get(3, 1); - final int f_c41 = matrix1.get(4, 1); - final int f_c02 = matrix1.get(0, 2); - final int f_c12 = matrix1.get(1, 2); - final int f_c22 = matrix1.get(2, 2); - final int f_c32 = matrix1.get(3, 2); - final int f_c42 = matrix1.get(4, 2); - final int f_c03 = matrix1.get(0, 3); - final int f_c13 = matrix1.get(1, 3); - final int f_c23 = matrix1.get(2, 3); - final int f_c33 = matrix1.get(3, 3); - final int f_c43 = matrix1.get(4, 3); - final int s_c00 = matrix2.get(0, 0); - final int s_c10 = matrix2.get(1, 0); - final int s_c20 = matrix2.get(2, 0); - final int s_c30 = matrix2.get(3, 0); - final int s_c40 = matrix2.get(4, 0); - final int s_c01 = matrix2.get(0, 1); - final int s_c11 = matrix2.get(1, 1); - final int s_c21 = matrix2.get(2, 1); - final int s_c31 = matrix2.get(3, 1); - final int s_c41 = matrix2.get(4, 1); - final int s_c02 = matrix2.get(0, 2); - final int s_c12 = matrix2.get(1, 2); - final int s_c22 = matrix2.get(2, 2); - final int s_c32 = matrix2.get(3, 2); - final int s_c42 = matrix2.get(4, 2); - final int s_c03 = matrix2.get(0, 3); - final int s_c13 = matrix2.get(1, 3); - final int s_c23 = matrix2.get(2, 3); - final int s_c33 = matrix2.get(3, 3); - final int s_c43 = matrix2.get(4, 3); - final int s_c04 = matrix2.get(0, 4); - final int s_c14 = matrix2.get(1, 4); - final int s_c24 = matrix2.get(2, 4); - final int s_c34 = matrix2.get(3, 4); - final int s_c44 = matrix2.get(4, 4); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03 + f_c43*s_c04); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13 + f_c43*s_c14); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23 + f_c42*s_c24); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23 + f_c43*s_c24); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33 + f_c40*s_c34); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33 + f_c41*s_c34); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33 + f_c42*s_c34); - output.set(3, 3, f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32 + f_c33*s_c33 + f_c43*s_c34); - output.set(4, 0, f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42 + f_c30*s_c43 + f_c40*s_c44); - output.set(4, 1, f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42 + f_c31*s_c43 + f_c41*s_c44); - output.set(4, 2, f_c02*s_c40 + f_c12*s_c41 + f_c22*s_c42 + f_c32*s_c43 + f_c42*s_c44); - output.set(4, 3, f_c03*s_c40 + f_c13*s_c41 + f_c23*s_c42 + f_c33*s_c43 + f_c43*s_c44); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int f30 = matrix1.get(3, 0); + final int f40 = matrix1.get(4, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f21 = matrix1.get(2, 1); + final int f31 = matrix1.get(3, 1); + final int f41 = matrix1.get(4, 1); + final int f02 = matrix1.get(0, 2); + final int f12 = matrix1.get(1, 2); + final int f22 = matrix1.get(2, 2); + final int f32 = matrix1.get(3, 2); + final int f42 = matrix1.get(4, 2); + final int f03 = matrix1.get(0, 3); + final int f13 = matrix1.get(1, 3); + final int f23 = matrix1.get(2, 3); + final int f33 = matrix1.get(3, 3); + final int f43 = matrix1.get(4, 3); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + final int s30 = matrix2.get(3, 0); + final int s40 = matrix2.get(4, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s21 = matrix2.get(2, 1); + final int s31 = matrix2.get(3, 1); + final int s41 = matrix2.get(4, 1); + final int s02 = matrix2.get(0, 2); + final int s12 = matrix2.get(1, 2); + final int s22 = matrix2.get(2, 2); + final int s32 = matrix2.get(3, 2); + final int s42 = matrix2.get(4, 2); + final int s03 = matrix2.get(0, 3); + final int s13 = matrix2.get(1, 3); + final int s23 = matrix2.get(2, 3); + final int s33 = matrix2.get(3, 3); + final int s43 = matrix2.get(4, 3); + final int s04 = matrix2.get(0, 4); + final int s14 = matrix2.get(1, 4); + final int s24 = matrix2.get(2, 4); + final int s34 = matrix2.get(3, 4); + final int s44 = matrix2.get(4, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33 + f40 * s34); + output.set(4, 0, f00 * s40 + f10 * s41 + f20 * s42 + f30 * s43 + f40 * s44); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33 + f41 * s34); + output.set(4, 1, f01 * s40 + f11 * s41 + f21 * s42 + f31 * s43 + f41 * s44); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23 + f42 * s24); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33 + f42 * s34); + output.set(4, 2, f02 * s40 + f12 * s41 + f22 * s42 + f32 * s43 + f42 * s44); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03 + f43 * s04); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13 + f43 * s14); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23 + f43 * s24); + output.set(3, 3, f03 * s30 + f13 * s31 + f23 * s32 + f33 * s33 + f43 * s34); + output.set(4, 3, f03 * s40 + f13 * s41 + f23 * s42 + f33 * s43 + f43 * s44); + return output; + } + + private static IMatrixSetterInt multiplyMatrix5x5x1(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int f30 = matrix1.get(3, 0); + final int f40 = matrix1.get(4, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f21 = matrix1.get(2, 1); + final int f31 = matrix1.get(3, 1); + final int f41 = matrix1.get(4, 1); + final int f02 = matrix1.get(0, 2); + final int f12 = matrix1.get(1, 2); + final int f22 = matrix1.get(2, 2); + final int f32 = matrix1.get(3, 2); + final int f42 = matrix1.get(4, 2); + final int f03 = matrix1.get(0, 3); + final int f13 = matrix1.get(1, 3); + final int f23 = matrix1.get(2, 3); + final int f33 = matrix1.get(3, 3); + final int f43 = matrix1.get(4, 3); + final int f04 = matrix1.get(0, 4); + final int f14 = matrix1.get(1, 4); + final int f24 = matrix1.get(2, 4); + final int f34 = matrix1.get(3, 4); + final int f44 = matrix1.get(4, 4); + final int s00 = matrix2.get(0, 0); + final int s01 = matrix2.get(0, 1); + final int s02 = matrix2.get(0, 2); + final int s03 = matrix2.get(0, 3); + final int s04 = matrix2.get(0, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03 + f43 * s04); + output.set(0, 4, f04 * s00 + f14 * s01 + f24 * s02 + f34 * s03 + f44 * s04); return output; } private static IMatrixSetterInt multiplyMatrix5x5x2(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final int f_c00 = matrix1.get(0, 0); - final int f_c10 = matrix1.get(1, 0); - final int f_c20 = matrix1.get(2, 0); - final int f_c30 = matrix1.get(3, 0); - final int f_c40 = matrix1.get(4, 0); - final int f_c01 = matrix1.get(0, 1); - final int f_c11 = matrix1.get(1, 1); - final int f_c21 = matrix1.get(2, 1); - final int f_c31 = matrix1.get(3, 1); - final int f_c41 = matrix1.get(4, 1); - final int f_c02 = matrix1.get(0, 2); - final int f_c12 = matrix1.get(1, 2); - final int f_c22 = matrix1.get(2, 2); - final int f_c32 = matrix1.get(3, 2); - final int f_c42 = matrix1.get(4, 2); - final int f_c03 = matrix1.get(0, 3); - final int f_c13 = matrix1.get(1, 3); - final int f_c23 = matrix1.get(2, 3); - final int f_c33 = matrix1.get(3, 3); - final int f_c43 = matrix1.get(4, 3); - final int f_c04 = matrix1.get(0, 4); - final int f_c14 = matrix1.get(1, 4); - final int f_c24 = matrix1.get(2, 4); - final int f_c34 = matrix1.get(3, 4); - final int f_c44 = matrix1.get(4, 4); - final int s_c00 = matrix2.get(0, 0); - final int s_c10 = matrix2.get(1, 0); - final int s_c01 = matrix2.get(0, 1); - final int s_c11 = matrix2.get(1, 1); - final int s_c02 = matrix2.get(0, 2); - final int s_c12 = matrix2.get(1, 2); - final int s_c03 = matrix2.get(0, 3); - final int s_c13 = matrix2.get(1, 3); - final int s_c04 = matrix2.get(0, 4); - final int s_c14 = matrix2.get(1, 4); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03 + f_c43*s_c04); - output.set(0, 4, f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02 + f_c34*s_c03 + f_c44*s_c04); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13 + f_c43*s_c14); - output.set(1, 4, f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12 + f_c34*s_c13 + f_c44*s_c14); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int f30 = matrix1.get(3, 0); + final int f40 = matrix1.get(4, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f21 = matrix1.get(2, 1); + final int f31 = matrix1.get(3, 1); + final int f41 = matrix1.get(4, 1); + final int f02 = matrix1.get(0, 2); + final int f12 = matrix1.get(1, 2); + final int f22 = matrix1.get(2, 2); + final int f32 = matrix1.get(3, 2); + final int f42 = matrix1.get(4, 2); + final int f03 = matrix1.get(0, 3); + final int f13 = matrix1.get(1, 3); + final int f23 = matrix1.get(2, 3); + final int f33 = matrix1.get(3, 3); + final int f43 = matrix1.get(4, 3); + final int f04 = matrix1.get(0, 4); + final int f14 = matrix1.get(1, 4); + final int f24 = matrix1.get(2, 4); + final int f34 = matrix1.get(3, 4); + final int f44 = matrix1.get(4, 4); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s02 = matrix2.get(0, 2); + final int s12 = matrix2.get(1, 2); + final int s03 = matrix2.get(0, 3); + final int s13 = matrix2.get(1, 3); + final int s04 = matrix2.get(0, 4); + final int s14 = matrix2.get(1, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03 + f43 * s04); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13 + f43 * s14); + output.set(0, 4, f04 * s00 + f14 * s01 + f24 * s02 + f34 * s03 + f44 * s04); + output.set(1, 4, f04 * s10 + f14 * s11 + f24 * s12 + f34 * s13 + f44 * s14); return output; } private static IMatrixSetterInt multiplyMatrix5x5x3(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final int f_c00 = matrix1.get(0, 0); - final int f_c10 = matrix1.get(1, 0); - final int f_c20 = matrix1.get(2, 0); - final int f_c30 = matrix1.get(3, 0); - final int f_c40 = matrix1.get(4, 0); - final int f_c01 = matrix1.get(0, 1); - final int f_c11 = matrix1.get(1, 1); - final int f_c21 = matrix1.get(2, 1); - final int f_c31 = matrix1.get(3, 1); - final int f_c41 = matrix1.get(4, 1); - final int f_c02 = matrix1.get(0, 2); - final int f_c12 = matrix1.get(1, 2); - final int f_c22 = matrix1.get(2, 2); - final int f_c32 = matrix1.get(3, 2); - final int f_c42 = matrix1.get(4, 2); - final int f_c03 = matrix1.get(0, 3); - final int f_c13 = matrix1.get(1, 3); - final int f_c23 = matrix1.get(2, 3); - final int f_c33 = matrix1.get(3, 3); - final int f_c43 = matrix1.get(4, 3); - final int f_c04 = matrix1.get(0, 4); - final int f_c14 = matrix1.get(1, 4); - final int f_c24 = matrix1.get(2, 4); - final int f_c34 = matrix1.get(3, 4); - final int f_c44 = matrix1.get(4, 4); - final int s_c00 = matrix2.get(0, 0); - final int s_c10 = matrix2.get(1, 0); - final int s_c20 = matrix2.get(2, 0); - final int s_c01 = matrix2.get(0, 1); - final int s_c11 = matrix2.get(1, 1); - final int s_c21 = matrix2.get(2, 1); - final int s_c02 = matrix2.get(0, 2); - final int s_c12 = matrix2.get(1, 2); - final int s_c22 = matrix2.get(2, 2); - final int s_c03 = matrix2.get(0, 3); - final int s_c13 = matrix2.get(1, 3); - final int s_c23 = matrix2.get(2, 3); - final int s_c04 = matrix2.get(0, 4); - final int s_c14 = matrix2.get(1, 4); - final int s_c24 = matrix2.get(2, 4); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03 + f_c43*s_c04); - output.set(0, 4, f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02 + f_c34*s_c03 + f_c44*s_c04); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13 + f_c43*s_c14); - output.set(1, 4, f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12 + f_c34*s_c13 + f_c44*s_c14); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23 + f_c42*s_c24); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23 + f_c43*s_c24); - output.set(2, 4, f_c04*s_c20 + f_c14*s_c21 + f_c24*s_c22 + f_c34*s_c23 + f_c44*s_c24); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int f30 = matrix1.get(3, 0); + final int f40 = matrix1.get(4, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f21 = matrix1.get(2, 1); + final int f31 = matrix1.get(3, 1); + final int f41 = matrix1.get(4, 1); + final int f02 = matrix1.get(0, 2); + final int f12 = matrix1.get(1, 2); + final int f22 = matrix1.get(2, 2); + final int f32 = matrix1.get(3, 2); + final int f42 = matrix1.get(4, 2); + final int f03 = matrix1.get(0, 3); + final int f13 = matrix1.get(1, 3); + final int f23 = matrix1.get(2, 3); + final int f33 = matrix1.get(3, 3); + final int f43 = matrix1.get(4, 3); + final int f04 = matrix1.get(0, 4); + final int f14 = matrix1.get(1, 4); + final int f24 = matrix1.get(2, 4); + final int f34 = matrix1.get(3, 4); + final int f44 = matrix1.get(4, 4); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s21 = matrix2.get(2, 1); + final int s02 = matrix2.get(0, 2); + final int s12 = matrix2.get(1, 2); + final int s22 = matrix2.get(2, 2); + final int s03 = matrix2.get(0, 3); + final int s13 = matrix2.get(1, 3); + final int s23 = matrix2.get(2, 3); + final int s04 = matrix2.get(0, 4); + final int s14 = matrix2.get(1, 4); + final int s24 = matrix2.get(2, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23 + f42 * s24); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03 + f43 * s04); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13 + f43 * s14); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23 + f43 * s24); + output.set(0, 4, f04 * s00 + f14 * s01 + f24 * s02 + f34 * s03 + f44 * s04); + output.set(1, 4, f04 * s10 + f14 * s11 + f24 * s12 + f34 * s13 + f44 * s14); + output.set(2, 4, f04 * s20 + f14 * s21 + f24 * s22 + f34 * s23 + f44 * s24); return output; } private static IMatrixSetterInt multiplyMatrix5x5x4(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final int f_c00 = matrix1.get(0, 0); - final int f_c10 = matrix1.get(1, 0); - final int f_c20 = matrix1.get(2, 0); - final int f_c30 = matrix1.get(3, 0); - final int f_c40 = matrix1.get(4, 0); - final int f_c01 = matrix1.get(0, 1); - final int f_c11 = matrix1.get(1, 1); - final int f_c21 = matrix1.get(2, 1); - final int f_c31 = matrix1.get(3, 1); - final int f_c41 = matrix1.get(4, 1); - final int f_c02 = matrix1.get(0, 2); - final int f_c12 = matrix1.get(1, 2); - final int f_c22 = matrix1.get(2, 2); - final int f_c32 = matrix1.get(3, 2); - final int f_c42 = matrix1.get(4, 2); - final int f_c03 = matrix1.get(0, 3); - final int f_c13 = matrix1.get(1, 3); - final int f_c23 = matrix1.get(2, 3); - final int f_c33 = matrix1.get(3, 3); - final int f_c43 = matrix1.get(4, 3); - final int f_c04 = matrix1.get(0, 4); - final int f_c14 = matrix1.get(1, 4); - final int f_c24 = matrix1.get(2, 4); - final int f_c34 = matrix1.get(3, 4); - final int f_c44 = matrix1.get(4, 4); - final int s_c00 = matrix2.get(0, 0); - final int s_c10 = matrix2.get(1, 0); - final int s_c20 = matrix2.get(2, 0); - final int s_c30 = matrix2.get(3, 0); - final int s_c01 = matrix2.get(0, 1); - final int s_c11 = matrix2.get(1, 1); - final int s_c21 = matrix2.get(2, 1); - final int s_c31 = matrix2.get(3, 1); - final int s_c02 = matrix2.get(0, 2); - final int s_c12 = matrix2.get(1, 2); - final int s_c22 = matrix2.get(2, 2); - final int s_c32 = matrix2.get(3, 2); - final int s_c03 = matrix2.get(0, 3); - final int s_c13 = matrix2.get(1, 3); - final int s_c23 = matrix2.get(2, 3); - final int s_c33 = matrix2.get(3, 3); - final int s_c04 = matrix2.get(0, 4); - final int s_c14 = matrix2.get(1, 4); - final int s_c24 = matrix2.get(2, 4); - final int s_c34 = matrix2.get(3, 4); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03 + f_c43*s_c04); - output.set(0, 4, f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02 + f_c34*s_c03 + f_c44*s_c04); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13 + f_c43*s_c14); - output.set(1, 4, f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12 + f_c34*s_c13 + f_c44*s_c14); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23 + f_c42*s_c24); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23 + f_c43*s_c24); - output.set(2, 4, f_c04*s_c20 + f_c14*s_c21 + f_c24*s_c22 + f_c34*s_c23 + f_c44*s_c24); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33 + f_c40*s_c34); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33 + f_c41*s_c34); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33 + f_c42*s_c34); - output.set(3, 3, f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32 + f_c33*s_c33 + f_c43*s_c34); - output.set(3, 4, f_c04*s_c30 + f_c14*s_c31 + f_c24*s_c32 + f_c34*s_c33 + f_c44*s_c34); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int f30 = matrix1.get(3, 0); + final int f40 = matrix1.get(4, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f21 = matrix1.get(2, 1); + final int f31 = matrix1.get(3, 1); + final int f41 = matrix1.get(4, 1); + final int f02 = matrix1.get(0, 2); + final int f12 = matrix1.get(1, 2); + final int f22 = matrix1.get(2, 2); + final int f32 = matrix1.get(3, 2); + final int f42 = matrix1.get(4, 2); + final int f03 = matrix1.get(0, 3); + final int f13 = matrix1.get(1, 3); + final int f23 = matrix1.get(2, 3); + final int f33 = matrix1.get(3, 3); + final int f43 = matrix1.get(4, 3); + final int f04 = matrix1.get(0, 4); + final int f14 = matrix1.get(1, 4); + final int f24 = matrix1.get(2, 4); + final int f34 = matrix1.get(3, 4); + final int f44 = matrix1.get(4, 4); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + final int s30 = matrix2.get(3, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s21 = matrix2.get(2, 1); + final int s31 = matrix2.get(3, 1); + final int s02 = matrix2.get(0, 2); + final int s12 = matrix2.get(1, 2); + final int s22 = matrix2.get(2, 2); + final int s32 = matrix2.get(3, 2); + final int s03 = matrix2.get(0, 3); + final int s13 = matrix2.get(1, 3); + final int s23 = matrix2.get(2, 3); + final int s33 = matrix2.get(3, 3); + final int s04 = matrix2.get(0, 4); + final int s14 = matrix2.get(1, 4); + final int s24 = matrix2.get(2, 4); + final int s34 = matrix2.get(3, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33 + f40 * s34); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33 + f41 * s34); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23 + f42 * s24); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33 + f42 * s34); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03 + f43 * s04); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13 + f43 * s14); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23 + f43 * s24); + output.set(3, 3, f03 * s30 + f13 * s31 + f23 * s32 + f33 * s33 + f43 * s34); + output.set(0, 4, f04 * s00 + f14 * s01 + f24 * s02 + f34 * s03 + f44 * s04); + output.set(1, 4, f04 * s10 + f14 * s11 + f24 * s12 + f34 * s13 + f44 * s14); + output.set(2, 4, f04 * s20 + f14 * s21 + f24 * s22 + f34 * s23 + f44 * s24); + output.set(3, 4, f04 * s30 + f14 * s31 + f24 * s32 + f34 * s33 + f44 * s34); return output; } private static IMatrixSetterInt multiplyMatrix5x5x5(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final int f_c00 = matrix1.get(0, 0); - final int f_c10 = matrix1.get(1, 0); - final int f_c20 = matrix1.get(2, 0); - final int f_c30 = matrix1.get(3, 0); - final int f_c40 = matrix1.get(4, 0); - final int f_c01 = matrix1.get(0, 1); - final int f_c11 = matrix1.get(1, 1); - final int f_c21 = matrix1.get(2, 1); - final int f_c31 = matrix1.get(3, 1); - final int f_c41 = matrix1.get(4, 1); - final int f_c02 = matrix1.get(0, 2); - final int f_c12 = matrix1.get(1, 2); - final int f_c22 = matrix1.get(2, 2); - final int f_c32 = matrix1.get(3, 2); - final int f_c42 = matrix1.get(4, 2); - final int f_c03 = matrix1.get(0, 3); - final int f_c13 = matrix1.get(1, 3); - final int f_c23 = matrix1.get(2, 3); - final int f_c33 = matrix1.get(3, 3); - final int f_c43 = matrix1.get(4, 3); - final int f_c04 = matrix1.get(0, 4); - final int f_c14 = matrix1.get(1, 4); - final int f_c24 = matrix1.get(2, 4); - final int f_c34 = matrix1.get(3, 4); - final int f_c44 = matrix1.get(4, 4); - final int s_c00 = matrix2.get(0, 0); - final int s_c10 = matrix2.get(1, 0); - final int s_c20 = matrix2.get(2, 0); - final int s_c30 = matrix2.get(3, 0); - final int s_c40 = matrix2.get(4, 0); - final int s_c01 = matrix2.get(0, 1); - final int s_c11 = matrix2.get(1, 1); - final int s_c21 = matrix2.get(2, 1); - final int s_c31 = matrix2.get(3, 1); - final int s_c41 = matrix2.get(4, 1); - final int s_c02 = matrix2.get(0, 2); - final int s_c12 = matrix2.get(1, 2); - final int s_c22 = matrix2.get(2, 2); - final int s_c32 = matrix2.get(3, 2); - final int s_c42 = matrix2.get(4, 2); - final int s_c03 = matrix2.get(0, 3); - final int s_c13 = matrix2.get(1, 3); - final int s_c23 = matrix2.get(2, 3); - final int s_c33 = matrix2.get(3, 3); - final int s_c43 = matrix2.get(4, 3); - final int s_c04 = matrix2.get(0, 4); - final int s_c14 = matrix2.get(1, 4); - final int s_c24 = matrix2.get(2, 4); - final int s_c34 = matrix2.get(3, 4); - final int s_c44 = matrix2.get(4, 4); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03 + f_c43*s_c04); - output.set(0, 4, f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02 + f_c34*s_c03 + f_c44*s_c04); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13 + f_c43*s_c14); - output.set(1, 4, f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12 + f_c34*s_c13 + f_c44*s_c14); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23 + f_c42*s_c24); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23 + f_c43*s_c24); - output.set(2, 4, f_c04*s_c20 + f_c14*s_c21 + f_c24*s_c22 + f_c34*s_c23 + f_c44*s_c24); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33 + f_c40*s_c34); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33 + f_c41*s_c34); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33 + f_c42*s_c34); - output.set(3, 3, f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32 + f_c33*s_c33 + f_c43*s_c34); - output.set(3, 4, f_c04*s_c30 + f_c14*s_c31 + f_c24*s_c32 + f_c34*s_c33 + f_c44*s_c34); - output.set(4, 0, f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42 + f_c30*s_c43 + f_c40*s_c44); - output.set(4, 1, f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42 + f_c31*s_c43 + f_c41*s_c44); - output.set(4, 2, f_c02*s_c40 + f_c12*s_c41 + f_c22*s_c42 + f_c32*s_c43 + f_c42*s_c44); - output.set(4, 3, f_c03*s_c40 + f_c13*s_c41 + f_c23*s_c42 + f_c33*s_c43 + f_c43*s_c44); - output.set(4, 4, f_c04*s_c40 + f_c14*s_c41 + f_c24*s_c42 + f_c34*s_c43 + f_c44*s_c44); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final int f00 = matrix1.get(0, 0); + final int f10 = matrix1.get(1, 0); + final int f20 = matrix1.get(2, 0); + final int f30 = matrix1.get(3, 0); + final int f40 = matrix1.get(4, 0); + final int f01 = matrix1.get(0, 1); + final int f11 = matrix1.get(1, 1); + final int f21 = matrix1.get(2, 1); + final int f31 = matrix1.get(3, 1); + final int f41 = matrix1.get(4, 1); + final int f02 = matrix1.get(0, 2); + final int f12 = matrix1.get(1, 2); + final int f22 = matrix1.get(2, 2); + final int f32 = matrix1.get(3, 2); + final int f42 = matrix1.get(4, 2); + final int f03 = matrix1.get(0, 3); + final int f13 = matrix1.get(1, 3); + final int f23 = matrix1.get(2, 3); + final int f33 = matrix1.get(3, 3); + final int f43 = matrix1.get(4, 3); + final int f04 = matrix1.get(0, 4); + final int f14 = matrix1.get(1, 4); + final int f24 = matrix1.get(2, 4); + final int f34 = matrix1.get(3, 4); + final int f44 = matrix1.get(4, 4); + final int s00 = matrix2.get(0, 0); + final int s10 = matrix2.get(1, 0); + final int s20 = matrix2.get(2, 0); + final int s30 = matrix2.get(3, 0); + final int s40 = matrix2.get(4, 0); + final int s01 = matrix2.get(0, 1); + final int s11 = matrix2.get(1, 1); + final int s21 = matrix2.get(2, 1); + final int s31 = matrix2.get(3, 1); + final int s41 = matrix2.get(4, 1); + final int s02 = matrix2.get(0, 2); + final int s12 = matrix2.get(1, 2); + final int s22 = matrix2.get(2, 2); + final int s32 = matrix2.get(3, 2); + final int s42 = matrix2.get(4, 2); + final int s03 = matrix2.get(0, 3); + final int s13 = matrix2.get(1, 3); + final int s23 = matrix2.get(2, 3); + final int s33 = matrix2.get(3, 3); + final int s43 = matrix2.get(4, 3); + final int s04 = matrix2.get(0, 4); + final int s14 = matrix2.get(1, 4); + final int s24 = matrix2.get(2, 4); + final int s34 = matrix2.get(3, 4); + final int s44 = matrix2.get(4, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33 + f40 * s34); + output.set(4, 0, f00 * s40 + f10 * s41 + f20 * s42 + f30 * s43 + f40 * s44); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33 + f41 * s34); + output.set(4, 1, f01 * s40 + f11 * s41 + f21 * s42 + f31 * s43 + f41 * s44); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23 + f42 * s24); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33 + f42 * s34); + output.set(4, 2, f02 * s40 + f12 * s41 + f22 * s42 + f32 * s43 + f42 * s44); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03 + f43 * s04); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13 + f43 * s14); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23 + f43 * s24); + output.set(3, 3, f03 * s30 + f13 * s31 + f23 * s32 + f33 * s33 + f43 * s34); + output.set(4, 3, f03 * s40 + f13 * s41 + f23 * s42 + f33 * s43 + f43 * s44); + output.set(0, 4, f04 * s00 + f14 * s01 + f24 * s02 + f34 * s03 + f44 * s04); + output.set(1, 4, f04 * s10 + f14 * s11 + f24 * s12 + f34 * s13 + f44 * s14); + output.set(2, 4, f04 * s20 + f14 * s21 + f24 * s22 + f34 * s23 + f44 * s24); + output.set(3, 4, f04 * s30 + f14 * s31 + f24 * s32 + f34 * s33 + f44 * s34); + output.set(4, 4, f04 * s40 + f14 * s41 + f24 * s42 + f34 * s43 + f44 * s44); return output; } /** * Automatically generated concrete matrix multiplication. If no mapping exist, this method returns null. * - * @return new Int2Dimensional + * @return new Int2Dimensional */ - @org.jetbrains.annotations.Nullable - public static Int2Dimensional multiplyMatrix(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2) { + @org.jetbrains.annotations.Nullable + public static Int2Dimensional multiplyMatrix(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2) { if (matrix1.getColumns() != matrix2.getRows()) return null; - switch (matrix1.getColumns()) { - case 2: switch (matrix1.getRows()) { - case 2: switch (matrix2.getColumns()) { + switch(matrix1.getColumns()) { + case 1: switch(matrix1.getRows()) { + case 1: switch(matrix2.getColumns()) { + case 1: return (Int2Dimensional) multiplyMatrix1x1x1(matrix1, matrix2, new Int2Dimensional(1, 1)); + case 2: return (Int2Dimensional) multiplyMatrix1x1x2(matrix1, matrix2, new Int2Dimensional(2, 1)); + case 3: return (Int2Dimensional) multiplyMatrix1x1x3(matrix1, matrix2, new Int2Dimensional(3, 1)); + case 4: return (Int2Dimensional) multiplyMatrix1x1x4(matrix1, matrix2, new Int2Dimensional(4, 1)); + case 5: return (Int2Dimensional) multiplyMatrix1x1x5(matrix1, matrix2, new Int2Dimensional(5, 1)); + default: return null; + } + case 2: switch(matrix2.getColumns()) { + case 1: return (Int2Dimensional) multiplyMatrix2x1x1(matrix1, matrix2, new Int2Dimensional(1, 2)); + case 2: return (Int2Dimensional) multiplyMatrix2x1x2(matrix1, matrix2, new Int2Dimensional(2, 2)); + case 3: return (Int2Dimensional) multiplyMatrix2x1x3(matrix1, matrix2, new Int2Dimensional(3, 2)); + case 4: return (Int2Dimensional) multiplyMatrix2x1x4(matrix1, matrix2, new Int2Dimensional(4, 2)); + case 5: return (Int2Dimensional) multiplyMatrix2x1x5(matrix1, matrix2, new Int2Dimensional(5, 2)); + default: return null; + } + case 3: switch(matrix2.getColumns()) { + case 1: return (Int2Dimensional) multiplyMatrix3x1x1(matrix1, matrix2, new Int2Dimensional(1, 3)); + case 2: return (Int2Dimensional) multiplyMatrix3x1x2(matrix1, matrix2, new Int2Dimensional(2, 3)); + case 3: return (Int2Dimensional) multiplyMatrix3x1x3(matrix1, matrix2, new Int2Dimensional(3, 3)); + case 4: return (Int2Dimensional) multiplyMatrix3x1x4(matrix1, matrix2, new Int2Dimensional(4, 3)); + case 5: return (Int2Dimensional) multiplyMatrix3x1x5(matrix1, matrix2, new Int2Dimensional(5, 3)); + default: return null; + } + case 4: switch(matrix2.getColumns()) { + case 1: return (Int2Dimensional) multiplyMatrix4x1x1(matrix1, matrix2, new Int2Dimensional(1, 4)); + case 2: return (Int2Dimensional) multiplyMatrix4x1x2(matrix1, matrix2, new Int2Dimensional(2, 4)); + case 3: return (Int2Dimensional) multiplyMatrix4x1x3(matrix1, matrix2, new Int2Dimensional(3, 4)); + case 4: return (Int2Dimensional) multiplyMatrix4x1x4(matrix1, matrix2, new Int2Dimensional(4, 4)); + case 5: return (Int2Dimensional) multiplyMatrix4x1x5(matrix1, matrix2, new Int2Dimensional(5, 4)); + default: return null; + } + case 5: switch(matrix2.getColumns()) { + case 1: return (Int2Dimensional) multiplyMatrix5x1x1(matrix1, matrix2, new Int2Dimensional(1, 5)); + case 2: return (Int2Dimensional) multiplyMatrix5x1x2(matrix1, matrix2, new Int2Dimensional(2, 5)); + case 3: return (Int2Dimensional) multiplyMatrix5x1x3(matrix1, matrix2, new Int2Dimensional(3, 5)); + case 4: return (Int2Dimensional) multiplyMatrix5x1x4(matrix1, matrix2, new Int2Dimensional(4, 5)); + case 5: return (Int2Dimensional) multiplyMatrix5x1x5(matrix1, matrix2, new Int2Dimensional(5, 5)); + default: return null; + } + default: return null; + } + case 2: switch(matrix1.getRows()) { + case 1: switch(matrix2.getColumns()) { + case 1: return (Int2Dimensional) multiplyMatrix1x2x1(matrix1, matrix2, new Int2Dimensional(1, 1)); + case 2: return (Int2Dimensional) multiplyMatrix1x2x2(matrix1, matrix2, new Int2Dimensional(2, 1)); + case 3: return (Int2Dimensional) multiplyMatrix1x2x3(matrix1, matrix2, new Int2Dimensional(3, 1)); + case 4: return (Int2Dimensional) multiplyMatrix1x2x4(matrix1, matrix2, new Int2Dimensional(4, 1)); + case 5: return (Int2Dimensional) multiplyMatrix1x2x5(matrix1, matrix2, new Int2Dimensional(5, 1)); + default: return null; + } + case 2: switch(matrix2.getColumns()) { + case 1: return (Int2Dimensional) multiplyMatrix2x2x1(matrix1, matrix2, new Int2Dimensional(1, 2)); case 2: return (Int2Dimensional) multiplyMatrix2x2x2(matrix1, matrix2, new Int2Dimensional(2, 2)); case 3: return (Int2Dimensional) multiplyMatrix2x2x3(matrix1, matrix2, new Int2Dimensional(3, 2)); case 4: return (Int2Dimensional) multiplyMatrix2x2x4(matrix1, matrix2, new Int2Dimensional(4, 2)); case 5: return (Int2Dimensional) multiplyMatrix2x2x5(matrix1, matrix2, new Int2Dimensional(5, 2)); default: return null; } - case 3: switch (matrix2.getColumns()) { + case 3: switch(matrix2.getColumns()) { + case 1: return (Int2Dimensional) multiplyMatrix3x2x1(matrix1, matrix2, new Int2Dimensional(1, 3)); case 2: return (Int2Dimensional) multiplyMatrix3x2x2(matrix1, matrix2, new Int2Dimensional(2, 3)); case 3: return (Int2Dimensional) multiplyMatrix3x2x3(matrix1, matrix2, new Int2Dimensional(3, 3)); case 4: return (Int2Dimensional) multiplyMatrix3x2x4(matrix1, matrix2, new Int2Dimensional(4, 3)); case 5: return (Int2Dimensional) multiplyMatrix3x2x5(matrix1, matrix2, new Int2Dimensional(5, 3)); default: return null; } - case 4: switch (matrix2.getColumns()) { + case 4: switch(matrix2.getColumns()) { + case 1: return (Int2Dimensional) multiplyMatrix4x2x1(matrix1, matrix2, new Int2Dimensional(1, 4)); case 2: return (Int2Dimensional) multiplyMatrix4x2x2(matrix1, matrix2, new Int2Dimensional(2, 4)); case 3: return (Int2Dimensional) multiplyMatrix4x2x3(matrix1, matrix2, new Int2Dimensional(3, 4)); case 4: return (Int2Dimensional) multiplyMatrix4x2x4(matrix1, matrix2, new Int2Dimensional(4, 4)); case 5: return (Int2Dimensional) multiplyMatrix4x2x5(matrix1, matrix2, new Int2Dimensional(5, 4)); default: return null; } - case 5: switch (matrix2.getColumns()) { + case 5: switch(matrix2.getColumns()) { + case 1: return (Int2Dimensional) multiplyMatrix5x2x1(matrix1, matrix2, new Int2Dimensional(1, 5)); case 2: return (Int2Dimensional) multiplyMatrix5x2x2(matrix1, matrix2, new Int2Dimensional(2, 5)); case 3: return (Int2Dimensional) multiplyMatrix5x2x3(matrix1, matrix2, new Int2Dimensional(3, 5)); case 4: return (Int2Dimensional) multiplyMatrix5x2x4(matrix1, matrix2, new Int2Dimensional(4, 5)); @@ -2788,29 +4230,41 @@ public final class MultiplicationsInt { } default: return null; } - case 3: switch (matrix1.getRows()) { - case 2: switch (matrix2.getColumns()) { + case 3: switch(matrix1.getRows()) { + case 1: switch(matrix2.getColumns()) { + case 1: return (Int2Dimensional) multiplyMatrix1x3x1(matrix1, matrix2, new Int2Dimensional(1, 1)); + case 2: return (Int2Dimensional) multiplyMatrix1x3x2(matrix1, matrix2, new Int2Dimensional(2, 1)); + case 3: return (Int2Dimensional) multiplyMatrix1x3x3(matrix1, matrix2, new Int2Dimensional(3, 1)); + case 4: return (Int2Dimensional) multiplyMatrix1x3x4(matrix1, matrix2, new Int2Dimensional(4, 1)); + case 5: return (Int2Dimensional) multiplyMatrix1x3x5(matrix1, matrix2, new Int2Dimensional(5, 1)); + default: return null; + } + case 2: switch(matrix2.getColumns()) { + case 1: return (Int2Dimensional) multiplyMatrix2x3x1(matrix1, matrix2, new Int2Dimensional(1, 2)); case 2: return (Int2Dimensional) multiplyMatrix2x3x2(matrix1, matrix2, new Int2Dimensional(2, 2)); case 3: return (Int2Dimensional) multiplyMatrix2x3x3(matrix1, matrix2, new Int2Dimensional(3, 2)); case 4: return (Int2Dimensional) multiplyMatrix2x3x4(matrix1, matrix2, new Int2Dimensional(4, 2)); case 5: return (Int2Dimensional) multiplyMatrix2x3x5(matrix1, matrix2, new Int2Dimensional(5, 2)); default: return null; } - case 3: switch (matrix2.getColumns()) { + case 3: switch(matrix2.getColumns()) { + case 1: return (Int2Dimensional) multiplyMatrix3x3x1(matrix1, matrix2, new Int2Dimensional(1, 3)); case 2: return (Int2Dimensional) multiplyMatrix3x3x2(matrix1, matrix2, new Int2Dimensional(2, 3)); case 3: return (Int2Dimensional) multiplyMatrix3x3x3(matrix1, matrix2, new Int2Dimensional(3, 3)); case 4: return (Int2Dimensional) multiplyMatrix3x3x4(matrix1, matrix2, new Int2Dimensional(4, 3)); case 5: return (Int2Dimensional) multiplyMatrix3x3x5(matrix1, matrix2, new Int2Dimensional(5, 3)); default: return null; } - case 4: switch (matrix2.getColumns()) { + case 4: switch(matrix2.getColumns()) { + case 1: return (Int2Dimensional) multiplyMatrix4x3x1(matrix1, matrix2, new Int2Dimensional(1, 4)); case 2: return (Int2Dimensional) multiplyMatrix4x3x2(matrix1, matrix2, new Int2Dimensional(2, 4)); case 3: return (Int2Dimensional) multiplyMatrix4x3x3(matrix1, matrix2, new Int2Dimensional(3, 4)); case 4: return (Int2Dimensional) multiplyMatrix4x3x4(matrix1, matrix2, new Int2Dimensional(4, 4)); case 5: return (Int2Dimensional) multiplyMatrix4x3x5(matrix1, matrix2, new Int2Dimensional(5, 4)); default: return null; } - case 5: switch (matrix2.getColumns()) { + case 5: switch(matrix2.getColumns()) { + case 1: return (Int2Dimensional) multiplyMatrix5x3x1(matrix1, matrix2, new Int2Dimensional(1, 5)); case 2: return (Int2Dimensional) multiplyMatrix5x3x2(matrix1, matrix2, new Int2Dimensional(2, 5)); case 3: return (Int2Dimensional) multiplyMatrix5x3x3(matrix1, matrix2, new Int2Dimensional(3, 5)); case 4: return (Int2Dimensional) multiplyMatrix5x3x4(matrix1, matrix2, new Int2Dimensional(4, 5)); @@ -2819,29 +4273,41 @@ public final class MultiplicationsInt { } default: return null; } - case 4: switch (matrix1.getRows()) { - case 2: switch (matrix2.getColumns()) { + case 4: switch(matrix1.getRows()) { + case 1: switch(matrix2.getColumns()) { + case 1: return (Int2Dimensional) multiplyMatrix1x4x1(matrix1, matrix2, new Int2Dimensional(1, 1)); + case 2: return (Int2Dimensional) multiplyMatrix1x4x2(matrix1, matrix2, new Int2Dimensional(2, 1)); + case 3: return (Int2Dimensional) multiplyMatrix1x4x3(matrix1, matrix2, new Int2Dimensional(3, 1)); + case 4: return (Int2Dimensional) multiplyMatrix1x4x4(matrix1, matrix2, new Int2Dimensional(4, 1)); + case 5: return (Int2Dimensional) multiplyMatrix1x4x5(matrix1, matrix2, new Int2Dimensional(5, 1)); + default: return null; + } + case 2: switch(matrix2.getColumns()) { + case 1: return (Int2Dimensional) multiplyMatrix2x4x1(matrix1, matrix2, new Int2Dimensional(1, 2)); case 2: return (Int2Dimensional) multiplyMatrix2x4x2(matrix1, matrix2, new Int2Dimensional(2, 2)); case 3: return (Int2Dimensional) multiplyMatrix2x4x3(matrix1, matrix2, new Int2Dimensional(3, 2)); case 4: return (Int2Dimensional) multiplyMatrix2x4x4(matrix1, matrix2, new Int2Dimensional(4, 2)); case 5: return (Int2Dimensional) multiplyMatrix2x4x5(matrix1, matrix2, new Int2Dimensional(5, 2)); default: return null; } - case 3: switch (matrix2.getColumns()) { + case 3: switch(matrix2.getColumns()) { + case 1: return (Int2Dimensional) multiplyMatrix3x4x1(matrix1, matrix2, new Int2Dimensional(1, 3)); case 2: return (Int2Dimensional) multiplyMatrix3x4x2(matrix1, matrix2, new Int2Dimensional(2, 3)); case 3: return (Int2Dimensional) multiplyMatrix3x4x3(matrix1, matrix2, new Int2Dimensional(3, 3)); case 4: return (Int2Dimensional) multiplyMatrix3x4x4(matrix1, matrix2, new Int2Dimensional(4, 3)); case 5: return (Int2Dimensional) multiplyMatrix3x4x5(matrix1, matrix2, new Int2Dimensional(5, 3)); default: return null; } - case 4: switch (matrix2.getColumns()) { + case 4: switch(matrix2.getColumns()) { + case 1: return (Int2Dimensional) multiplyMatrix4x4x1(matrix1, matrix2, new Int2Dimensional(1, 4)); case 2: return (Int2Dimensional) multiplyMatrix4x4x2(matrix1, matrix2, new Int2Dimensional(2, 4)); case 3: return (Int2Dimensional) multiplyMatrix4x4x3(matrix1, matrix2, new Int2Dimensional(3, 4)); case 4: return (Int2Dimensional) multiplyMatrix4x4x4(matrix1, matrix2, new Int2Dimensional(4, 4)); case 5: return (Int2Dimensional) multiplyMatrix4x4x5(matrix1, matrix2, new Int2Dimensional(5, 4)); default: return null; } - case 5: switch (matrix2.getColumns()) { + case 5: switch(matrix2.getColumns()) { + case 1: return (Int2Dimensional) multiplyMatrix5x4x1(matrix1, matrix2, new Int2Dimensional(1, 5)); case 2: return (Int2Dimensional) multiplyMatrix5x4x2(matrix1, matrix2, new Int2Dimensional(2, 5)); case 3: return (Int2Dimensional) multiplyMatrix5x4x3(matrix1, matrix2, new Int2Dimensional(3, 5)); case 4: return (Int2Dimensional) multiplyMatrix5x4x4(matrix1, matrix2, new Int2Dimensional(4, 5)); @@ -2850,29 +4316,41 @@ public final class MultiplicationsInt { } default: return null; } - case 5: switch (matrix1.getRows()) { - case 2: switch (matrix2.getColumns()) { + case 5: switch(matrix1.getRows()) { + case 1: switch(matrix2.getColumns()) { + case 1: return (Int2Dimensional) multiplyMatrix1x5x1(matrix1, matrix2, new Int2Dimensional(1, 1)); + case 2: return (Int2Dimensional) multiplyMatrix1x5x2(matrix1, matrix2, new Int2Dimensional(2, 1)); + case 3: return (Int2Dimensional) multiplyMatrix1x5x3(matrix1, matrix2, new Int2Dimensional(3, 1)); + case 4: return (Int2Dimensional) multiplyMatrix1x5x4(matrix1, matrix2, new Int2Dimensional(4, 1)); + case 5: return (Int2Dimensional) multiplyMatrix1x5x5(matrix1, matrix2, new Int2Dimensional(5, 1)); + default: return null; + } + case 2: switch(matrix2.getColumns()) { + case 1: return (Int2Dimensional) multiplyMatrix2x5x1(matrix1, matrix2, new Int2Dimensional(1, 2)); case 2: return (Int2Dimensional) multiplyMatrix2x5x2(matrix1, matrix2, new Int2Dimensional(2, 2)); case 3: return (Int2Dimensional) multiplyMatrix2x5x3(matrix1, matrix2, new Int2Dimensional(3, 2)); case 4: return (Int2Dimensional) multiplyMatrix2x5x4(matrix1, matrix2, new Int2Dimensional(4, 2)); case 5: return (Int2Dimensional) multiplyMatrix2x5x5(matrix1, matrix2, new Int2Dimensional(5, 2)); default: return null; } - case 3: switch (matrix2.getColumns()) { + case 3: switch(matrix2.getColumns()) { + case 1: return (Int2Dimensional) multiplyMatrix3x5x1(matrix1, matrix2, new Int2Dimensional(1, 3)); case 2: return (Int2Dimensional) multiplyMatrix3x5x2(matrix1, matrix2, new Int2Dimensional(2, 3)); case 3: return (Int2Dimensional) multiplyMatrix3x5x3(matrix1, matrix2, new Int2Dimensional(3, 3)); case 4: return (Int2Dimensional) multiplyMatrix3x5x4(matrix1, matrix2, new Int2Dimensional(4, 3)); case 5: return (Int2Dimensional) multiplyMatrix3x5x5(matrix1, matrix2, new Int2Dimensional(5, 3)); default: return null; } - case 4: switch (matrix2.getColumns()) { + case 4: switch(matrix2.getColumns()) { + case 1: return (Int2Dimensional) multiplyMatrix4x5x1(matrix1, matrix2, new Int2Dimensional(1, 4)); case 2: return (Int2Dimensional) multiplyMatrix4x5x2(matrix1, matrix2, new Int2Dimensional(2, 4)); case 3: return (Int2Dimensional) multiplyMatrix4x5x3(matrix1, matrix2, new Int2Dimensional(3, 4)); case 4: return (Int2Dimensional) multiplyMatrix4x5x4(matrix1, matrix2, new Int2Dimensional(4, 4)); case 5: return (Int2Dimensional) multiplyMatrix4x5x5(matrix1, matrix2, new Int2Dimensional(5, 4)); default: return null; } - case 5: switch (matrix2.getColumns()) { + case 5: switch(matrix2.getColumns()) { + case 1: return (Int2Dimensional) multiplyMatrix5x5x1(matrix1, matrix2, new Int2Dimensional(1, 5)); case 2: return (Int2Dimensional) multiplyMatrix5x5x2(matrix1, matrix2, new Int2Dimensional(2, 5)); case 3: return (Int2Dimensional) multiplyMatrix5x5x3(matrix1, matrix2, new Int2Dimensional(3, 5)); case 4: return (Int2Dimensional) multiplyMatrix5x5x4(matrix1, matrix2, new Int2Dimensional(4, 5)); @@ -2884,39 +4362,94 @@ public final class MultiplicationsInt { default: return null; } } - /** - * Automatically generated concrete matrix multiplication. If no mapping exist, this method returns null. - * This method writes the result to specified [output] - * @return provided IMatrixSetterInt if mapping exists and computed, or null if mapping does not exist + * Automatically generated concrete matrix multiplication. + * This function writes the result onto specified output, and returns it, if mapping exists and computed, otherwise returns null. + * + * @return provided output, or null if mapping does not exist */ - @org.jetbrains.annotations.Nullable - public static IMatrixSetterInt multiplyMatrix(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { + @org.jetbrains.annotations.Nullable + public static IMatrixSetterInt multiplyMatrix(final IMatrixGetterInt matrix1, final IMatrixGetterInt matrix2, final IMatrixSetterInt output) { if (matrix1.getColumns() != matrix2.getRows()) return null; - switch (matrix1.getColumns()) { - case 2: switch (matrix1.getRows()) { - case 2: switch (matrix2.getColumns()) { + switch(matrix1.getColumns()) { + case 1: switch(matrix1.getRows()) { + case 1: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix1x1x1(matrix1, matrix2, output); + case 2: return multiplyMatrix1x1x2(matrix1, matrix2, output); + case 3: return multiplyMatrix1x1x3(matrix1, matrix2, output); + case 4: return multiplyMatrix1x1x4(matrix1, matrix2, output); + case 5: return multiplyMatrix1x1x5(matrix1, matrix2, output); + default: return null; + } + case 2: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix2x1x1(matrix1, matrix2, output); + case 2: return multiplyMatrix2x1x2(matrix1, matrix2, output); + case 3: return multiplyMatrix2x1x3(matrix1, matrix2, output); + case 4: return multiplyMatrix2x1x4(matrix1, matrix2, output); + case 5: return multiplyMatrix2x1x5(matrix1, matrix2, output); + default: return null; + } + case 3: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix3x1x1(matrix1, matrix2, output); + case 2: return multiplyMatrix3x1x2(matrix1, matrix2, output); + case 3: return multiplyMatrix3x1x3(matrix1, matrix2, output); + case 4: return multiplyMatrix3x1x4(matrix1, matrix2, output); + case 5: return multiplyMatrix3x1x5(matrix1, matrix2, output); + default: return null; + } + case 4: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix4x1x1(matrix1, matrix2, output); + case 2: return multiplyMatrix4x1x2(matrix1, matrix2, output); + case 3: return multiplyMatrix4x1x3(matrix1, matrix2, output); + case 4: return multiplyMatrix4x1x4(matrix1, matrix2, output); + case 5: return multiplyMatrix4x1x5(matrix1, matrix2, output); + default: return null; + } + case 5: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix5x1x1(matrix1, matrix2, output); + case 2: return multiplyMatrix5x1x2(matrix1, matrix2, output); + case 3: return multiplyMatrix5x1x3(matrix1, matrix2, output); + case 4: return multiplyMatrix5x1x4(matrix1, matrix2, output); + case 5: return multiplyMatrix5x1x5(matrix1, matrix2, output); + default: return null; + } + default: return null; + } + case 2: switch(matrix1.getRows()) { + case 1: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix1x2x1(matrix1, matrix2, output); + case 2: return multiplyMatrix1x2x2(matrix1, matrix2, output); + case 3: return multiplyMatrix1x2x3(matrix1, matrix2, output); + case 4: return multiplyMatrix1x2x4(matrix1, matrix2, output); + case 5: return multiplyMatrix1x2x5(matrix1, matrix2, output); + default: return null; + } + case 2: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix2x2x1(matrix1, matrix2, output); case 2: return multiplyMatrix2x2x2(matrix1, matrix2, output); case 3: return multiplyMatrix2x2x3(matrix1, matrix2, output); case 4: return multiplyMatrix2x2x4(matrix1, matrix2, output); case 5: return multiplyMatrix2x2x5(matrix1, matrix2, output); default: return null; } - case 3: switch (matrix2.getColumns()) { + case 3: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix3x2x1(matrix1, matrix2, output); case 2: return multiplyMatrix3x2x2(matrix1, matrix2, output); case 3: return multiplyMatrix3x2x3(matrix1, matrix2, output); case 4: return multiplyMatrix3x2x4(matrix1, matrix2, output); case 5: return multiplyMatrix3x2x5(matrix1, matrix2, output); default: return null; } - case 4: switch (matrix2.getColumns()) { + case 4: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix4x2x1(matrix1, matrix2, output); case 2: return multiplyMatrix4x2x2(matrix1, matrix2, output); case 3: return multiplyMatrix4x2x3(matrix1, matrix2, output); case 4: return multiplyMatrix4x2x4(matrix1, matrix2, output); case 5: return multiplyMatrix4x2x5(matrix1, matrix2, output); default: return null; } - case 5: switch (matrix2.getColumns()) { + case 5: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix5x2x1(matrix1, matrix2, output); case 2: return multiplyMatrix5x2x2(matrix1, matrix2, output); case 3: return multiplyMatrix5x2x3(matrix1, matrix2, output); case 4: return multiplyMatrix5x2x4(matrix1, matrix2, output); @@ -2925,29 +4458,41 @@ public final class MultiplicationsInt { } default: return null; } - case 3: switch (matrix1.getRows()) { - case 2: switch (matrix2.getColumns()) { + case 3: switch(matrix1.getRows()) { + case 1: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix1x3x1(matrix1, matrix2, output); + case 2: return multiplyMatrix1x3x2(matrix1, matrix2, output); + case 3: return multiplyMatrix1x3x3(matrix1, matrix2, output); + case 4: return multiplyMatrix1x3x4(matrix1, matrix2, output); + case 5: return multiplyMatrix1x3x5(matrix1, matrix2, output); + default: return null; + } + case 2: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix2x3x1(matrix1, matrix2, output); case 2: return multiplyMatrix2x3x2(matrix1, matrix2, output); case 3: return multiplyMatrix2x3x3(matrix1, matrix2, output); case 4: return multiplyMatrix2x3x4(matrix1, matrix2, output); case 5: return multiplyMatrix2x3x5(matrix1, matrix2, output); default: return null; } - case 3: switch (matrix2.getColumns()) { + case 3: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix3x3x1(matrix1, matrix2, output); case 2: return multiplyMatrix3x3x2(matrix1, matrix2, output); case 3: return multiplyMatrix3x3x3(matrix1, matrix2, output); case 4: return multiplyMatrix3x3x4(matrix1, matrix2, output); case 5: return multiplyMatrix3x3x5(matrix1, matrix2, output); default: return null; } - case 4: switch (matrix2.getColumns()) { + case 4: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix4x3x1(matrix1, matrix2, output); case 2: return multiplyMatrix4x3x2(matrix1, matrix2, output); case 3: return multiplyMatrix4x3x3(matrix1, matrix2, output); case 4: return multiplyMatrix4x3x4(matrix1, matrix2, output); case 5: return multiplyMatrix4x3x5(matrix1, matrix2, output); default: return null; } - case 5: switch (matrix2.getColumns()) { + case 5: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix5x3x1(matrix1, matrix2, output); case 2: return multiplyMatrix5x3x2(matrix1, matrix2, output); case 3: return multiplyMatrix5x3x3(matrix1, matrix2, output); case 4: return multiplyMatrix5x3x4(matrix1, matrix2, output); @@ -2956,29 +4501,41 @@ public final class MultiplicationsInt { } default: return null; } - case 4: switch (matrix1.getRows()) { - case 2: switch (matrix2.getColumns()) { + case 4: switch(matrix1.getRows()) { + case 1: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix1x4x1(matrix1, matrix2, output); + case 2: return multiplyMatrix1x4x2(matrix1, matrix2, output); + case 3: return multiplyMatrix1x4x3(matrix1, matrix2, output); + case 4: return multiplyMatrix1x4x4(matrix1, matrix2, output); + case 5: return multiplyMatrix1x4x5(matrix1, matrix2, output); + default: return null; + } + case 2: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix2x4x1(matrix1, matrix2, output); case 2: return multiplyMatrix2x4x2(matrix1, matrix2, output); case 3: return multiplyMatrix2x4x3(matrix1, matrix2, output); case 4: return multiplyMatrix2x4x4(matrix1, matrix2, output); case 5: return multiplyMatrix2x4x5(matrix1, matrix2, output); default: return null; } - case 3: switch (matrix2.getColumns()) { + case 3: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix3x4x1(matrix1, matrix2, output); case 2: return multiplyMatrix3x4x2(matrix1, matrix2, output); case 3: return multiplyMatrix3x4x3(matrix1, matrix2, output); case 4: return multiplyMatrix3x4x4(matrix1, matrix2, output); case 5: return multiplyMatrix3x4x5(matrix1, matrix2, output); default: return null; } - case 4: switch (matrix2.getColumns()) { + case 4: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix4x4x1(matrix1, matrix2, output); case 2: return multiplyMatrix4x4x2(matrix1, matrix2, output); case 3: return multiplyMatrix4x4x3(matrix1, matrix2, output); case 4: return multiplyMatrix4x4x4(matrix1, matrix2, output); case 5: return multiplyMatrix4x4x5(matrix1, matrix2, output); default: return null; } - case 5: switch (matrix2.getColumns()) { + case 5: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix5x4x1(matrix1, matrix2, output); case 2: return multiplyMatrix5x4x2(matrix1, matrix2, output); case 3: return multiplyMatrix5x4x3(matrix1, matrix2, output); case 4: return multiplyMatrix5x4x4(matrix1, matrix2, output); @@ -2987,29 +4544,41 @@ public final class MultiplicationsInt { } default: return null; } - case 5: switch (matrix1.getRows()) { - case 2: switch (matrix2.getColumns()) { + case 5: switch(matrix1.getRows()) { + case 1: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix1x5x1(matrix1, matrix2, output); + case 2: return multiplyMatrix1x5x2(matrix1, matrix2, output); + case 3: return multiplyMatrix1x5x3(matrix1, matrix2, output); + case 4: return multiplyMatrix1x5x4(matrix1, matrix2, output); + case 5: return multiplyMatrix1x5x5(matrix1, matrix2, output); + default: return null; + } + case 2: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix2x5x1(matrix1, matrix2, output); case 2: return multiplyMatrix2x5x2(matrix1, matrix2, output); case 3: return multiplyMatrix2x5x3(matrix1, matrix2, output); case 4: return multiplyMatrix2x5x4(matrix1, matrix2, output); case 5: return multiplyMatrix2x5x5(matrix1, matrix2, output); default: return null; } - case 3: switch (matrix2.getColumns()) { + case 3: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix3x5x1(matrix1, matrix2, output); case 2: return multiplyMatrix3x5x2(matrix1, matrix2, output); case 3: return multiplyMatrix3x5x3(matrix1, matrix2, output); case 4: return multiplyMatrix3x5x4(matrix1, matrix2, output); case 5: return multiplyMatrix3x5x5(matrix1, matrix2, output); default: return null; } - case 4: switch (matrix2.getColumns()) { + case 4: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix4x5x1(matrix1, matrix2, output); case 2: return multiplyMatrix4x5x2(matrix1, matrix2, output); case 3: return multiplyMatrix4x5x3(matrix1, matrix2, output); case 4: return multiplyMatrix4x5x4(matrix1, matrix2, output); case 5: return multiplyMatrix4x5x5(matrix1, matrix2, output); default: return null; } - case 5: switch (matrix2.getColumns()) { + case 5: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix5x5x1(matrix1, matrix2, output); case 2: return multiplyMatrix5x5x2(matrix1, matrix2, output); case 3: return multiplyMatrix5x5x3(matrix1, matrix2, output); case 4: return multiplyMatrix5x5x4(matrix1, matrix2, output); diff --git a/src/kvector/java/ru/dbotthepony/kvector/matrix/generated/MultiplicationsLong.java b/src/kvector/java/ru/dbotthepony/kvector/matrix/generated/MultiplicationsLong.java index 0e35364c..119d3f37 100644 --- a/src/kvector/java/ru/dbotthepony/kvector/matrix/generated/MultiplicationsLong.java +++ b/src/kvector/java/ru/dbotthepony/kvector/matrix/generated/MultiplicationsLong.java @@ -3,7 +3,6 @@ package ru.dbotthepony.kvector.matrix.generated; import ru.dbotthepony.kvector.api.*; import ru.dbotthepony.kvector.narray.*; -// Some metaprogramming ///////////////////////////////// // THIS FILE IS AUTO GENERATED // // DO NOT EDIT // @@ -11,2775 +10,4218 @@ import ru.dbotthepony.kvector.narray.*; public final class MultiplicationsLong { private MultiplicationsLong() {} + private static IMatrixSetterLong multiplyMatrix1x1x1(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final long f00 = matrix1.get(0, 0); + final long s00 = matrix2.get(0, 0); + output.set(0, 0, f00 * s00); + return output; + } + + private static IMatrixSetterLong multiplyMatrix1x1x2(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final long f00 = matrix1.get(0, 0); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + return output; + } + + private static IMatrixSetterLong multiplyMatrix1x1x3(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final long f00 = matrix1.get(0, 0); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(2, 0, f00 * s20); + return output; + } + + private static IMatrixSetterLong multiplyMatrix1x1x4(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final long f00 = matrix1.get(0, 0); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + final long s30 = matrix2.get(3, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(2, 0, f00 * s20); + output.set(3, 0, f00 * s30); + return output; + } + + private static IMatrixSetterLong multiplyMatrix1x1x5(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final long f00 = matrix1.get(0, 0); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + final long s30 = matrix2.get(3, 0); + final long s40 = matrix2.get(4, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(2, 0, f00 * s20); + output.set(3, 0, f00 * s30); + output.set(4, 0, f00 * s40); + return output; + } + + private static IMatrixSetterLong multiplyMatrix2x1x1(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final long f00 = matrix1.get(0, 0); + final long f01 = matrix1.get(0, 1); + final long s00 = matrix2.get(0, 0); + output.set(0, 0, f00 * s00); + output.set(0, 1, f01 * s00); + return output; + } + + private static IMatrixSetterLong multiplyMatrix2x1x2(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final long f00 = matrix1.get(0, 0); + final long f01 = matrix1.get(0, 1); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(0, 1, f01 * s00); + output.set(1, 1, f01 * s10); + return output; + } + + private static IMatrixSetterLong multiplyMatrix2x1x3(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final long f00 = matrix1.get(0, 0); + final long f01 = matrix1.get(0, 1); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(2, 0, f00 * s20); + output.set(0, 1, f01 * s00); + output.set(1, 1, f01 * s10); + output.set(2, 1, f01 * s20); + return output; + } + + private static IMatrixSetterLong multiplyMatrix2x1x4(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final long f00 = matrix1.get(0, 0); + final long f01 = matrix1.get(0, 1); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + final long s30 = matrix2.get(3, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(2, 0, f00 * s20); + output.set(3, 0, f00 * s30); + output.set(0, 1, f01 * s00); + output.set(1, 1, f01 * s10); + output.set(2, 1, f01 * s20); + output.set(3, 1, f01 * s30); + return output; + } + + private static IMatrixSetterLong multiplyMatrix2x1x5(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final long f00 = matrix1.get(0, 0); + final long f01 = matrix1.get(0, 1); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + final long s30 = matrix2.get(3, 0); + final long s40 = matrix2.get(4, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(2, 0, f00 * s20); + output.set(3, 0, f00 * s30); + output.set(4, 0, f00 * s40); + output.set(0, 1, f01 * s00); + output.set(1, 1, f01 * s10); + output.set(2, 1, f01 * s20); + output.set(3, 1, f01 * s30); + output.set(4, 1, f01 * s40); + return output; + } + + private static IMatrixSetterLong multiplyMatrix3x1x1(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final long f00 = matrix1.get(0, 0); + final long f01 = matrix1.get(0, 1); + final long f02 = matrix1.get(0, 2); + final long s00 = matrix2.get(0, 0); + output.set(0, 0, f00 * s00); + output.set(0, 1, f01 * s00); + output.set(0, 2, f02 * s00); + return output; + } + + private static IMatrixSetterLong multiplyMatrix3x1x2(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final long f00 = matrix1.get(0, 0); + final long f01 = matrix1.get(0, 1); + final long f02 = matrix1.get(0, 2); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(0, 1, f01 * s00); + output.set(1, 1, f01 * s10); + output.set(0, 2, f02 * s00); + output.set(1, 2, f02 * s10); + return output; + } + + private static IMatrixSetterLong multiplyMatrix3x1x3(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final long f00 = matrix1.get(0, 0); + final long f01 = matrix1.get(0, 1); + final long f02 = matrix1.get(0, 2); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(2, 0, f00 * s20); + output.set(0, 1, f01 * s00); + output.set(1, 1, f01 * s10); + output.set(2, 1, f01 * s20); + output.set(0, 2, f02 * s00); + output.set(1, 2, f02 * s10); + output.set(2, 2, f02 * s20); + return output; + } + + private static IMatrixSetterLong multiplyMatrix3x1x4(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final long f00 = matrix1.get(0, 0); + final long f01 = matrix1.get(0, 1); + final long f02 = matrix1.get(0, 2); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + final long s30 = matrix2.get(3, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(2, 0, f00 * s20); + output.set(3, 0, f00 * s30); + output.set(0, 1, f01 * s00); + output.set(1, 1, f01 * s10); + output.set(2, 1, f01 * s20); + output.set(3, 1, f01 * s30); + output.set(0, 2, f02 * s00); + output.set(1, 2, f02 * s10); + output.set(2, 2, f02 * s20); + output.set(3, 2, f02 * s30); + return output; + } + + private static IMatrixSetterLong multiplyMatrix3x1x5(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final long f00 = matrix1.get(0, 0); + final long f01 = matrix1.get(0, 1); + final long f02 = matrix1.get(0, 2); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + final long s30 = matrix2.get(3, 0); + final long s40 = matrix2.get(4, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(2, 0, f00 * s20); + output.set(3, 0, f00 * s30); + output.set(4, 0, f00 * s40); + output.set(0, 1, f01 * s00); + output.set(1, 1, f01 * s10); + output.set(2, 1, f01 * s20); + output.set(3, 1, f01 * s30); + output.set(4, 1, f01 * s40); + output.set(0, 2, f02 * s00); + output.set(1, 2, f02 * s10); + output.set(2, 2, f02 * s20); + output.set(3, 2, f02 * s30); + output.set(4, 2, f02 * s40); + return output; + } + + private static IMatrixSetterLong multiplyMatrix4x1x1(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final long f00 = matrix1.get(0, 0); + final long f01 = matrix1.get(0, 1); + final long f02 = matrix1.get(0, 2); + final long f03 = matrix1.get(0, 3); + final long s00 = matrix2.get(0, 0); + output.set(0, 0, f00 * s00); + output.set(0, 1, f01 * s00); + output.set(0, 2, f02 * s00); + output.set(0, 3, f03 * s00); + return output; + } + + private static IMatrixSetterLong multiplyMatrix4x1x2(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final long f00 = matrix1.get(0, 0); + final long f01 = matrix1.get(0, 1); + final long f02 = matrix1.get(0, 2); + final long f03 = matrix1.get(0, 3); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(0, 1, f01 * s00); + output.set(1, 1, f01 * s10); + output.set(0, 2, f02 * s00); + output.set(1, 2, f02 * s10); + output.set(0, 3, f03 * s00); + output.set(1, 3, f03 * s10); + return output; + } + + private static IMatrixSetterLong multiplyMatrix4x1x3(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final long f00 = matrix1.get(0, 0); + final long f01 = matrix1.get(0, 1); + final long f02 = matrix1.get(0, 2); + final long f03 = matrix1.get(0, 3); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(2, 0, f00 * s20); + output.set(0, 1, f01 * s00); + output.set(1, 1, f01 * s10); + output.set(2, 1, f01 * s20); + output.set(0, 2, f02 * s00); + output.set(1, 2, f02 * s10); + output.set(2, 2, f02 * s20); + output.set(0, 3, f03 * s00); + output.set(1, 3, f03 * s10); + output.set(2, 3, f03 * s20); + return output; + } + + private static IMatrixSetterLong multiplyMatrix4x1x4(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final long f00 = matrix1.get(0, 0); + final long f01 = matrix1.get(0, 1); + final long f02 = matrix1.get(0, 2); + final long f03 = matrix1.get(0, 3); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + final long s30 = matrix2.get(3, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(2, 0, f00 * s20); + output.set(3, 0, f00 * s30); + output.set(0, 1, f01 * s00); + output.set(1, 1, f01 * s10); + output.set(2, 1, f01 * s20); + output.set(3, 1, f01 * s30); + output.set(0, 2, f02 * s00); + output.set(1, 2, f02 * s10); + output.set(2, 2, f02 * s20); + output.set(3, 2, f02 * s30); + output.set(0, 3, f03 * s00); + output.set(1, 3, f03 * s10); + output.set(2, 3, f03 * s20); + output.set(3, 3, f03 * s30); + return output; + } + + private static IMatrixSetterLong multiplyMatrix4x1x5(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final long f00 = matrix1.get(0, 0); + final long f01 = matrix1.get(0, 1); + final long f02 = matrix1.get(0, 2); + final long f03 = matrix1.get(0, 3); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + final long s30 = matrix2.get(3, 0); + final long s40 = matrix2.get(4, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(2, 0, f00 * s20); + output.set(3, 0, f00 * s30); + output.set(4, 0, f00 * s40); + output.set(0, 1, f01 * s00); + output.set(1, 1, f01 * s10); + output.set(2, 1, f01 * s20); + output.set(3, 1, f01 * s30); + output.set(4, 1, f01 * s40); + output.set(0, 2, f02 * s00); + output.set(1, 2, f02 * s10); + output.set(2, 2, f02 * s20); + output.set(3, 2, f02 * s30); + output.set(4, 2, f02 * s40); + output.set(0, 3, f03 * s00); + output.set(1, 3, f03 * s10); + output.set(2, 3, f03 * s20); + output.set(3, 3, f03 * s30); + output.set(4, 3, f03 * s40); + return output; + } + + private static IMatrixSetterLong multiplyMatrix5x1x1(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final long f00 = matrix1.get(0, 0); + final long f01 = matrix1.get(0, 1); + final long f02 = matrix1.get(0, 2); + final long f03 = matrix1.get(0, 3); + final long f04 = matrix1.get(0, 4); + final long s00 = matrix2.get(0, 0); + output.set(0, 0, f00 * s00); + output.set(0, 1, f01 * s00); + output.set(0, 2, f02 * s00); + output.set(0, 3, f03 * s00); + output.set(0, 4, f04 * s00); + return output; + } + + private static IMatrixSetterLong multiplyMatrix5x1x2(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final long f00 = matrix1.get(0, 0); + final long f01 = matrix1.get(0, 1); + final long f02 = matrix1.get(0, 2); + final long f03 = matrix1.get(0, 3); + final long f04 = matrix1.get(0, 4); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(0, 1, f01 * s00); + output.set(1, 1, f01 * s10); + output.set(0, 2, f02 * s00); + output.set(1, 2, f02 * s10); + output.set(0, 3, f03 * s00); + output.set(1, 3, f03 * s10); + output.set(0, 4, f04 * s00); + output.set(1, 4, f04 * s10); + return output; + } + + private static IMatrixSetterLong multiplyMatrix5x1x3(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final long f00 = matrix1.get(0, 0); + final long f01 = matrix1.get(0, 1); + final long f02 = matrix1.get(0, 2); + final long f03 = matrix1.get(0, 3); + final long f04 = matrix1.get(0, 4); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(2, 0, f00 * s20); + output.set(0, 1, f01 * s00); + output.set(1, 1, f01 * s10); + output.set(2, 1, f01 * s20); + output.set(0, 2, f02 * s00); + output.set(1, 2, f02 * s10); + output.set(2, 2, f02 * s20); + output.set(0, 3, f03 * s00); + output.set(1, 3, f03 * s10); + output.set(2, 3, f03 * s20); + output.set(0, 4, f04 * s00); + output.set(1, 4, f04 * s10); + output.set(2, 4, f04 * s20); + return output; + } + + private static IMatrixSetterLong multiplyMatrix5x1x4(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final long f00 = matrix1.get(0, 0); + final long f01 = matrix1.get(0, 1); + final long f02 = matrix1.get(0, 2); + final long f03 = matrix1.get(0, 3); + final long f04 = matrix1.get(0, 4); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + final long s30 = matrix2.get(3, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(2, 0, f00 * s20); + output.set(3, 0, f00 * s30); + output.set(0, 1, f01 * s00); + output.set(1, 1, f01 * s10); + output.set(2, 1, f01 * s20); + output.set(3, 1, f01 * s30); + output.set(0, 2, f02 * s00); + output.set(1, 2, f02 * s10); + output.set(2, 2, f02 * s20); + output.set(3, 2, f02 * s30); + output.set(0, 3, f03 * s00); + output.set(1, 3, f03 * s10); + output.set(2, 3, f03 * s20); + output.set(3, 3, f03 * s30); + output.set(0, 4, f04 * s00); + output.set(1, 4, f04 * s10); + output.set(2, 4, f04 * s20); + output.set(3, 4, f04 * s30); + return output; + } + + private static IMatrixSetterLong multiplyMatrix5x1x5(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final long f00 = matrix1.get(0, 0); + final long f01 = matrix1.get(0, 1); + final long f02 = matrix1.get(0, 2); + final long f03 = matrix1.get(0, 3); + final long f04 = matrix1.get(0, 4); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + final long s30 = matrix2.get(3, 0); + final long s40 = matrix2.get(4, 0); + output.set(0, 0, f00 * s00); + output.set(1, 0, f00 * s10); + output.set(2, 0, f00 * s20); + output.set(3, 0, f00 * s30); + output.set(4, 0, f00 * s40); + output.set(0, 1, f01 * s00); + output.set(1, 1, f01 * s10); + output.set(2, 1, f01 * s20); + output.set(3, 1, f01 * s30); + output.set(4, 1, f01 * s40); + output.set(0, 2, f02 * s00); + output.set(1, 2, f02 * s10); + output.set(2, 2, f02 * s20); + output.set(3, 2, f02 * s30); + output.set(4, 2, f02 * s40); + output.set(0, 3, f03 * s00); + output.set(1, 3, f03 * s10); + output.set(2, 3, f03 * s20); + output.set(3, 3, f03 * s30); + output.set(4, 3, f03 * s40); + output.set(0, 4, f04 * s00); + output.set(1, 4, f04 * s10); + output.set(2, 4, f04 * s20); + output.set(3, 4, f04 * s30); + output.set(4, 4, f04 * s40); + return output; + } + + private static IMatrixSetterLong multiplyMatrix1x2x1(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long s00 = matrix2.get(0, 0); + final long s01 = matrix2.get(0, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + return output; + } + + private static IMatrixSetterLong multiplyMatrix1x2x2(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + return output; + } + + private static IMatrixSetterLong multiplyMatrix1x2x3(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s21 = matrix2.get(2, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(2, 0, f00 * s20 + f10 * s21); + return output; + } + + private static IMatrixSetterLong multiplyMatrix1x2x4(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + final long s30 = matrix2.get(3, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s21 = matrix2.get(2, 1); + final long s31 = matrix2.get(3, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(2, 0, f00 * s20 + f10 * s21); + output.set(3, 0, f00 * s30 + f10 * s31); + return output; + } + + private static IMatrixSetterLong multiplyMatrix1x2x5(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + final long s30 = matrix2.get(3, 0); + final long s40 = matrix2.get(4, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s21 = matrix2.get(2, 1); + final long s31 = matrix2.get(3, 1); + final long s41 = matrix2.get(4, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(2, 0, f00 * s20 + f10 * s21); + output.set(3, 0, f00 * s30 + f10 * s31); + output.set(4, 0, f00 * s40 + f10 * s41); + return output; + } + + private static IMatrixSetterLong multiplyMatrix2x2x1(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long s00 = matrix2.get(0, 0); + final long s01 = matrix2.get(0, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(0, 1, f01 * s00 + f11 * s01); + return output; + } private static IMatrixSetterLong multiplyMatrix2x2x2(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final long f_c00 = matrix1.get(0, 0); - final long f_c10 = matrix1.get(1, 0); - final long f_c01 = matrix1.get(0, 1); - final long f_c11 = matrix1.get(1, 1); - final long s_c00 = matrix2.get(0, 0); - final long s_c10 = matrix2.get(1, 0); - final long s_c01 = matrix2.get(0, 1); - final long s_c11 = matrix2.get(1, 1); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(1, 1, f01 * s10 + f11 * s11); return output; } private static IMatrixSetterLong multiplyMatrix2x2x3(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final long f_c00 = matrix1.get(0, 0); - final long f_c10 = matrix1.get(1, 0); - final long f_c01 = matrix1.get(0, 1); - final long f_c11 = matrix1.get(1, 1); - final long s_c00 = matrix2.get(0, 0); - final long s_c10 = matrix2.get(1, 0); - final long s_c20 = matrix2.get(2, 0); - final long s_c01 = matrix2.get(0, 1); - final long s_c11 = matrix2.get(1, 1); - final long s_c21 = matrix2.get(2, 1); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s21 = matrix2.get(2, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(2, 0, f00 * s20 + f10 * s21); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(1, 1, f01 * s10 + f11 * s11); + output.set(2, 1, f01 * s20 + f11 * s21); return output; } private static IMatrixSetterLong multiplyMatrix2x2x4(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final long f_c00 = matrix1.get(0, 0); - final long f_c10 = matrix1.get(1, 0); - final long f_c01 = matrix1.get(0, 1); - final long f_c11 = matrix1.get(1, 1); - final long s_c00 = matrix2.get(0, 0); - final long s_c10 = matrix2.get(1, 0); - final long s_c20 = matrix2.get(2, 0); - final long s_c30 = matrix2.get(3, 0); - final long s_c01 = matrix2.get(0, 1); - final long s_c11 = matrix2.get(1, 1); - final long s_c21 = matrix2.get(2, 1); - final long s_c31 = matrix2.get(3, 1); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + final long s30 = matrix2.get(3, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s21 = matrix2.get(2, 1); + final long s31 = matrix2.get(3, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(2, 0, f00 * s20 + f10 * s21); + output.set(3, 0, f00 * s30 + f10 * s31); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(1, 1, f01 * s10 + f11 * s11); + output.set(2, 1, f01 * s20 + f11 * s21); + output.set(3, 1, f01 * s30 + f11 * s31); return output; } private static IMatrixSetterLong multiplyMatrix2x2x5(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final long f_c00 = matrix1.get(0, 0); - final long f_c10 = matrix1.get(1, 0); - final long f_c01 = matrix1.get(0, 1); - final long f_c11 = matrix1.get(1, 1); - final long s_c00 = matrix2.get(0, 0); - final long s_c10 = matrix2.get(1, 0); - final long s_c20 = matrix2.get(2, 0); - final long s_c30 = matrix2.get(3, 0); - final long s_c40 = matrix2.get(4, 0); - final long s_c01 = matrix2.get(0, 1); - final long s_c11 = matrix2.get(1, 1); - final long s_c21 = matrix2.get(2, 1); - final long s_c31 = matrix2.get(3, 1); - final long s_c41 = matrix2.get(4, 1); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31); - output.set(4, 0, f_c00*s_c40 + f_c10*s_c41); - output.set(4, 1, f_c01*s_c40 + f_c11*s_c41); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + final long s30 = matrix2.get(3, 0); + final long s40 = matrix2.get(4, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s21 = matrix2.get(2, 1); + final long s31 = matrix2.get(3, 1); + final long s41 = matrix2.get(4, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(2, 0, f00 * s20 + f10 * s21); + output.set(3, 0, f00 * s30 + f10 * s31); + output.set(4, 0, f00 * s40 + f10 * s41); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(1, 1, f01 * s10 + f11 * s11); + output.set(2, 1, f01 * s20 + f11 * s21); + output.set(3, 1, f01 * s30 + f11 * s31); + output.set(4, 1, f01 * s40 + f11 * s41); + return output; + } + + private static IMatrixSetterLong multiplyMatrix3x2x1(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f02 = matrix1.get(0, 2); + final long f12 = matrix1.get(1, 2); + final long s00 = matrix2.get(0, 0); + final long s01 = matrix2.get(0, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(0, 2, f02 * s00 + f12 * s01); return output; } private static IMatrixSetterLong multiplyMatrix3x2x2(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final long f_c00 = matrix1.get(0, 0); - final long f_c10 = matrix1.get(1, 0); - final long f_c01 = matrix1.get(0, 1); - final long f_c11 = matrix1.get(1, 1); - final long f_c02 = matrix1.get(0, 2); - final long f_c12 = matrix1.get(1, 2); - final long s_c00 = matrix2.get(0, 0); - final long s_c10 = matrix2.get(1, 0); - final long s_c01 = matrix2.get(0, 1); - final long s_c11 = matrix2.get(1, 1); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f02 = matrix1.get(0, 2); + final long f12 = matrix1.get(1, 2); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(1, 1, f01 * s10 + f11 * s11); + output.set(0, 2, f02 * s00 + f12 * s01); + output.set(1, 2, f02 * s10 + f12 * s11); return output; } private static IMatrixSetterLong multiplyMatrix3x2x3(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final long f_c00 = matrix1.get(0, 0); - final long f_c10 = matrix1.get(1, 0); - final long f_c01 = matrix1.get(0, 1); - final long f_c11 = matrix1.get(1, 1); - final long f_c02 = matrix1.get(0, 2); - final long f_c12 = matrix1.get(1, 2); - final long s_c00 = matrix2.get(0, 0); - final long s_c10 = matrix2.get(1, 0); - final long s_c20 = matrix2.get(2, 0); - final long s_c01 = matrix2.get(0, 1); - final long s_c11 = matrix2.get(1, 1); - final long s_c21 = matrix2.get(2, 1); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f02 = matrix1.get(0, 2); + final long f12 = matrix1.get(1, 2); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s21 = matrix2.get(2, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(2, 0, f00 * s20 + f10 * s21); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(1, 1, f01 * s10 + f11 * s11); + output.set(2, 1, f01 * s20 + f11 * s21); + output.set(0, 2, f02 * s00 + f12 * s01); + output.set(1, 2, f02 * s10 + f12 * s11); + output.set(2, 2, f02 * s20 + f12 * s21); return output; } private static IMatrixSetterLong multiplyMatrix3x2x4(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final long f_c00 = matrix1.get(0, 0); - final long f_c10 = matrix1.get(1, 0); - final long f_c01 = matrix1.get(0, 1); - final long f_c11 = matrix1.get(1, 1); - final long f_c02 = matrix1.get(0, 2); - final long f_c12 = matrix1.get(1, 2); - final long s_c00 = matrix2.get(0, 0); - final long s_c10 = matrix2.get(1, 0); - final long s_c20 = matrix2.get(2, 0); - final long s_c30 = matrix2.get(3, 0); - final long s_c01 = matrix2.get(0, 1); - final long s_c11 = matrix2.get(1, 1); - final long s_c21 = matrix2.get(2, 1); - final long s_c31 = matrix2.get(3, 1); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f02 = matrix1.get(0, 2); + final long f12 = matrix1.get(1, 2); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + final long s30 = matrix2.get(3, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s21 = matrix2.get(2, 1); + final long s31 = matrix2.get(3, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(2, 0, f00 * s20 + f10 * s21); + output.set(3, 0, f00 * s30 + f10 * s31); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(1, 1, f01 * s10 + f11 * s11); + output.set(2, 1, f01 * s20 + f11 * s21); + output.set(3, 1, f01 * s30 + f11 * s31); + output.set(0, 2, f02 * s00 + f12 * s01); + output.set(1, 2, f02 * s10 + f12 * s11); + output.set(2, 2, f02 * s20 + f12 * s21); + output.set(3, 2, f02 * s30 + f12 * s31); return output; } private static IMatrixSetterLong multiplyMatrix3x2x5(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final long f_c00 = matrix1.get(0, 0); - final long f_c10 = matrix1.get(1, 0); - final long f_c01 = matrix1.get(0, 1); - final long f_c11 = matrix1.get(1, 1); - final long f_c02 = matrix1.get(0, 2); - final long f_c12 = matrix1.get(1, 2); - final long s_c00 = matrix2.get(0, 0); - final long s_c10 = matrix2.get(1, 0); - final long s_c20 = matrix2.get(2, 0); - final long s_c30 = matrix2.get(3, 0); - final long s_c40 = matrix2.get(4, 0); - final long s_c01 = matrix2.get(0, 1); - final long s_c11 = matrix2.get(1, 1); - final long s_c21 = matrix2.get(2, 1); - final long s_c31 = matrix2.get(3, 1); - final long s_c41 = matrix2.get(4, 1); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31); - output.set(4, 0, f_c00*s_c40 + f_c10*s_c41); - output.set(4, 1, f_c01*s_c40 + f_c11*s_c41); - output.set(4, 2, f_c02*s_c40 + f_c12*s_c41); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f02 = matrix1.get(0, 2); + final long f12 = matrix1.get(1, 2); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + final long s30 = matrix2.get(3, 0); + final long s40 = matrix2.get(4, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s21 = matrix2.get(2, 1); + final long s31 = matrix2.get(3, 1); + final long s41 = matrix2.get(4, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(2, 0, f00 * s20 + f10 * s21); + output.set(3, 0, f00 * s30 + f10 * s31); + output.set(4, 0, f00 * s40 + f10 * s41); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(1, 1, f01 * s10 + f11 * s11); + output.set(2, 1, f01 * s20 + f11 * s21); + output.set(3, 1, f01 * s30 + f11 * s31); + output.set(4, 1, f01 * s40 + f11 * s41); + output.set(0, 2, f02 * s00 + f12 * s01); + output.set(1, 2, f02 * s10 + f12 * s11); + output.set(2, 2, f02 * s20 + f12 * s21); + output.set(3, 2, f02 * s30 + f12 * s31); + output.set(4, 2, f02 * s40 + f12 * s41); + return output; + } + + private static IMatrixSetterLong multiplyMatrix4x2x1(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f02 = matrix1.get(0, 2); + final long f12 = matrix1.get(1, 2); + final long f03 = matrix1.get(0, 3); + final long f13 = matrix1.get(1, 3); + final long s00 = matrix2.get(0, 0); + final long s01 = matrix2.get(0, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(0, 2, f02 * s00 + f12 * s01); + output.set(0, 3, f03 * s00 + f13 * s01); return output; } private static IMatrixSetterLong multiplyMatrix4x2x2(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final long f_c00 = matrix1.get(0, 0); - final long f_c10 = matrix1.get(1, 0); - final long f_c01 = matrix1.get(0, 1); - final long f_c11 = matrix1.get(1, 1); - final long f_c02 = matrix1.get(0, 2); - final long f_c12 = matrix1.get(1, 2); - final long f_c03 = matrix1.get(0, 3); - final long f_c13 = matrix1.get(1, 3); - final long s_c00 = matrix2.get(0, 0); - final long s_c10 = matrix2.get(1, 0); - final long s_c01 = matrix2.get(0, 1); - final long s_c11 = matrix2.get(1, 1); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f02 = matrix1.get(0, 2); + final long f12 = matrix1.get(1, 2); + final long f03 = matrix1.get(0, 3); + final long f13 = matrix1.get(1, 3); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(1, 1, f01 * s10 + f11 * s11); + output.set(0, 2, f02 * s00 + f12 * s01); + output.set(1, 2, f02 * s10 + f12 * s11); + output.set(0, 3, f03 * s00 + f13 * s01); + output.set(1, 3, f03 * s10 + f13 * s11); return output; } private static IMatrixSetterLong multiplyMatrix4x2x3(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final long f_c00 = matrix1.get(0, 0); - final long f_c10 = matrix1.get(1, 0); - final long f_c01 = matrix1.get(0, 1); - final long f_c11 = matrix1.get(1, 1); - final long f_c02 = matrix1.get(0, 2); - final long f_c12 = matrix1.get(1, 2); - final long f_c03 = matrix1.get(0, 3); - final long f_c13 = matrix1.get(1, 3); - final long s_c00 = matrix2.get(0, 0); - final long s_c10 = matrix2.get(1, 0); - final long s_c20 = matrix2.get(2, 0); - final long s_c01 = matrix2.get(0, 1); - final long s_c11 = matrix2.get(1, 1); - final long s_c21 = matrix2.get(2, 1); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f02 = matrix1.get(0, 2); + final long f12 = matrix1.get(1, 2); + final long f03 = matrix1.get(0, 3); + final long f13 = matrix1.get(1, 3); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s21 = matrix2.get(2, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(2, 0, f00 * s20 + f10 * s21); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(1, 1, f01 * s10 + f11 * s11); + output.set(2, 1, f01 * s20 + f11 * s21); + output.set(0, 2, f02 * s00 + f12 * s01); + output.set(1, 2, f02 * s10 + f12 * s11); + output.set(2, 2, f02 * s20 + f12 * s21); + output.set(0, 3, f03 * s00 + f13 * s01); + output.set(1, 3, f03 * s10 + f13 * s11); + output.set(2, 3, f03 * s20 + f13 * s21); return output; } private static IMatrixSetterLong multiplyMatrix4x2x4(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final long f_c00 = matrix1.get(0, 0); - final long f_c10 = matrix1.get(1, 0); - final long f_c01 = matrix1.get(0, 1); - final long f_c11 = matrix1.get(1, 1); - final long f_c02 = matrix1.get(0, 2); - final long f_c12 = matrix1.get(1, 2); - final long f_c03 = matrix1.get(0, 3); - final long f_c13 = matrix1.get(1, 3); - final long s_c00 = matrix2.get(0, 0); - final long s_c10 = matrix2.get(1, 0); - final long s_c20 = matrix2.get(2, 0); - final long s_c30 = matrix2.get(3, 0); - final long s_c01 = matrix2.get(0, 1); - final long s_c11 = matrix2.get(1, 1); - final long s_c21 = matrix2.get(2, 1); - final long s_c31 = matrix2.get(3, 1); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31); - output.set(3, 3, f_c03*s_c30 + f_c13*s_c31); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f02 = matrix1.get(0, 2); + final long f12 = matrix1.get(1, 2); + final long f03 = matrix1.get(0, 3); + final long f13 = matrix1.get(1, 3); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + final long s30 = matrix2.get(3, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s21 = matrix2.get(2, 1); + final long s31 = matrix2.get(3, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(2, 0, f00 * s20 + f10 * s21); + output.set(3, 0, f00 * s30 + f10 * s31); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(1, 1, f01 * s10 + f11 * s11); + output.set(2, 1, f01 * s20 + f11 * s21); + output.set(3, 1, f01 * s30 + f11 * s31); + output.set(0, 2, f02 * s00 + f12 * s01); + output.set(1, 2, f02 * s10 + f12 * s11); + output.set(2, 2, f02 * s20 + f12 * s21); + output.set(3, 2, f02 * s30 + f12 * s31); + output.set(0, 3, f03 * s00 + f13 * s01); + output.set(1, 3, f03 * s10 + f13 * s11); + output.set(2, 3, f03 * s20 + f13 * s21); + output.set(3, 3, f03 * s30 + f13 * s31); return output; } private static IMatrixSetterLong multiplyMatrix4x2x5(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final long f_c00 = matrix1.get(0, 0); - final long f_c10 = matrix1.get(1, 0); - final long f_c01 = matrix1.get(0, 1); - final long f_c11 = matrix1.get(1, 1); - final long f_c02 = matrix1.get(0, 2); - final long f_c12 = matrix1.get(1, 2); - final long f_c03 = matrix1.get(0, 3); - final long f_c13 = matrix1.get(1, 3); - final long s_c00 = matrix2.get(0, 0); - final long s_c10 = matrix2.get(1, 0); - final long s_c20 = matrix2.get(2, 0); - final long s_c30 = matrix2.get(3, 0); - final long s_c40 = matrix2.get(4, 0); - final long s_c01 = matrix2.get(0, 1); - final long s_c11 = matrix2.get(1, 1); - final long s_c21 = matrix2.get(2, 1); - final long s_c31 = matrix2.get(3, 1); - final long s_c41 = matrix2.get(4, 1); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31); - output.set(3, 3, f_c03*s_c30 + f_c13*s_c31); - output.set(4, 0, f_c00*s_c40 + f_c10*s_c41); - output.set(4, 1, f_c01*s_c40 + f_c11*s_c41); - output.set(4, 2, f_c02*s_c40 + f_c12*s_c41); - output.set(4, 3, f_c03*s_c40 + f_c13*s_c41); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f02 = matrix1.get(0, 2); + final long f12 = matrix1.get(1, 2); + final long f03 = matrix1.get(0, 3); + final long f13 = matrix1.get(1, 3); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + final long s30 = matrix2.get(3, 0); + final long s40 = matrix2.get(4, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s21 = matrix2.get(2, 1); + final long s31 = matrix2.get(3, 1); + final long s41 = matrix2.get(4, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(2, 0, f00 * s20 + f10 * s21); + output.set(3, 0, f00 * s30 + f10 * s31); + output.set(4, 0, f00 * s40 + f10 * s41); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(1, 1, f01 * s10 + f11 * s11); + output.set(2, 1, f01 * s20 + f11 * s21); + output.set(3, 1, f01 * s30 + f11 * s31); + output.set(4, 1, f01 * s40 + f11 * s41); + output.set(0, 2, f02 * s00 + f12 * s01); + output.set(1, 2, f02 * s10 + f12 * s11); + output.set(2, 2, f02 * s20 + f12 * s21); + output.set(3, 2, f02 * s30 + f12 * s31); + output.set(4, 2, f02 * s40 + f12 * s41); + output.set(0, 3, f03 * s00 + f13 * s01); + output.set(1, 3, f03 * s10 + f13 * s11); + output.set(2, 3, f03 * s20 + f13 * s21); + output.set(3, 3, f03 * s30 + f13 * s31); + output.set(4, 3, f03 * s40 + f13 * s41); + return output; + } + + private static IMatrixSetterLong multiplyMatrix5x2x1(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f02 = matrix1.get(0, 2); + final long f12 = matrix1.get(1, 2); + final long f03 = matrix1.get(0, 3); + final long f13 = matrix1.get(1, 3); + final long f04 = matrix1.get(0, 4); + final long f14 = matrix1.get(1, 4); + final long s00 = matrix2.get(0, 0); + final long s01 = matrix2.get(0, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(0, 2, f02 * s00 + f12 * s01); + output.set(0, 3, f03 * s00 + f13 * s01); + output.set(0, 4, f04 * s00 + f14 * s01); return output; } private static IMatrixSetterLong multiplyMatrix5x2x2(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final long f_c00 = matrix1.get(0, 0); - final long f_c10 = matrix1.get(1, 0); - final long f_c01 = matrix1.get(0, 1); - final long f_c11 = matrix1.get(1, 1); - final long f_c02 = matrix1.get(0, 2); - final long f_c12 = matrix1.get(1, 2); - final long f_c03 = matrix1.get(0, 3); - final long f_c13 = matrix1.get(1, 3); - final long f_c04 = matrix1.get(0, 4); - final long f_c14 = matrix1.get(1, 4); - final long s_c00 = matrix2.get(0, 0); - final long s_c10 = matrix2.get(1, 0); - final long s_c01 = matrix2.get(0, 1); - final long s_c11 = matrix2.get(1, 1); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01); - output.set(0, 4, f_c04*s_c00 + f_c14*s_c01); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11); - output.set(1, 4, f_c04*s_c10 + f_c14*s_c11); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f02 = matrix1.get(0, 2); + final long f12 = matrix1.get(1, 2); + final long f03 = matrix1.get(0, 3); + final long f13 = matrix1.get(1, 3); + final long f04 = matrix1.get(0, 4); + final long f14 = matrix1.get(1, 4); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(1, 1, f01 * s10 + f11 * s11); + output.set(0, 2, f02 * s00 + f12 * s01); + output.set(1, 2, f02 * s10 + f12 * s11); + output.set(0, 3, f03 * s00 + f13 * s01); + output.set(1, 3, f03 * s10 + f13 * s11); + output.set(0, 4, f04 * s00 + f14 * s01); + output.set(1, 4, f04 * s10 + f14 * s11); return output; } private static IMatrixSetterLong multiplyMatrix5x2x3(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final long f_c00 = matrix1.get(0, 0); - final long f_c10 = matrix1.get(1, 0); - final long f_c01 = matrix1.get(0, 1); - final long f_c11 = matrix1.get(1, 1); - final long f_c02 = matrix1.get(0, 2); - final long f_c12 = matrix1.get(1, 2); - final long f_c03 = matrix1.get(0, 3); - final long f_c13 = matrix1.get(1, 3); - final long f_c04 = matrix1.get(0, 4); - final long f_c14 = matrix1.get(1, 4); - final long s_c00 = matrix2.get(0, 0); - final long s_c10 = matrix2.get(1, 0); - final long s_c20 = matrix2.get(2, 0); - final long s_c01 = matrix2.get(0, 1); - final long s_c11 = matrix2.get(1, 1); - final long s_c21 = matrix2.get(2, 1); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01); - output.set(0, 4, f_c04*s_c00 + f_c14*s_c01); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11); - output.set(1, 4, f_c04*s_c10 + f_c14*s_c11); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21); - output.set(2, 4, f_c04*s_c20 + f_c14*s_c21); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f02 = matrix1.get(0, 2); + final long f12 = matrix1.get(1, 2); + final long f03 = matrix1.get(0, 3); + final long f13 = matrix1.get(1, 3); + final long f04 = matrix1.get(0, 4); + final long f14 = matrix1.get(1, 4); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s21 = matrix2.get(2, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(2, 0, f00 * s20 + f10 * s21); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(1, 1, f01 * s10 + f11 * s11); + output.set(2, 1, f01 * s20 + f11 * s21); + output.set(0, 2, f02 * s00 + f12 * s01); + output.set(1, 2, f02 * s10 + f12 * s11); + output.set(2, 2, f02 * s20 + f12 * s21); + output.set(0, 3, f03 * s00 + f13 * s01); + output.set(1, 3, f03 * s10 + f13 * s11); + output.set(2, 3, f03 * s20 + f13 * s21); + output.set(0, 4, f04 * s00 + f14 * s01); + output.set(1, 4, f04 * s10 + f14 * s11); + output.set(2, 4, f04 * s20 + f14 * s21); return output; } private static IMatrixSetterLong multiplyMatrix5x2x4(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final long f_c00 = matrix1.get(0, 0); - final long f_c10 = matrix1.get(1, 0); - final long f_c01 = matrix1.get(0, 1); - final long f_c11 = matrix1.get(1, 1); - final long f_c02 = matrix1.get(0, 2); - final long f_c12 = matrix1.get(1, 2); - final long f_c03 = matrix1.get(0, 3); - final long f_c13 = matrix1.get(1, 3); - final long f_c04 = matrix1.get(0, 4); - final long f_c14 = matrix1.get(1, 4); - final long s_c00 = matrix2.get(0, 0); - final long s_c10 = matrix2.get(1, 0); - final long s_c20 = matrix2.get(2, 0); - final long s_c30 = matrix2.get(3, 0); - final long s_c01 = matrix2.get(0, 1); - final long s_c11 = matrix2.get(1, 1); - final long s_c21 = matrix2.get(2, 1); - final long s_c31 = matrix2.get(3, 1); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01); - output.set(0, 4, f_c04*s_c00 + f_c14*s_c01); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11); - output.set(1, 4, f_c04*s_c10 + f_c14*s_c11); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21); - output.set(2, 4, f_c04*s_c20 + f_c14*s_c21); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31); - output.set(3, 3, f_c03*s_c30 + f_c13*s_c31); - output.set(3, 4, f_c04*s_c30 + f_c14*s_c31); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f02 = matrix1.get(0, 2); + final long f12 = matrix1.get(1, 2); + final long f03 = matrix1.get(0, 3); + final long f13 = matrix1.get(1, 3); + final long f04 = matrix1.get(0, 4); + final long f14 = matrix1.get(1, 4); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + final long s30 = matrix2.get(3, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s21 = matrix2.get(2, 1); + final long s31 = matrix2.get(3, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(2, 0, f00 * s20 + f10 * s21); + output.set(3, 0, f00 * s30 + f10 * s31); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(1, 1, f01 * s10 + f11 * s11); + output.set(2, 1, f01 * s20 + f11 * s21); + output.set(3, 1, f01 * s30 + f11 * s31); + output.set(0, 2, f02 * s00 + f12 * s01); + output.set(1, 2, f02 * s10 + f12 * s11); + output.set(2, 2, f02 * s20 + f12 * s21); + output.set(3, 2, f02 * s30 + f12 * s31); + output.set(0, 3, f03 * s00 + f13 * s01); + output.set(1, 3, f03 * s10 + f13 * s11); + output.set(2, 3, f03 * s20 + f13 * s21); + output.set(3, 3, f03 * s30 + f13 * s31); + output.set(0, 4, f04 * s00 + f14 * s01); + output.set(1, 4, f04 * s10 + f14 * s11); + output.set(2, 4, f04 * s20 + f14 * s21); + output.set(3, 4, f04 * s30 + f14 * s31); return output; } private static IMatrixSetterLong multiplyMatrix5x2x5(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final long f_c00 = matrix1.get(0, 0); - final long f_c10 = matrix1.get(1, 0); - final long f_c01 = matrix1.get(0, 1); - final long f_c11 = matrix1.get(1, 1); - final long f_c02 = matrix1.get(0, 2); - final long f_c12 = matrix1.get(1, 2); - final long f_c03 = matrix1.get(0, 3); - final long f_c13 = matrix1.get(1, 3); - final long f_c04 = matrix1.get(0, 4); - final long f_c14 = matrix1.get(1, 4); - final long s_c00 = matrix2.get(0, 0); - final long s_c10 = matrix2.get(1, 0); - final long s_c20 = matrix2.get(2, 0); - final long s_c30 = matrix2.get(3, 0); - final long s_c40 = matrix2.get(4, 0); - final long s_c01 = matrix2.get(0, 1); - final long s_c11 = matrix2.get(1, 1); - final long s_c21 = matrix2.get(2, 1); - final long s_c31 = matrix2.get(3, 1); - final long s_c41 = matrix2.get(4, 1); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01); - output.set(0, 4, f_c04*s_c00 + f_c14*s_c01); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11); - output.set(1, 4, f_c04*s_c10 + f_c14*s_c11); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21); - output.set(2, 4, f_c04*s_c20 + f_c14*s_c21); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31); - output.set(3, 3, f_c03*s_c30 + f_c13*s_c31); - output.set(3, 4, f_c04*s_c30 + f_c14*s_c31); - output.set(4, 0, f_c00*s_c40 + f_c10*s_c41); - output.set(4, 1, f_c01*s_c40 + f_c11*s_c41); - output.set(4, 2, f_c02*s_c40 + f_c12*s_c41); - output.set(4, 3, f_c03*s_c40 + f_c13*s_c41); - output.set(4, 4, f_c04*s_c40 + f_c14*s_c41); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f02 = matrix1.get(0, 2); + final long f12 = matrix1.get(1, 2); + final long f03 = matrix1.get(0, 3); + final long f13 = matrix1.get(1, 3); + final long f04 = matrix1.get(0, 4); + final long f14 = matrix1.get(1, 4); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + final long s30 = matrix2.get(3, 0); + final long s40 = matrix2.get(4, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s21 = matrix2.get(2, 1); + final long s31 = matrix2.get(3, 1); + final long s41 = matrix2.get(4, 1); + output.set(0, 0, f00 * s00 + f10 * s01); + output.set(1, 0, f00 * s10 + f10 * s11); + output.set(2, 0, f00 * s20 + f10 * s21); + output.set(3, 0, f00 * s30 + f10 * s31); + output.set(4, 0, f00 * s40 + f10 * s41); + output.set(0, 1, f01 * s00 + f11 * s01); + output.set(1, 1, f01 * s10 + f11 * s11); + output.set(2, 1, f01 * s20 + f11 * s21); + output.set(3, 1, f01 * s30 + f11 * s31); + output.set(4, 1, f01 * s40 + f11 * s41); + output.set(0, 2, f02 * s00 + f12 * s01); + output.set(1, 2, f02 * s10 + f12 * s11); + output.set(2, 2, f02 * s20 + f12 * s21); + output.set(3, 2, f02 * s30 + f12 * s31); + output.set(4, 2, f02 * s40 + f12 * s41); + output.set(0, 3, f03 * s00 + f13 * s01); + output.set(1, 3, f03 * s10 + f13 * s11); + output.set(2, 3, f03 * s20 + f13 * s21); + output.set(3, 3, f03 * s30 + f13 * s31); + output.set(4, 3, f03 * s40 + f13 * s41); + output.set(0, 4, f04 * s00 + f14 * s01); + output.set(1, 4, f04 * s10 + f14 * s11); + output.set(2, 4, f04 * s20 + f14 * s21); + output.set(3, 4, f04 * s30 + f14 * s31); + output.set(4, 4, f04 * s40 + f14 * s41); + return output; + } + + private static IMatrixSetterLong multiplyMatrix1x3x1(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long s00 = matrix2.get(0, 0); + final long s01 = matrix2.get(0, 1); + final long s02 = matrix2.get(0, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + return output; + } + + private static IMatrixSetterLong multiplyMatrix1x3x2(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s02 = matrix2.get(0, 2); + final long s12 = matrix2.get(1, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + return output; + } + + private static IMatrixSetterLong multiplyMatrix1x3x3(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s21 = matrix2.get(2, 1); + final long s02 = matrix2.get(0, 2); + final long s12 = matrix2.get(1, 2); + final long s22 = matrix2.get(2, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22); + return output; + } + + private static IMatrixSetterLong multiplyMatrix1x3x4(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + final long s30 = matrix2.get(3, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s21 = matrix2.get(2, 1); + final long s31 = matrix2.get(3, 1); + final long s02 = matrix2.get(0, 2); + final long s12 = matrix2.get(1, 2); + final long s22 = matrix2.get(2, 2); + final long s32 = matrix2.get(3, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32); + return output; + } + + private static IMatrixSetterLong multiplyMatrix1x3x5(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + final long s30 = matrix2.get(3, 0); + final long s40 = matrix2.get(4, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s21 = matrix2.get(2, 1); + final long s31 = matrix2.get(3, 1); + final long s41 = matrix2.get(4, 1); + final long s02 = matrix2.get(0, 2); + final long s12 = matrix2.get(1, 2); + final long s22 = matrix2.get(2, 2); + final long s32 = matrix2.get(3, 2); + final long s42 = matrix2.get(4, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32); + output.set(4, 0, f00 * s40 + f10 * s41 + f20 * s42); + return output; + } + + private static IMatrixSetterLong multiplyMatrix2x3x1(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f21 = matrix1.get(2, 1); + final long s00 = matrix2.get(0, 0); + final long s01 = matrix2.get(0, 1); + final long s02 = matrix2.get(0, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); return output; } private static IMatrixSetterLong multiplyMatrix2x3x2(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final long f_c00 = matrix1.get(0, 0); - final long f_c10 = matrix1.get(1, 0); - final long f_c20 = matrix1.get(2, 0); - final long f_c01 = matrix1.get(0, 1); - final long f_c11 = matrix1.get(1, 1); - final long f_c21 = matrix1.get(2, 1); - final long s_c00 = matrix2.get(0, 0); - final long s_c10 = matrix2.get(1, 0); - final long s_c01 = matrix2.get(0, 1); - final long s_c11 = matrix2.get(1, 1); - final long s_c02 = matrix2.get(0, 2); - final long s_c12 = matrix2.get(1, 2); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f21 = matrix1.get(2, 1); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s02 = matrix2.get(0, 2); + final long s12 = matrix2.get(1, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12); return output; } private static IMatrixSetterLong multiplyMatrix2x3x3(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final long f_c00 = matrix1.get(0, 0); - final long f_c10 = matrix1.get(1, 0); - final long f_c20 = matrix1.get(2, 0); - final long f_c01 = matrix1.get(0, 1); - final long f_c11 = matrix1.get(1, 1); - final long f_c21 = matrix1.get(2, 1); - final long s_c00 = matrix2.get(0, 0); - final long s_c10 = matrix2.get(1, 0); - final long s_c20 = matrix2.get(2, 0); - final long s_c01 = matrix2.get(0, 1); - final long s_c11 = matrix2.get(1, 1); - final long s_c21 = matrix2.get(2, 1); - final long s_c02 = matrix2.get(0, 2); - final long s_c12 = matrix2.get(1, 2); - final long s_c22 = matrix2.get(2, 2); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f21 = matrix1.get(2, 1); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s21 = matrix2.get(2, 1); + final long s02 = matrix2.get(0, 2); + final long s12 = matrix2.get(1, 2); + final long s22 = matrix2.get(2, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22); return output; } private static IMatrixSetterLong multiplyMatrix2x3x4(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final long f_c00 = matrix1.get(0, 0); - final long f_c10 = matrix1.get(1, 0); - final long f_c20 = matrix1.get(2, 0); - final long f_c01 = matrix1.get(0, 1); - final long f_c11 = matrix1.get(1, 1); - final long f_c21 = matrix1.get(2, 1); - final long s_c00 = matrix2.get(0, 0); - final long s_c10 = matrix2.get(1, 0); - final long s_c20 = matrix2.get(2, 0); - final long s_c30 = matrix2.get(3, 0); - final long s_c01 = matrix2.get(0, 1); - final long s_c11 = matrix2.get(1, 1); - final long s_c21 = matrix2.get(2, 1); - final long s_c31 = matrix2.get(3, 1); - final long s_c02 = matrix2.get(0, 2); - final long s_c12 = matrix2.get(1, 2); - final long s_c22 = matrix2.get(2, 2); - final long s_c32 = matrix2.get(3, 2); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f21 = matrix1.get(2, 1); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + final long s30 = matrix2.get(3, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s21 = matrix2.get(2, 1); + final long s31 = matrix2.get(3, 1); + final long s02 = matrix2.get(0, 2); + final long s12 = matrix2.get(1, 2); + final long s22 = matrix2.get(2, 2); + final long s32 = matrix2.get(3, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32); return output; } private static IMatrixSetterLong multiplyMatrix2x3x5(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final long f_c00 = matrix1.get(0, 0); - final long f_c10 = matrix1.get(1, 0); - final long f_c20 = matrix1.get(2, 0); - final long f_c01 = matrix1.get(0, 1); - final long f_c11 = matrix1.get(1, 1); - final long f_c21 = matrix1.get(2, 1); - final long s_c00 = matrix2.get(0, 0); - final long s_c10 = matrix2.get(1, 0); - final long s_c20 = matrix2.get(2, 0); - final long s_c30 = matrix2.get(3, 0); - final long s_c40 = matrix2.get(4, 0); - final long s_c01 = matrix2.get(0, 1); - final long s_c11 = matrix2.get(1, 1); - final long s_c21 = matrix2.get(2, 1); - final long s_c31 = matrix2.get(3, 1); - final long s_c41 = matrix2.get(4, 1); - final long s_c02 = matrix2.get(0, 2); - final long s_c12 = matrix2.get(1, 2); - final long s_c22 = matrix2.get(2, 2); - final long s_c32 = matrix2.get(3, 2); - final long s_c42 = matrix2.get(4, 2); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32); - output.set(4, 0, f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42); - output.set(4, 1, f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f21 = matrix1.get(2, 1); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + final long s30 = matrix2.get(3, 0); + final long s40 = matrix2.get(4, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s21 = matrix2.get(2, 1); + final long s31 = matrix2.get(3, 1); + final long s41 = matrix2.get(4, 1); + final long s02 = matrix2.get(0, 2); + final long s12 = matrix2.get(1, 2); + final long s22 = matrix2.get(2, 2); + final long s32 = matrix2.get(3, 2); + final long s42 = matrix2.get(4, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32); + output.set(4, 0, f00 * s40 + f10 * s41 + f20 * s42); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32); + output.set(4, 1, f01 * s40 + f11 * s41 + f21 * s42); + return output; + } + + private static IMatrixSetterLong multiplyMatrix3x3x1(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f21 = matrix1.get(2, 1); + final long f02 = matrix1.get(0, 2); + final long f12 = matrix1.get(1, 2); + final long f22 = matrix1.get(2, 2); + final long s00 = matrix2.get(0, 0); + final long s01 = matrix2.get(0, 1); + final long s02 = matrix2.get(0, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02); return output; } private static IMatrixSetterLong multiplyMatrix3x3x2(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final long f_c00 = matrix1.get(0, 0); - final long f_c10 = matrix1.get(1, 0); - final long f_c20 = matrix1.get(2, 0); - final long f_c01 = matrix1.get(0, 1); - final long f_c11 = matrix1.get(1, 1); - final long f_c21 = matrix1.get(2, 1); - final long f_c02 = matrix1.get(0, 2); - final long f_c12 = matrix1.get(1, 2); - final long f_c22 = matrix1.get(2, 2); - final long s_c00 = matrix2.get(0, 0); - final long s_c10 = matrix2.get(1, 0); - final long s_c01 = matrix2.get(0, 1); - final long s_c11 = matrix2.get(1, 1); - final long s_c02 = matrix2.get(0, 2); - final long s_c12 = matrix2.get(1, 2); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f21 = matrix1.get(2, 1); + final long f02 = matrix1.get(0, 2); + final long f12 = matrix1.get(1, 2); + final long f22 = matrix1.get(2, 2); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s02 = matrix2.get(0, 2); + final long s12 = matrix2.get(1, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12); return output; } private static IMatrixSetterLong multiplyMatrix3x3x3(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final long f_c00 = matrix1.get(0, 0); - final long f_c10 = matrix1.get(1, 0); - final long f_c20 = matrix1.get(2, 0); - final long f_c01 = matrix1.get(0, 1); - final long f_c11 = matrix1.get(1, 1); - final long f_c21 = matrix1.get(2, 1); - final long f_c02 = matrix1.get(0, 2); - final long f_c12 = matrix1.get(1, 2); - final long f_c22 = matrix1.get(2, 2); - final long s_c00 = matrix2.get(0, 0); - final long s_c10 = matrix2.get(1, 0); - final long s_c20 = matrix2.get(2, 0); - final long s_c01 = matrix2.get(0, 1); - final long s_c11 = matrix2.get(1, 1); - final long s_c21 = matrix2.get(2, 1); - final long s_c02 = matrix2.get(0, 2); - final long s_c12 = matrix2.get(1, 2); - final long s_c22 = matrix2.get(2, 2); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f21 = matrix1.get(2, 1); + final long f02 = matrix1.get(0, 2); + final long f12 = matrix1.get(1, 2); + final long f22 = matrix1.get(2, 2); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s21 = matrix2.get(2, 1); + final long s02 = matrix2.get(0, 2); + final long s12 = matrix2.get(1, 2); + final long s22 = matrix2.get(2, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22); return output; } private static IMatrixSetterLong multiplyMatrix3x3x4(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final long f_c00 = matrix1.get(0, 0); - final long f_c10 = matrix1.get(1, 0); - final long f_c20 = matrix1.get(2, 0); - final long f_c01 = matrix1.get(0, 1); - final long f_c11 = matrix1.get(1, 1); - final long f_c21 = matrix1.get(2, 1); - final long f_c02 = matrix1.get(0, 2); - final long f_c12 = matrix1.get(1, 2); - final long f_c22 = matrix1.get(2, 2); - final long s_c00 = matrix2.get(0, 0); - final long s_c10 = matrix2.get(1, 0); - final long s_c20 = matrix2.get(2, 0); - final long s_c30 = matrix2.get(3, 0); - final long s_c01 = matrix2.get(0, 1); - final long s_c11 = matrix2.get(1, 1); - final long s_c21 = matrix2.get(2, 1); - final long s_c31 = matrix2.get(3, 1); - final long s_c02 = matrix2.get(0, 2); - final long s_c12 = matrix2.get(1, 2); - final long s_c22 = matrix2.get(2, 2); - final long s_c32 = matrix2.get(3, 2); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f21 = matrix1.get(2, 1); + final long f02 = matrix1.get(0, 2); + final long f12 = matrix1.get(1, 2); + final long f22 = matrix1.get(2, 2); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + final long s30 = matrix2.get(3, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s21 = matrix2.get(2, 1); + final long s31 = matrix2.get(3, 1); + final long s02 = matrix2.get(0, 2); + final long s12 = matrix2.get(1, 2); + final long s22 = matrix2.get(2, 2); + final long s32 = matrix2.get(3, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32); return output; } private static IMatrixSetterLong multiplyMatrix3x3x5(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final long f_c00 = matrix1.get(0, 0); - final long f_c10 = matrix1.get(1, 0); - final long f_c20 = matrix1.get(2, 0); - final long f_c01 = matrix1.get(0, 1); - final long f_c11 = matrix1.get(1, 1); - final long f_c21 = matrix1.get(2, 1); - final long f_c02 = matrix1.get(0, 2); - final long f_c12 = matrix1.get(1, 2); - final long f_c22 = matrix1.get(2, 2); - final long s_c00 = matrix2.get(0, 0); - final long s_c10 = matrix2.get(1, 0); - final long s_c20 = matrix2.get(2, 0); - final long s_c30 = matrix2.get(3, 0); - final long s_c40 = matrix2.get(4, 0); - final long s_c01 = matrix2.get(0, 1); - final long s_c11 = matrix2.get(1, 1); - final long s_c21 = matrix2.get(2, 1); - final long s_c31 = matrix2.get(3, 1); - final long s_c41 = matrix2.get(4, 1); - final long s_c02 = matrix2.get(0, 2); - final long s_c12 = matrix2.get(1, 2); - final long s_c22 = matrix2.get(2, 2); - final long s_c32 = matrix2.get(3, 2); - final long s_c42 = matrix2.get(4, 2); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32); - output.set(4, 0, f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42); - output.set(4, 1, f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42); - output.set(4, 2, f_c02*s_c40 + f_c12*s_c41 + f_c22*s_c42); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f21 = matrix1.get(2, 1); + final long f02 = matrix1.get(0, 2); + final long f12 = matrix1.get(1, 2); + final long f22 = matrix1.get(2, 2); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + final long s30 = matrix2.get(3, 0); + final long s40 = matrix2.get(4, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s21 = matrix2.get(2, 1); + final long s31 = matrix2.get(3, 1); + final long s41 = matrix2.get(4, 1); + final long s02 = matrix2.get(0, 2); + final long s12 = matrix2.get(1, 2); + final long s22 = matrix2.get(2, 2); + final long s32 = matrix2.get(3, 2); + final long s42 = matrix2.get(4, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32); + output.set(4, 0, f00 * s40 + f10 * s41 + f20 * s42); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32); + output.set(4, 1, f01 * s40 + f11 * s41 + f21 * s42); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32); + output.set(4, 2, f02 * s40 + f12 * s41 + f22 * s42); + return output; + } + + private static IMatrixSetterLong multiplyMatrix4x3x1(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f21 = matrix1.get(2, 1); + final long f02 = matrix1.get(0, 2); + final long f12 = matrix1.get(1, 2); + final long f22 = matrix1.get(2, 2); + final long f03 = matrix1.get(0, 3); + final long f13 = matrix1.get(1, 3); + final long f23 = matrix1.get(2, 3); + final long s00 = matrix2.get(0, 0); + final long s01 = matrix2.get(0, 1); + final long s02 = matrix2.get(0, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02); return output; } private static IMatrixSetterLong multiplyMatrix4x3x2(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final long f_c00 = matrix1.get(0, 0); - final long f_c10 = matrix1.get(1, 0); - final long f_c20 = matrix1.get(2, 0); - final long f_c01 = matrix1.get(0, 1); - final long f_c11 = matrix1.get(1, 1); - final long f_c21 = matrix1.get(2, 1); - final long f_c02 = matrix1.get(0, 2); - final long f_c12 = matrix1.get(1, 2); - final long f_c22 = matrix1.get(2, 2); - final long f_c03 = matrix1.get(0, 3); - final long f_c13 = matrix1.get(1, 3); - final long f_c23 = matrix1.get(2, 3); - final long s_c00 = matrix2.get(0, 0); - final long s_c10 = matrix2.get(1, 0); - final long s_c01 = matrix2.get(0, 1); - final long s_c11 = matrix2.get(1, 1); - final long s_c02 = matrix2.get(0, 2); - final long s_c12 = matrix2.get(1, 2); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f21 = matrix1.get(2, 1); + final long f02 = matrix1.get(0, 2); + final long f12 = matrix1.get(1, 2); + final long f22 = matrix1.get(2, 2); + final long f03 = matrix1.get(0, 3); + final long f13 = matrix1.get(1, 3); + final long f23 = matrix1.get(2, 3); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s02 = matrix2.get(0, 2); + final long s12 = matrix2.get(1, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12); return output; } private static IMatrixSetterLong multiplyMatrix4x3x3(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final long f_c00 = matrix1.get(0, 0); - final long f_c10 = matrix1.get(1, 0); - final long f_c20 = matrix1.get(2, 0); - final long f_c01 = matrix1.get(0, 1); - final long f_c11 = matrix1.get(1, 1); - final long f_c21 = matrix1.get(2, 1); - final long f_c02 = matrix1.get(0, 2); - final long f_c12 = matrix1.get(1, 2); - final long f_c22 = matrix1.get(2, 2); - final long f_c03 = matrix1.get(0, 3); - final long f_c13 = matrix1.get(1, 3); - final long f_c23 = matrix1.get(2, 3); - final long s_c00 = matrix2.get(0, 0); - final long s_c10 = matrix2.get(1, 0); - final long s_c20 = matrix2.get(2, 0); - final long s_c01 = matrix2.get(0, 1); - final long s_c11 = matrix2.get(1, 1); - final long s_c21 = matrix2.get(2, 1); - final long s_c02 = matrix2.get(0, 2); - final long s_c12 = matrix2.get(1, 2); - final long s_c22 = matrix2.get(2, 2); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f21 = matrix1.get(2, 1); + final long f02 = matrix1.get(0, 2); + final long f12 = matrix1.get(1, 2); + final long f22 = matrix1.get(2, 2); + final long f03 = matrix1.get(0, 3); + final long f13 = matrix1.get(1, 3); + final long f23 = matrix1.get(2, 3); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s21 = matrix2.get(2, 1); + final long s02 = matrix2.get(0, 2); + final long s12 = matrix2.get(1, 2); + final long s22 = matrix2.get(2, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22); return output; } private static IMatrixSetterLong multiplyMatrix4x3x4(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final long f_c00 = matrix1.get(0, 0); - final long f_c10 = matrix1.get(1, 0); - final long f_c20 = matrix1.get(2, 0); - final long f_c01 = matrix1.get(0, 1); - final long f_c11 = matrix1.get(1, 1); - final long f_c21 = matrix1.get(2, 1); - final long f_c02 = matrix1.get(0, 2); - final long f_c12 = matrix1.get(1, 2); - final long f_c22 = matrix1.get(2, 2); - final long f_c03 = matrix1.get(0, 3); - final long f_c13 = matrix1.get(1, 3); - final long f_c23 = matrix1.get(2, 3); - final long s_c00 = matrix2.get(0, 0); - final long s_c10 = matrix2.get(1, 0); - final long s_c20 = matrix2.get(2, 0); - final long s_c30 = matrix2.get(3, 0); - final long s_c01 = matrix2.get(0, 1); - final long s_c11 = matrix2.get(1, 1); - final long s_c21 = matrix2.get(2, 1); - final long s_c31 = matrix2.get(3, 1); - final long s_c02 = matrix2.get(0, 2); - final long s_c12 = matrix2.get(1, 2); - final long s_c22 = matrix2.get(2, 2); - final long s_c32 = matrix2.get(3, 2); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32); - output.set(3, 3, f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f21 = matrix1.get(2, 1); + final long f02 = matrix1.get(0, 2); + final long f12 = matrix1.get(1, 2); + final long f22 = matrix1.get(2, 2); + final long f03 = matrix1.get(0, 3); + final long f13 = matrix1.get(1, 3); + final long f23 = matrix1.get(2, 3); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + final long s30 = matrix2.get(3, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s21 = matrix2.get(2, 1); + final long s31 = matrix2.get(3, 1); + final long s02 = matrix2.get(0, 2); + final long s12 = matrix2.get(1, 2); + final long s22 = matrix2.get(2, 2); + final long s32 = matrix2.get(3, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22); + output.set(3, 3, f03 * s30 + f13 * s31 + f23 * s32); return output; } private static IMatrixSetterLong multiplyMatrix4x3x5(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final long f_c00 = matrix1.get(0, 0); - final long f_c10 = matrix1.get(1, 0); - final long f_c20 = matrix1.get(2, 0); - final long f_c01 = matrix1.get(0, 1); - final long f_c11 = matrix1.get(1, 1); - final long f_c21 = matrix1.get(2, 1); - final long f_c02 = matrix1.get(0, 2); - final long f_c12 = matrix1.get(1, 2); - final long f_c22 = matrix1.get(2, 2); - final long f_c03 = matrix1.get(0, 3); - final long f_c13 = matrix1.get(1, 3); - final long f_c23 = matrix1.get(2, 3); - final long s_c00 = matrix2.get(0, 0); - final long s_c10 = matrix2.get(1, 0); - final long s_c20 = matrix2.get(2, 0); - final long s_c30 = matrix2.get(3, 0); - final long s_c40 = matrix2.get(4, 0); - final long s_c01 = matrix2.get(0, 1); - final long s_c11 = matrix2.get(1, 1); - final long s_c21 = matrix2.get(2, 1); - final long s_c31 = matrix2.get(3, 1); - final long s_c41 = matrix2.get(4, 1); - final long s_c02 = matrix2.get(0, 2); - final long s_c12 = matrix2.get(1, 2); - final long s_c22 = matrix2.get(2, 2); - final long s_c32 = matrix2.get(3, 2); - final long s_c42 = matrix2.get(4, 2); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32); - output.set(3, 3, f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32); - output.set(4, 0, f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42); - output.set(4, 1, f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42); - output.set(4, 2, f_c02*s_c40 + f_c12*s_c41 + f_c22*s_c42); - output.set(4, 3, f_c03*s_c40 + f_c13*s_c41 + f_c23*s_c42); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f21 = matrix1.get(2, 1); + final long f02 = matrix1.get(0, 2); + final long f12 = matrix1.get(1, 2); + final long f22 = matrix1.get(2, 2); + final long f03 = matrix1.get(0, 3); + final long f13 = matrix1.get(1, 3); + final long f23 = matrix1.get(2, 3); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + final long s30 = matrix2.get(3, 0); + final long s40 = matrix2.get(4, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s21 = matrix2.get(2, 1); + final long s31 = matrix2.get(3, 1); + final long s41 = matrix2.get(4, 1); + final long s02 = matrix2.get(0, 2); + final long s12 = matrix2.get(1, 2); + final long s22 = matrix2.get(2, 2); + final long s32 = matrix2.get(3, 2); + final long s42 = matrix2.get(4, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32); + output.set(4, 0, f00 * s40 + f10 * s41 + f20 * s42); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32); + output.set(4, 1, f01 * s40 + f11 * s41 + f21 * s42); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32); + output.set(4, 2, f02 * s40 + f12 * s41 + f22 * s42); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22); + output.set(3, 3, f03 * s30 + f13 * s31 + f23 * s32); + output.set(4, 3, f03 * s40 + f13 * s41 + f23 * s42); + return output; + } + + private static IMatrixSetterLong multiplyMatrix5x3x1(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f21 = matrix1.get(2, 1); + final long f02 = matrix1.get(0, 2); + final long f12 = matrix1.get(1, 2); + final long f22 = matrix1.get(2, 2); + final long f03 = matrix1.get(0, 3); + final long f13 = matrix1.get(1, 3); + final long f23 = matrix1.get(2, 3); + final long f04 = matrix1.get(0, 4); + final long f14 = matrix1.get(1, 4); + final long f24 = matrix1.get(2, 4); + final long s00 = matrix2.get(0, 0); + final long s01 = matrix2.get(0, 1); + final long s02 = matrix2.get(0, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02); + output.set(0, 4, f04 * s00 + f14 * s01 + f24 * s02); return output; } private static IMatrixSetterLong multiplyMatrix5x3x2(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final long f_c00 = matrix1.get(0, 0); - final long f_c10 = matrix1.get(1, 0); - final long f_c20 = matrix1.get(2, 0); - final long f_c01 = matrix1.get(0, 1); - final long f_c11 = matrix1.get(1, 1); - final long f_c21 = matrix1.get(2, 1); - final long f_c02 = matrix1.get(0, 2); - final long f_c12 = matrix1.get(1, 2); - final long f_c22 = matrix1.get(2, 2); - final long f_c03 = matrix1.get(0, 3); - final long f_c13 = matrix1.get(1, 3); - final long f_c23 = matrix1.get(2, 3); - final long f_c04 = matrix1.get(0, 4); - final long f_c14 = matrix1.get(1, 4); - final long f_c24 = matrix1.get(2, 4); - final long s_c00 = matrix2.get(0, 0); - final long s_c10 = matrix2.get(1, 0); - final long s_c01 = matrix2.get(0, 1); - final long s_c11 = matrix2.get(1, 1); - final long s_c02 = matrix2.get(0, 2); - final long s_c12 = matrix2.get(1, 2); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02); - output.set(0, 4, f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12); - output.set(1, 4, f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f21 = matrix1.get(2, 1); + final long f02 = matrix1.get(0, 2); + final long f12 = matrix1.get(1, 2); + final long f22 = matrix1.get(2, 2); + final long f03 = matrix1.get(0, 3); + final long f13 = matrix1.get(1, 3); + final long f23 = matrix1.get(2, 3); + final long f04 = matrix1.get(0, 4); + final long f14 = matrix1.get(1, 4); + final long f24 = matrix1.get(2, 4); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s02 = matrix2.get(0, 2); + final long s12 = matrix2.get(1, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12); + output.set(0, 4, f04 * s00 + f14 * s01 + f24 * s02); + output.set(1, 4, f04 * s10 + f14 * s11 + f24 * s12); return output; } private static IMatrixSetterLong multiplyMatrix5x3x3(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final long f_c00 = matrix1.get(0, 0); - final long f_c10 = matrix1.get(1, 0); - final long f_c20 = matrix1.get(2, 0); - final long f_c01 = matrix1.get(0, 1); - final long f_c11 = matrix1.get(1, 1); - final long f_c21 = matrix1.get(2, 1); - final long f_c02 = matrix1.get(0, 2); - final long f_c12 = matrix1.get(1, 2); - final long f_c22 = matrix1.get(2, 2); - final long f_c03 = matrix1.get(0, 3); - final long f_c13 = matrix1.get(1, 3); - final long f_c23 = matrix1.get(2, 3); - final long f_c04 = matrix1.get(0, 4); - final long f_c14 = matrix1.get(1, 4); - final long f_c24 = matrix1.get(2, 4); - final long s_c00 = matrix2.get(0, 0); - final long s_c10 = matrix2.get(1, 0); - final long s_c20 = matrix2.get(2, 0); - final long s_c01 = matrix2.get(0, 1); - final long s_c11 = matrix2.get(1, 1); - final long s_c21 = matrix2.get(2, 1); - final long s_c02 = matrix2.get(0, 2); - final long s_c12 = matrix2.get(1, 2); - final long s_c22 = matrix2.get(2, 2); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02); - output.set(0, 4, f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12); - output.set(1, 4, f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22); - output.set(2, 4, f_c04*s_c20 + f_c14*s_c21 + f_c24*s_c22); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f21 = matrix1.get(2, 1); + final long f02 = matrix1.get(0, 2); + final long f12 = matrix1.get(1, 2); + final long f22 = matrix1.get(2, 2); + final long f03 = matrix1.get(0, 3); + final long f13 = matrix1.get(1, 3); + final long f23 = matrix1.get(2, 3); + final long f04 = matrix1.get(0, 4); + final long f14 = matrix1.get(1, 4); + final long f24 = matrix1.get(2, 4); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s21 = matrix2.get(2, 1); + final long s02 = matrix2.get(0, 2); + final long s12 = matrix2.get(1, 2); + final long s22 = matrix2.get(2, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22); + output.set(0, 4, f04 * s00 + f14 * s01 + f24 * s02); + output.set(1, 4, f04 * s10 + f14 * s11 + f24 * s12); + output.set(2, 4, f04 * s20 + f14 * s21 + f24 * s22); return output; } private static IMatrixSetterLong multiplyMatrix5x3x4(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final long f_c00 = matrix1.get(0, 0); - final long f_c10 = matrix1.get(1, 0); - final long f_c20 = matrix1.get(2, 0); - final long f_c01 = matrix1.get(0, 1); - final long f_c11 = matrix1.get(1, 1); - final long f_c21 = matrix1.get(2, 1); - final long f_c02 = matrix1.get(0, 2); - final long f_c12 = matrix1.get(1, 2); - final long f_c22 = matrix1.get(2, 2); - final long f_c03 = matrix1.get(0, 3); - final long f_c13 = matrix1.get(1, 3); - final long f_c23 = matrix1.get(2, 3); - final long f_c04 = matrix1.get(0, 4); - final long f_c14 = matrix1.get(1, 4); - final long f_c24 = matrix1.get(2, 4); - final long s_c00 = matrix2.get(0, 0); - final long s_c10 = matrix2.get(1, 0); - final long s_c20 = matrix2.get(2, 0); - final long s_c30 = matrix2.get(3, 0); - final long s_c01 = matrix2.get(0, 1); - final long s_c11 = matrix2.get(1, 1); - final long s_c21 = matrix2.get(2, 1); - final long s_c31 = matrix2.get(3, 1); - final long s_c02 = matrix2.get(0, 2); - final long s_c12 = matrix2.get(1, 2); - final long s_c22 = matrix2.get(2, 2); - final long s_c32 = matrix2.get(3, 2); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02); - output.set(0, 4, f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12); - output.set(1, 4, f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22); - output.set(2, 4, f_c04*s_c20 + f_c14*s_c21 + f_c24*s_c22); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32); - output.set(3, 3, f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32); - output.set(3, 4, f_c04*s_c30 + f_c14*s_c31 + f_c24*s_c32); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f21 = matrix1.get(2, 1); + final long f02 = matrix1.get(0, 2); + final long f12 = matrix1.get(1, 2); + final long f22 = matrix1.get(2, 2); + final long f03 = matrix1.get(0, 3); + final long f13 = matrix1.get(1, 3); + final long f23 = matrix1.get(2, 3); + final long f04 = matrix1.get(0, 4); + final long f14 = matrix1.get(1, 4); + final long f24 = matrix1.get(2, 4); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + final long s30 = matrix2.get(3, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s21 = matrix2.get(2, 1); + final long s31 = matrix2.get(3, 1); + final long s02 = matrix2.get(0, 2); + final long s12 = matrix2.get(1, 2); + final long s22 = matrix2.get(2, 2); + final long s32 = matrix2.get(3, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22); + output.set(3, 3, f03 * s30 + f13 * s31 + f23 * s32); + output.set(0, 4, f04 * s00 + f14 * s01 + f24 * s02); + output.set(1, 4, f04 * s10 + f14 * s11 + f24 * s12); + output.set(2, 4, f04 * s20 + f14 * s21 + f24 * s22); + output.set(3, 4, f04 * s30 + f14 * s31 + f24 * s32); return output; } private static IMatrixSetterLong multiplyMatrix5x3x5(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final long f_c00 = matrix1.get(0, 0); - final long f_c10 = matrix1.get(1, 0); - final long f_c20 = matrix1.get(2, 0); - final long f_c01 = matrix1.get(0, 1); - final long f_c11 = matrix1.get(1, 1); - final long f_c21 = matrix1.get(2, 1); - final long f_c02 = matrix1.get(0, 2); - final long f_c12 = matrix1.get(1, 2); - final long f_c22 = matrix1.get(2, 2); - final long f_c03 = matrix1.get(0, 3); - final long f_c13 = matrix1.get(1, 3); - final long f_c23 = matrix1.get(2, 3); - final long f_c04 = matrix1.get(0, 4); - final long f_c14 = matrix1.get(1, 4); - final long f_c24 = matrix1.get(2, 4); - final long s_c00 = matrix2.get(0, 0); - final long s_c10 = matrix2.get(1, 0); - final long s_c20 = matrix2.get(2, 0); - final long s_c30 = matrix2.get(3, 0); - final long s_c40 = matrix2.get(4, 0); - final long s_c01 = matrix2.get(0, 1); - final long s_c11 = matrix2.get(1, 1); - final long s_c21 = matrix2.get(2, 1); - final long s_c31 = matrix2.get(3, 1); - final long s_c41 = matrix2.get(4, 1); - final long s_c02 = matrix2.get(0, 2); - final long s_c12 = matrix2.get(1, 2); - final long s_c22 = matrix2.get(2, 2); - final long s_c32 = matrix2.get(3, 2); - final long s_c42 = matrix2.get(4, 2); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02); - output.set(0, 4, f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12); - output.set(1, 4, f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22); - output.set(2, 4, f_c04*s_c20 + f_c14*s_c21 + f_c24*s_c22); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32); - output.set(3, 3, f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32); - output.set(3, 4, f_c04*s_c30 + f_c14*s_c31 + f_c24*s_c32); - output.set(4, 0, f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42); - output.set(4, 1, f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42); - output.set(4, 2, f_c02*s_c40 + f_c12*s_c41 + f_c22*s_c42); - output.set(4, 3, f_c03*s_c40 + f_c13*s_c41 + f_c23*s_c42); - output.set(4, 4, f_c04*s_c40 + f_c14*s_c41 + f_c24*s_c42); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f21 = matrix1.get(2, 1); + final long f02 = matrix1.get(0, 2); + final long f12 = matrix1.get(1, 2); + final long f22 = matrix1.get(2, 2); + final long f03 = matrix1.get(0, 3); + final long f13 = matrix1.get(1, 3); + final long f23 = matrix1.get(2, 3); + final long f04 = matrix1.get(0, 4); + final long f14 = matrix1.get(1, 4); + final long f24 = matrix1.get(2, 4); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + final long s30 = matrix2.get(3, 0); + final long s40 = matrix2.get(4, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s21 = matrix2.get(2, 1); + final long s31 = matrix2.get(3, 1); + final long s41 = matrix2.get(4, 1); + final long s02 = matrix2.get(0, 2); + final long s12 = matrix2.get(1, 2); + final long s22 = matrix2.get(2, 2); + final long s32 = matrix2.get(3, 2); + final long s42 = matrix2.get(4, 2); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32); + output.set(4, 0, f00 * s40 + f10 * s41 + f20 * s42); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32); + output.set(4, 1, f01 * s40 + f11 * s41 + f21 * s42); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32); + output.set(4, 2, f02 * s40 + f12 * s41 + f22 * s42); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22); + output.set(3, 3, f03 * s30 + f13 * s31 + f23 * s32); + output.set(4, 3, f03 * s40 + f13 * s41 + f23 * s42); + output.set(0, 4, f04 * s00 + f14 * s01 + f24 * s02); + output.set(1, 4, f04 * s10 + f14 * s11 + f24 * s12); + output.set(2, 4, f04 * s20 + f14 * s21 + f24 * s22); + output.set(3, 4, f04 * s30 + f14 * s31 + f24 * s32); + output.set(4, 4, f04 * s40 + f14 * s41 + f24 * s42); + return output; + } + + private static IMatrixSetterLong multiplyMatrix1x4x1(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long f30 = matrix1.get(3, 0); + final long s00 = matrix2.get(0, 0); + final long s01 = matrix2.get(0, 1); + final long s02 = matrix2.get(0, 2); + final long s03 = matrix2.get(0, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + return output; + } + + private static IMatrixSetterLong multiplyMatrix1x4x2(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long f30 = matrix1.get(3, 0); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s02 = matrix2.get(0, 2); + final long s12 = matrix2.get(1, 2); + final long s03 = matrix2.get(0, 3); + final long s13 = matrix2.get(1, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + return output; + } + + private static IMatrixSetterLong multiplyMatrix1x4x3(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long f30 = matrix1.get(3, 0); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s21 = matrix2.get(2, 1); + final long s02 = matrix2.get(0, 2); + final long s12 = matrix2.get(1, 2); + final long s22 = matrix2.get(2, 2); + final long s03 = matrix2.get(0, 3); + final long s13 = matrix2.get(1, 3); + final long s23 = matrix2.get(2, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23); + return output; + } + + private static IMatrixSetterLong multiplyMatrix1x4x4(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long f30 = matrix1.get(3, 0); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + final long s30 = matrix2.get(3, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s21 = matrix2.get(2, 1); + final long s31 = matrix2.get(3, 1); + final long s02 = matrix2.get(0, 2); + final long s12 = matrix2.get(1, 2); + final long s22 = matrix2.get(2, 2); + final long s32 = matrix2.get(3, 2); + final long s03 = matrix2.get(0, 3); + final long s13 = matrix2.get(1, 3); + final long s23 = matrix2.get(2, 3); + final long s33 = matrix2.get(3, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33); + return output; + } + + private static IMatrixSetterLong multiplyMatrix1x4x5(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long f30 = matrix1.get(3, 0); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + final long s30 = matrix2.get(3, 0); + final long s40 = matrix2.get(4, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s21 = matrix2.get(2, 1); + final long s31 = matrix2.get(3, 1); + final long s41 = matrix2.get(4, 1); + final long s02 = matrix2.get(0, 2); + final long s12 = matrix2.get(1, 2); + final long s22 = matrix2.get(2, 2); + final long s32 = matrix2.get(3, 2); + final long s42 = matrix2.get(4, 2); + final long s03 = matrix2.get(0, 3); + final long s13 = matrix2.get(1, 3); + final long s23 = matrix2.get(2, 3); + final long s33 = matrix2.get(3, 3); + final long s43 = matrix2.get(4, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33); + output.set(4, 0, f00 * s40 + f10 * s41 + f20 * s42 + f30 * s43); + return output; + } + + private static IMatrixSetterLong multiplyMatrix2x4x1(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long f30 = matrix1.get(3, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f21 = matrix1.get(2, 1); + final long f31 = matrix1.get(3, 1); + final long s00 = matrix2.get(0, 0); + final long s01 = matrix2.get(0, 1); + final long s02 = matrix2.get(0, 2); + final long s03 = matrix2.get(0, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); return output; } private static IMatrixSetterLong multiplyMatrix2x4x2(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final long f_c00 = matrix1.get(0, 0); - final long f_c10 = matrix1.get(1, 0); - final long f_c20 = matrix1.get(2, 0); - final long f_c30 = matrix1.get(3, 0); - final long f_c01 = matrix1.get(0, 1); - final long f_c11 = matrix1.get(1, 1); - final long f_c21 = matrix1.get(2, 1); - final long f_c31 = matrix1.get(3, 1); - final long s_c00 = matrix2.get(0, 0); - final long s_c10 = matrix2.get(1, 0); - final long s_c01 = matrix2.get(0, 1); - final long s_c11 = matrix2.get(1, 1); - final long s_c02 = matrix2.get(0, 2); - final long s_c12 = matrix2.get(1, 2); - final long s_c03 = matrix2.get(0, 3); - final long s_c13 = matrix2.get(1, 3); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long f30 = matrix1.get(3, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f21 = matrix1.get(2, 1); + final long f31 = matrix1.get(3, 1); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s02 = matrix2.get(0, 2); + final long s12 = matrix2.get(1, 2); + final long s03 = matrix2.get(0, 3); + final long s13 = matrix2.get(1, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13); return output; } private static IMatrixSetterLong multiplyMatrix2x4x3(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final long f_c00 = matrix1.get(0, 0); - final long f_c10 = matrix1.get(1, 0); - final long f_c20 = matrix1.get(2, 0); - final long f_c30 = matrix1.get(3, 0); - final long f_c01 = matrix1.get(0, 1); - final long f_c11 = matrix1.get(1, 1); - final long f_c21 = matrix1.get(2, 1); - final long f_c31 = matrix1.get(3, 1); - final long s_c00 = matrix2.get(0, 0); - final long s_c10 = matrix2.get(1, 0); - final long s_c20 = matrix2.get(2, 0); - final long s_c01 = matrix2.get(0, 1); - final long s_c11 = matrix2.get(1, 1); - final long s_c21 = matrix2.get(2, 1); - final long s_c02 = matrix2.get(0, 2); - final long s_c12 = matrix2.get(1, 2); - final long s_c22 = matrix2.get(2, 2); - final long s_c03 = matrix2.get(0, 3); - final long s_c13 = matrix2.get(1, 3); - final long s_c23 = matrix2.get(2, 3); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long f30 = matrix1.get(3, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f21 = matrix1.get(2, 1); + final long f31 = matrix1.get(3, 1); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s21 = matrix2.get(2, 1); + final long s02 = matrix2.get(0, 2); + final long s12 = matrix2.get(1, 2); + final long s22 = matrix2.get(2, 2); + final long s03 = matrix2.get(0, 3); + final long s13 = matrix2.get(1, 3); + final long s23 = matrix2.get(2, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23); return output; } private static IMatrixSetterLong multiplyMatrix2x4x4(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final long f_c00 = matrix1.get(0, 0); - final long f_c10 = matrix1.get(1, 0); - final long f_c20 = matrix1.get(2, 0); - final long f_c30 = matrix1.get(3, 0); - final long f_c01 = matrix1.get(0, 1); - final long f_c11 = matrix1.get(1, 1); - final long f_c21 = matrix1.get(2, 1); - final long f_c31 = matrix1.get(3, 1); - final long s_c00 = matrix2.get(0, 0); - final long s_c10 = matrix2.get(1, 0); - final long s_c20 = matrix2.get(2, 0); - final long s_c30 = matrix2.get(3, 0); - final long s_c01 = matrix2.get(0, 1); - final long s_c11 = matrix2.get(1, 1); - final long s_c21 = matrix2.get(2, 1); - final long s_c31 = matrix2.get(3, 1); - final long s_c02 = matrix2.get(0, 2); - final long s_c12 = matrix2.get(1, 2); - final long s_c22 = matrix2.get(2, 2); - final long s_c32 = matrix2.get(3, 2); - final long s_c03 = matrix2.get(0, 3); - final long s_c13 = matrix2.get(1, 3); - final long s_c23 = matrix2.get(2, 3); - final long s_c33 = matrix2.get(3, 3); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long f30 = matrix1.get(3, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f21 = matrix1.get(2, 1); + final long f31 = matrix1.get(3, 1); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + final long s30 = matrix2.get(3, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s21 = matrix2.get(2, 1); + final long s31 = matrix2.get(3, 1); + final long s02 = matrix2.get(0, 2); + final long s12 = matrix2.get(1, 2); + final long s22 = matrix2.get(2, 2); + final long s32 = matrix2.get(3, 2); + final long s03 = matrix2.get(0, 3); + final long s13 = matrix2.get(1, 3); + final long s23 = matrix2.get(2, 3); + final long s33 = matrix2.get(3, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33); return output; } private static IMatrixSetterLong multiplyMatrix2x4x5(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final long f_c00 = matrix1.get(0, 0); - final long f_c10 = matrix1.get(1, 0); - final long f_c20 = matrix1.get(2, 0); - final long f_c30 = matrix1.get(3, 0); - final long f_c01 = matrix1.get(0, 1); - final long f_c11 = matrix1.get(1, 1); - final long f_c21 = matrix1.get(2, 1); - final long f_c31 = matrix1.get(3, 1); - final long s_c00 = matrix2.get(0, 0); - final long s_c10 = matrix2.get(1, 0); - final long s_c20 = matrix2.get(2, 0); - final long s_c30 = matrix2.get(3, 0); - final long s_c40 = matrix2.get(4, 0); - final long s_c01 = matrix2.get(0, 1); - final long s_c11 = matrix2.get(1, 1); - final long s_c21 = matrix2.get(2, 1); - final long s_c31 = matrix2.get(3, 1); - final long s_c41 = matrix2.get(4, 1); - final long s_c02 = matrix2.get(0, 2); - final long s_c12 = matrix2.get(1, 2); - final long s_c22 = matrix2.get(2, 2); - final long s_c32 = matrix2.get(3, 2); - final long s_c42 = matrix2.get(4, 2); - final long s_c03 = matrix2.get(0, 3); - final long s_c13 = matrix2.get(1, 3); - final long s_c23 = matrix2.get(2, 3); - final long s_c33 = matrix2.get(3, 3); - final long s_c43 = matrix2.get(4, 3); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33); - output.set(4, 0, f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42 + f_c30*s_c43); - output.set(4, 1, f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42 + f_c31*s_c43); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long f30 = matrix1.get(3, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f21 = matrix1.get(2, 1); + final long f31 = matrix1.get(3, 1); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + final long s30 = matrix2.get(3, 0); + final long s40 = matrix2.get(4, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s21 = matrix2.get(2, 1); + final long s31 = matrix2.get(3, 1); + final long s41 = matrix2.get(4, 1); + final long s02 = matrix2.get(0, 2); + final long s12 = matrix2.get(1, 2); + final long s22 = matrix2.get(2, 2); + final long s32 = matrix2.get(3, 2); + final long s42 = matrix2.get(4, 2); + final long s03 = matrix2.get(0, 3); + final long s13 = matrix2.get(1, 3); + final long s23 = matrix2.get(2, 3); + final long s33 = matrix2.get(3, 3); + final long s43 = matrix2.get(4, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33); + output.set(4, 0, f00 * s40 + f10 * s41 + f20 * s42 + f30 * s43); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33); + output.set(4, 1, f01 * s40 + f11 * s41 + f21 * s42 + f31 * s43); + return output; + } + + private static IMatrixSetterLong multiplyMatrix3x4x1(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long f30 = matrix1.get(3, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f21 = matrix1.get(2, 1); + final long f31 = matrix1.get(3, 1); + final long f02 = matrix1.get(0, 2); + final long f12 = matrix1.get(1, 2); + final long f22 = matrix1.get(2, 2); + final long f32 = matrix1.get(3, 2); + final long s00 = matrix2.get(0, 0); + final long s01 = matrix2.get(0, 1); + final long s02 = matrix2.get(0, 2); + final long s03 = matrix2.get(0, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03); return output; } private static IMatrixSetterLong multiplyMatrix3x4x2(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final long f_c00 = matrix1.get(0, 0); - final long f_c10 = matrix1.get(1, 0); - final long f_c20 = matrix1.get(2, 0); - final long f_c30 = matrix1.get(3, 0); - final long f_c01 = matrix1.get(0, 1); - final long f_c11 = matrix1.get(1, 1); - final long f_c21 = matrix1.get(2, 1); - final long f_c31 = matrix1.get(3, 1); - final long f_c02 = matrix1.get(0, 2); - final long f_c12 = matrix1.get(1, 2); - final long f_c22 = matrix1.get(2, 2); - final long f_c32 = matrix1.get(3, 2); - final long s_c00 = matrix2.get(0, 0); - final long s_c10 = matrix2.get(1, 0); - final long s_c01 = matrix2.get(0, 1); - final long s_c11 = matrix2.get(1, 1); - final long s_c02 = matrix2.get(0, 2); - final long s_c12 = matrix2.get(1, 2); - final long s_c03 = matrix2.get(0, 3); - final long s_c13 = matrix2.get(1, 3); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long f30 = matrix1.get(3, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f21 = matrix1.get(2, 1); + final long f31 = matrix1.get(3, 1); + final long f02 = matrix1.get(0, 2); + final long f12 = matrix1.get(1, 2); + final long f22 = matrix1.get(2, 2); + final long f32 = matrix1.get(3, 2); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s02 = matrix2.get(0, 2); + final long s12 = matrix2.get(1, 2); + final long s03 = matrix2.get(0, 3); + final long s13 = matrix2.get(1, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13); return output; } private static IMatrixSetterLong multiplyMatrix3x4x3(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final long f_c00 = matrix1.get(0, 0); - final long f_c10 = matrix1.get(1, 0); - final long f_c20 = matrix1.get(2, 0); - final long f_c30 = matrix1.get(3, 0); - final long f_c01 = matrix1.get(0, 1); - final long f_c11 = matrix1.get(1, 1); - final long f_c21 = matrix1.get(2, 1); - final long f_c31 = matrix1.get(3, 1); - final long f_c02 = matrix1.get(0, 2); - final long f_c12 = matrix1.get(1, 2); - final long f_c22 = matrix1.get(2, 2); - final long f_c32 = matrix1.get(3, 2); - final long s_c00 = matrix2.get(0, 0); - final long s_c10 = matrix2.get(1, 0); - final long s_c20 = matrix2.get(2, 0); - final long s_c01 = matrix2.get(0, 1); - final long s_c11 = matrix2.get(1, 1); - final long s_c21 = matrix2.get(2, 1); - final long s_c02 = matrix2.get(0, 2); - final long s_c12 = matrix2.get(1, 2); - final long s_c22 = matrix2.get(2, 2); - final long s_c03 = matrix2.get(0, 3); - final long s_c13 = matrix2.get(1, 3); - final long s_c23 = matrix2.get(2, 3); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long f30 = matrix1.get(3, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f21 = matrix1.get(2, 1); + final long f31 = matrix1.get(3, 1); + final long f02 = matrix1.get(0, 2); + final long f12 = matrix1.get(1, 2); + final long f22 = matrix1.get(2, 2); + final long f32 = matrix1.get(3, 2); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s21 = matrix2.get(2, 1); + final long s02 = matrix2.get(0, 2); + final long s12 = matrix2.get(1, 2); + final long s22 = matrix2.get(2, 2); + final long s03 = matrix2.get(0, 3); + final long s13 = matrix2.get(1, 3); + final long s23 = matrix2.get(2, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23); return output; } private static IMatrixSetterLong multiplyMatrix3x4x4(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final long f_c00 = matrix1.get(0, 0); - final long f_c10 = matrix1.get(1, 0); - final long f_c20 = matrix1.get(2, 0); - final long f_c30 = matrix1.get(3, 0); - final long f_c01 = matrix1.get(0, 1); - final long f_c11 = matrix1.get(1, 1); - final long f_c21 = matrix1.get(2, 1); - final long f_c31 = matrix1.get(3, 1); - final long f_c02 = matrix1.get(0, 2); - final long f_c12 = matrix1.get(1, 2); - final long f_c22 = matrix1.get(2, 2); - final long f_c32 = matrix1.get(3, 2); - final long s_c00 = matrix2.get(0, 0); - final long s_c10 = matrix2.get(1, 0); - final long s_c20 = matrix2.get(2, 0); - final long s_c30 = matrix2.get(3, 0); - final long s_c01 = matrix2.get(0, 1); - final long s_c11 = matrix2.get(1, 1); - final long s_c21 = matrix2.get(2, 1); - final long s_c31 = matrix2.get(3, 1); - final long s_c02 = matrix2.get(0, 2); - final long s_c12 = matrix2.get(1, 2); - final long s_c22 = matrix2.get(2, 2); - final long s_c32 = matrix2.get(3, 2); - final long s_c03 = matrix2.get(0, 3); - final long s_c13 = matrix2.get(1, 3); - final long s_c23 = matrix2.get(2, 3); - final long s_c33 = matrix2.get(3, 3); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long f30 = matrix1.get(3, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f21 = matrix1.get(2, 1); + final long f31 = matrix1.get(3, 1); + final long f02 = matrix1.get(0, 2); + final long f12 = matrix1.get(1, 2); + final long f22 = matrix1.get(2, 2); + final long f32 = matrix1.get(3, 2); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + final long s30 = matrix2.get(3, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s21 = matrix2.get(2, 1); + final long s31 = matrix2.get(3, 1); + final long s02 = matrix2.get(0, 2); + final long s12 = matrix2.get(1, 2); + final long s22 = matrix2.get(2, 2); + final long s32 = matrix2.get(3, 2); + final long s03 = matrix2.get(0, 3); + final long s13 = matrix2.get(1, 3); + final long s23 = matrix2.get(2, 3); + final long s33 = matrix2.get(3, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33); return output; } private static IMatrixSetterLong multiplyMatrix3x4x5(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final long f_c00 = matrix1.get(0, 0); - final long f_c10 = matrix1.get(1, 0); - final long f_c20 = matrix1.get(2, 0); - final long f_c30 = matrix1.get(3, 0); - final long f_c01 = matrix1.get(0, 1); - final long f_c11 = matrix1.get(1, 1); - final long f_c21 = matrix1.get(2, 1); - final long f_c31 = matrix1.get(3, 1); - final long f_c02 = matrix1.get(0, 2); - final long f_c12 = matrix1.get(1, 2); - final long f_c22 = matrix1.get(2, 2); - final long f_c32 = matrix1.get(3, 2); - final long s_c00 = matrix2.get(0, 0); - final long s_c10 = matrix2.get(1, 0); - final long s_c20 = matrix2.get(2, 0); - final long s_c30 = matrix2.get(3, 0); - final long s_c40 = matrix2.get(4, 0); - final long s_c01 = matrix2.get(0, 1); - final long s_c11 = matrix2.get(1, 1); - final long s_c21 = matrix2.get(2, 1); - final long s_c31 = matrix2.get(3, 1); - final long s_c41 = matrix2.get(4, 1); - final long s_c02 = matrix2.get(0, 2); - final long s_c12 = matrix2.get(1, 2); - final long s_c22 = matrix2.get(2, 2); - final long s_c32 = matrix2.get(3, 2); - final long s_c42 = matrix2.get(4, 2); - final long s_c03 = matrix2.get(0, 3); - final long s_c13 = matrix2.get(1, 3); - final long s_c23 = matrix2.get(2, 3); - final long s_c33 = matrix2.get(3, 3); - final long s_c43 = matrix2.get(4, 3); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33); - output.set(4, 0, f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42 + f_c30*s_c43); - output.set(4, 1, f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42 + f_c31*s_c43); - output.set(4, 2, f_c02*s_c40 + f_c12*s_c41 + f_c22*s_c42 + f_c32*s_c43); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long f30 = matrix1.get(3, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f21 = matrix1.get(2, 1); + final long f31 = matrix1.get(3, 1); + final long f02 = matrix1.get(0, 2); + final long f12 = matrix1.get(1, 2); + final long f22 = matrix1.get(2, 2); + final long f32 = matrix1.get(3, 2); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + final long s30 = matrix2.get(3, 0); + final long s40 = matrix2.get(4, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s21 = matrix2.get(2, 1); + final long s31 = matrix2.get(3, 1); + final long s41 = matrix2.get(4, 1); + final long s02 = matrix2.get(0, 2); + final long s12 = matrix2.get(1, 2); + final long s22 = matrix2.get(2, 2); + final long s32 = matrix2.get(3, 2); + final long s42 = matrix2.get(4, 2); + final long s03 = matrix2.get(0, 3); + final long s13 = matrix2.get(1, 3); + final long s23 = matrix2.get(2, 3); + final long s33 = matrix2.get(3, 3); + final long s43 = matrix2.get(4, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33); + output.set(4, 0, f00 * s40 + f10 * s41 + f20 * s42 + f30 * s43); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33); + output.set(4, 1, f01 * s40 + f11 * s41 + f21 * s42 + f31 * s43); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33); + output.set(4, 2, f02 * s40 + f12 * s41 + f22 * s42 + f32 * s43); + return output; + } + + private static IMatrixSetterLong multiplyMatrix4x4x1(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long f30 = matrix1.get(3, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f21 = matrix1.get(2, 1); + final long f31 = matrix1.get(3, 1); + final long f02 = matrix1.get(0, 2); + final long f12 = matrix1.get(1, 2); + final long f22 = matrix1.get(2, 2); + final long f32 = matrix1.get(3, 2); + final long f03 = matrix1.get(0, 3); + final long f13 = matrix1.get(1, 3); + final long f23 = matrix1.get(2, 3); + final long f33 = matrix1.get(3, 3); + final long s00 = matrix2.get(0, 0); + final long s01 = matrix2.get(0, 1); + final long s02 = matrix2.get(0, 2); + final long s03 = matrix2.get(0, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03); return output; } private static IMatrixSetterLong multiplyMatrix4x4x2(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final long f_c00 = matrix1.get(0, 0); - final long f_c10 = matrix1.get(1, 0); - final long f_c20 = matrix1.get(2, 0); - final long f_c30 = matrix1.get(3, 0); - final long f_c01 = matrix1.get(0, 1); - final long f_c11 = matrix1.get(1, 1); - final long f_c21 = matrix1.get(2, 1); - final long f_c31 = matrix1.get(3, 1); - final long f_c02 = matrix1.get(0, 2); - final long f_c12 = matrix1.get(1, 2); - final long f_c22 = matrix1.get(2, 2); - final long f_c32 = matrix1.get(3, 2); - final long f_c03 = matrix1.get(0, 3); - final long f_c13 = matrix1.get(1, 3); - final long f_c23 = matrix1.get(2, 3); - final long f_c33 = matrix1.get(3, 3); - final long s_c00 = matrix2.get(0, 0); - final long s_c10 = matrix2.get(1, 0); - final long s_c01 = matrix2.get(0, 1); - final long s_c11 = matrix2.get(1, 1); - final long s_c02 = matrix2.get(0, 2); - final long s_c12 = matrix2.get(1, 2); - final long s_c03 = matrix2.get(0, 3); - final long s_c13 = matrix2.get(1, 3); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long f30 = matrix1.get(3, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f21 = matrix1.get(2, 1); + final long f31 = matrix1.get(3, 1); + final long f02 = matrix1.get(0, 2); + final long f12 = matrix1.get(1, 2); + final long f22 = matrix1.get(2, 2); + final long f32 = matrix1.get(3, 2); + final long f03 = matrix1.get(0, 3); + final long f13 = matrix1.get(1, 3); + final long f23 = matrix1.get(2, 3); + final long f33 = matrix1.get(3, 3); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s02 = matrix2.get(0, 2); + final long s12 = matrix2.get(1, 2); + final long s03 = matrix2.get(0, 3); + final long s13 = matrix2.get(1, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13); return output; } private static IMatrixSetterLong multiplyMatrix4x4x3(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final long f_c00 = matrix1.get(0, 0); - final long f_c10 = matrix1.get(1, 0); - final long f_c20 = matrix1.get(2, 0); - final long f_c30 = matrix1.get(3, 0); - final long f_c01 = matrix1.get(0, 1); - final long f_c11 = matrix1.get(1, 1); - final long f_c21 = matrix1.get(2, 1); - final long f_c31 = matrix1.get(3, 1); - final long f_c02 = matrix1.get(0, 2); - final long f_c12 = matrix1.get(1, 2); - final long f_c22 = matrix1.get(2, 2); - final long f_c32 = matrix1.get(3, 2); - final long f_c03 = matrix1.get(0, 3); - final long f_c13 = matrix1.get(1, 3); - final long f_c23 = matrix1.get(2, 3); - final long f_c33 = matrix1.get(3, 3); - final long s_c00 = matrix2.get(0, 0); - final long s_c10 = matrix2.get(1, 0); - final long s_c20 = matrix2.get(2, 0); - final long s_c01 = matrix2.get(0, 1); - final long s_c11 = matrix2.get(1, 1); - final long s_c21 = matrix2.get(2, 1); - final long s_c02 = matrix2.get(0, 2); - final long s_c12 = matrix2.get(1, 2); - final long s_c22 = matrix2.get(2, 2); - final long s_c03 = matrix2.get(0, 3); - final long s_c13 = matrix2.get(1, 3); - final long s_c23 = matrix2.get(2, 3); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long f30 = matrix1.get(3, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f21 = matrix1.get(2, 1); + final long f31 = matrix1.get(3, 1); + final long f02 = matrix1.get(0, 2); + final long f12 = matrix1.get(1, 2); + final long f22 = matrix1.get(2, 2); + final long f32 = matrix1.get(3, 2); + final long f03 = matrix1.get(0, 3); + final long f13 = matrix1.get(1, 3); + final long f23 = matrix1.get(2, 3); + final long f33 = matrix1.get(3, 3); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s21 = matrix2.get(2, 1); + final long s02 = matrix2.get(0, 2); + final long s12 = matrix2.get(1, 2); + final long s22 = matrix2.get(2, 2); + final long s03 = matrix2.get(0, 3); + final long s13 = matrix2.get(1, 3); + final long s23 = matrix2.get(2, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23); return output; } private static IMatrixSetterLong multiplyMatrix4x4x4(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final long f_c00 = matrix1.get(0, 0); - final long f_c10 = matrix1.get(1, 0); - final long f_c20 = matrix1.get(2, 0); - final long f_c30 = matrix1.get(3, 0); - final long f_c01 = matrix1.get(0, 1); - final long f_c11 = matrix1.get(1, 1); - final long f_c21 = matrix1.get(2, 1); - final long f_c31 = matrix1.get(3, 1); - final long f_c02 = matrix1.get(0, 2); - final long f_c12 = matrix1.get(1, 2); - final long f_c22 = matrix1.get(2, 2); - final long f_c32 = matrix1.get(3, 2); - final long f_c03 = matrix1.get(0, 3); - final long f_c13 = matrix1.get(1, 3); - final long f_c23 = matrix1.get(2, 3); - final long f_c33 = matrix1.get(3, 3); - final long s_c00 = matrix2.get(0, 0); - final long s_c10 = matrix2.get(1, 0); - final long s_c20 = matrix2.get(2, 0); - final long s_c30 = matrix2.get(3, 0); - final long s_c01 = matrix2.get(0, 1); - final long s_c11 = matrix2.get(1, 1); - final long s_c21 = matrix2.get(2, 1); - final long s_c31 = matrix2.get(3, 1); - final long s_c02 = matrix2.get(0, 2); - final long s_c12 = matrix2.get(1, 2); - final long s_c22 = matrix2.get(2, 2); - final long s_c32 = matrix2.get(3, 2); - final long s_c03 = matrix2.get(0, 3); - final long s_c13 = matrix2.get(1, 3); - final long s_c23 = matrix2.get(2, 3); - final long s_c33 = matrix2.get(3, 3); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33); - output.set(3, 3, f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32 + f_c33*s_c33); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long f30 = matrix1.get(3, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f21 = matrix1.get(2, 1); + final long f31 = matrix1.get(3, 1); + final long f02 = matrix1.get(0, 2); + final long f12 = matrix1.get(1, 2); + final long f22 = matrix1.get(2, 2); + final long f32 = matrix1.get(3, 2); + final long f03 = matrix1.get(0, 3); + final long f13 = matrix1.get(1, 3); + final long f23 = matrix1.get(2, 3); + final long f33 = matrix1.get(3, 3); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + final long s30 = matrix2.get(3, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s21 = matrix2.get(2, 1); + final long s31 = matrix2.get(3, 1); + final long s02 = matrix2.get(0, 2); + final long s12 = matrix2.get(1, 2); + final long s22 = matrix2.get(2, 2); + final long s32 = matrix2.get(3, 2); + final long s03 = matrix2.get(0, 3); + final long s13 = matrix2.get(1, 3); + final long s23 = matrix2.get(2, 3); + final long s33 = matrix2.get(3, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23); + output.set(3, 3, f03 * s30 + f13 * s31 + f23 * s32 + f33 * s33); return output; } private static IMatrixSetterLong multiplyMatrix4x4x5(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final long f_c00 = matrix1.get(0, 0); - final long f_c10 = matrix1.get(1, 0); - final long f_c20 = matrix1.get(2, 0); - final long f_c30 = matrix1.get(3, 0); - final long f_c01 = matrix1.get(0, 1); - final long f_c11 = matrix1.get(1, 1); - final long f_c21 = matrix1.get(2, 1); - final long f_c31 = matrix1.get(3, 1); - final long f_c02 = matrix1.get(0, 2); - final long f_c12 = matrix1.get(1, 2); - final long f_c22 = matrix1.get(2, 2); - final long f_c32 = matrix1.get(3, 2); - final long f_c03 = matrix1.get(0, 3); - final long f_c13 = matrix1.get(1, 3); - final long f_c23 = matrix1.get(2, 3); - final long f_c33 = matrix1.get(3, 3); - final long s_c00 = matrix2.get(0, 0); - final long s_c10 = matrix2.get(1, 0); - final long s_c20 = matrix2.get(2, 0); - final long s_c30 = matrix2.get(3, 0); - final long s_c40 = matrix2.get(4, 0); - final long s_c01 = matrix2.get(0, 1); - final long s_c11 = matrix2.get(1, 1); - final long s_c21 = matrix2.get(2, 1); - final long s_c31 = matrix2.get(3, 1); - final long s_c41 = matrix2.get(4, 1); - final long s_c02 = matrix2.get(0, 2); - final long s_c12 = matrix2.get(1, 2); - final long s_c22 = matrix2.get(2, 2); - final long s_c32 = matrix2.get(3, 2); - final long s_c42 = matrix2.get(4, 2); - final long s_c03 = matrix2.get(0, 3); - final long s_c13 = matrix2.get(1, 3); - final long s_c23 = matrix2.get(2, 3); - final long s_c33 = matrix2.get(3, 3); - final long s_c43 = matrix2.get(4, 3); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33); - output.set(3, 3, f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32 + f_c33*s_c33); - output.set(4, 0, f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42 + f_c30*s_c43); - output.set(4, 1, f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42 + f_c31*s_c43); - output.set(4, 2, f_c02*s_c40 + f_c12*s_c41 + f_c22*s_c42 + f_c32*s_c43); - output.set(4, 3, f_c03*s_c40 + f_c13*s_c41 + f_c23*s_c42 + f_c33*s_c43); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long f30 = matrix1.get(3, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f21 = matrix1.get(2, 1); + final long f31 = matrix1.get(3, 1); + final long f02 = matrix1.get(0, 2); + final long f12 = matrix1.get(1, 2); + final long f22 = matrix1.get(2, 2); + final long f32 = matrix1.get(3, 2); + final long f03 = matrix1.get(0, 3); + final long f13 = matrix1.get(1, 3); + final long f23 = matrix1.get(2, 3); + final long f33 = matrix1.get(3, 3); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + final long s30 = matrix2.get(3, 0); + final long s40 = matrix2.get(4, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s21 = matrix2.get(2, 1); + final long s31 = matrix2.get(3, 1); + final long s41 = matrix2.get(4, 1); + final long s02 = matrix2.get(0, 2); + final long s12 = matrix2.get(1, 2); + final long s22 = matrix2.get(2, 2); + final long s32 = matrix2.get(3, 2); + final long s42 = matrix2.get(4, 2); + final long s03 = matrix2.get(0, 3); + final long s13 = matrix2.get(1, 3); + final long s23 = matrix2.get(2, 3); + final long s33 = matrix2.get(3, 3); + final long s43 = matrix2.get(4, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33); + output.set(4, 0, f00 * s40 + f10 * s41 + f20 * s42 + f30 * s43); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33); + output.set(4, 1, f01 * s40 + f11 * s41 + f21 * s42 + f31 * s43); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33); + output.set(4, 2, f02 * s40 + f12 * s41 + f22 * s42 + f32 * s43); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23); + output.set(3, 3, f03 * s30 + f13 * s31 + f23 * s32 + f33 * s33); + output.set(4, 3, f03 * s40 + f13 * s41 + f23 * s42 + f33 * s43); + return output; + } + + private static IMatrixSetterLong multiplyMatrix5x4x1(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long f30 = matrix1.get(3, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f21 = matrix1.get(2, 1); + final long f31 = matrix1.get(3, 1); + final long f02 = matrix1.get(0, 2); + final long f12 = matrix1.get(1, 2); + final long f22 = matrix1.get(2, 2); + final long f32 = matrix1.get(3, 2); + final long f03 = matrix1.get(0, 3); + final long f13 = matrix1.get(1, 3); + final long f23 = matrix1.get(2, 3); + final long f33 = matrix1.get(3, 3); + final long f04 = matrix1.get(0, 4); + final long f14 = matrix1.get(1, 4); + final long f24 = matrix1.get(2, 4); + final long f34 = matrix1.get(3, 4); + final long s00 = matrix2.get(0, 0); + final long s01 = matrix2.get(0, 1); + final long s02 = matrix2.get(0, 2); + final long s03 = matrix2.get(0, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03); + output.set(0, 4, f04 * s00 + f14 * s01 + f24 * s02 + f34 * s03); return output; } private static IMatrixSetterLong multiplyMatrix5x4x2(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final long f_c00 = matrix1.get(0, 0); - final long f_c10 = matrix1.get(1, 0); - final long f_c20 = matrix1.get(2, 0); - final long f_c30 = matrix1.get(3, 0); - final long f_c01 = matrix1.get(0, 1); - final long f_c11 = matrix1.get(1, 1); - final long f_c21 = matrix1.get(2, 1); - final long f_c31 = matrix1.get(3, 1); - final long f_c02 = matrix1.get(0, 2); - final long f_c12 = matrix1.get(1, 2); - final long f_c22 = matrix1.get(2, 2); - final long f_c32 = matrix1.get(3, 2); - final long f_c03 = matrix1.get(0, 3); - final long f_c13 = matrix1.get(1, 3); - final long f_c23 = matrix1.get(2, 3); - final long f_c33 = matrix1.get(3, 3); - final long f_c04 = matrix1.get(0, 4); - final long f_c14 = matrix1.get(1, 4); - final long f_c24 = matrix1.get(2, 4); - final long f_c34 = matrix1.get(3, 4); - final long s_c00 = matrix2.get(0, 0); - final long s_c10 = matrix2.get(1, 0); - final long s_c01 = matrix2.get(0, 1); - final long s_c11 = matrix2.get(1, 1); - final long s_c02 = matrix2.get(0, 2); - final long s_c12 = matrix2.get(1, 2); - final long s_c03 = matrix2.get(0, 3); - final long s_c13 = matrix2.get(1, 3); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03); - output.set(0, 4, f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02 + f_c34*s_c03); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13); - output.set(1, 4, f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12 + f_c34*s_c13); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long f30 = matrix1.get(3, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f21 = matrix1.get(2, 1); + final long f31 = matrix1.get(3, 1); + final long f02 = matrix1.get(0, 2); + final long f12 = matrix1.get(1, 2); + final long f22 = matrix1.get(2, 2); + final long f32 = matrix1.get(3, 2); + final long f03 = matrix1.get(0, 3); + final long f13 = matrix1.get(1, 3); + final long f23 = matrix1.get(2, 3); + final long f33 = matrix1.get(3, 3); + final long f04 = matrix1.get(0, 4); + final long f14 = matrix1.get(1, 4); + final long f24 = matrix1.get(2, 4); + final long f34 = matrix1.get(3, 4); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s02 = matrix2.get(0, 2); + final long s12 = matrix2.get(1, 2); + final long s03 = matrix2.get(0, 3); + final long s13 = matrix2.get(1, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13); + output.set(0, 4, f04 * s00 + f14 * s01 + f24 * s02 + f34 * s03); + output.set(1, 4, f04 * s10 + f14 * s11 + f24 * s12 + f34 * s13); return output; } private static IMatrixSetterLong multiplyMatrix5x4x3(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final long f_c00 = matrix1.get(0, 0); - final long f_c10 = matrix1.get(1, 0); - final long f_c20 = matrix1.get(2, 0); - final long f_c30 = matrix1.get(3, 0); - final long f_c01 = matrix1.get(0, 1); - final long f_c11 = matrix1.get(1, 1); - final long f_c21 = matrix1.get(2, 1); - final long f_c31 = matrix1.get(3, 1); - final long f_c02 = matrix1.get(0, 2); - final long f_c12 = matrix1.get(1, 2); - final long f_c22 = matrix1.get(2, 2); - final long f_c32 = matrix1.get(3, 2); - final long f_c03 = matrix1.get(0, 3); - final long f_c13 = matrix1.get(1, 3); - final long f_c23 = matrix1.get(2, 3); - final long f_c33 = matrix1.get(3, 3); - final long f_c04 = matrix1.get(0, 4); - final long f_c14 = matrix1.get(1, 4); - final long f_c24 = matrix1.get(2, 4); - final long f_c34 = matrix1.get(3, 4); - final long s_c00 = matrix2.get(0, 0); - final long s_c10 = matrix2.get(1, 0); - final long s_c20 = matrix2.get(2, 0); - final long s_c01 = matrix2.get(0, 1); - final long s_c11 = matrix2.get(1, 1); - final long s_c21 = matrix2.get(2, 1); - final long s_c02 = matrix2.get(0, 2); - final long s_c12 = matrix2.get(1, 2); - final long s_c22 = matrix2.get(2, 2); - final long s_c03 = matrix2.get(0, 3); - final long s_c13 = matrix2.get(1, 3); - final long s_c23 = matrix2.get(2, 3); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03); - output.set(0, 4, f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02 + f_c34*s_c03); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13); - output.set(1, 4, f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12 + f_c34*s_c13); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23); - output.set(2, 4, f_c04*s_c20 + f_c14*s_c21 + f_c24*s_c22 + f_c34*s_c23); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long f30 = matrix1.get(3, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f21 = matrix1.get(2, 1); + final long f31 = matrix1.get(3, 1); + final long f02 = matrix1.get(0, 2); + final long f12 = matrix1.get(1, 2); + final long f22 = matrix1.get(2, 2); + final long f32 = matrix1.get(3, 2); + final long f03 = matrix1.get(0, 3); + final long f13 = matrix1.get(1, 3); + final long f23 = matrix1.get(2, 3); + final long f33 = matrix1.get(3, 3); + final long f04 = matrix1.get(0, 4); + final long f14 = matrix1.get(1, 4); + final long f24 = matrix1.get(2, 4); + final long f34 = matrix1.get(3, 4); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s21 = matrix2.get(2, 1); + final long s02 = matrix2.get(0, 2); + final long s12 = matrix2.get(1, 2); + final long s22 = matrix2.get(2, 2); + final long s03 = matrix2.get(0, 3); + final long s13 = matrix2.get(1, 3); + final long s23 = matrix2.get(2, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23); + output.set(0, 4, f04 * s00 + f14 * s01 + f24 * s02 + f34 * s03); + output.set(1, 4, f04 * s10 + f14 * s11 + f24 * s12 + f34 * s13); + output.set(2, 4, f04 * s20 + f14 * s21 + f24 * s22 + f34 * s23); return output; } private static IMatrixSetterLong multiplyMatrix5x4x4(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final long f_c00 = matrix1.get(0, 0); - final long f_c10 = matrix1.get(1, 0); - final long f_c20 = matrix1.get(2, 0); - final long f_c30 = matrix1.get(3, 0); - final long f_c01 = matrix1.get(0, 1); - final long f_c11 = matrix1.get(1, 1); - final long f_c21 = matrix1.get(2, 1); - final long f_c31 = matrix1.get(3, 1); - final long f_c02 = matrix1.get(0, 2); - final long f_c12 = matrix1.get(1, 2); - final long f_c22 = matrix1.get(2, 2); - final long f_c32 = matrix1.get(3, 2); - final long f_c03 = matrix1.get(0, 3); - final long f_c13 = matrix1.get(1, 3); - final long f_c23 = matrix1.get(2, 3); - final long f_c33 = matrix1.get(3, 3); - final long f_c04 = matrix1.get(0, 4); - final long f_c14 = matrix1.get(1, 4); - final long f_c24 = matrix1.get(2, 4); - final long f_c34 = matrix1.get(3, 4); - final long s_c00 = matrix2.get(0, 0); - final long s_c10 = matrix2.get(1, 0); - final long s_c20 = matrix2.get(2, 0); - final long s_c30 = matrix2.get(3, 0); - final long s_c01 = matrix2.get(0, 1); - final long s_c11 = matrix2.get(1, 1); - final long s_c21 = matrix2.get(2, 1); - final long s_c31 = matrix2.get(3, 1); - final long s_c02 = matrix2.get(0, 2); - final long s_c12 = matrix2.get(1, 2); - final long s_c22 = matrix2.get(2, 2); - final long s_c32 = matrix2.get(3, 2); - final long s_c03 = matrix2.get(0, 3); - final long s_c13 = matrix2.get(1, 3); - final long s_c23 = matrix2.get(2, 3); - final long s_c33 = matrix2.get(3, 3); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03); - output.set(0, 4, f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02 + f_c34*s_c03); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13); - output.set(1, 4, f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12 + f_c34*s_c13); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23); - output.set(2, 4, f_c04*s_c20 + f_c14*s_c21 + f_c24*s_c22 + f_c34*s_c23); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33); - output.set(3, 3, f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32 + f_c33*s_c33); - output.set(3, 4, f_c04*s_c30 + f_c14*s_c31 + f_c24*s_c32 + f_c34*s_c33); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long f30 = matrix1.get(3, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f21 = matrix1.get(2, 1); + final long f31 = matrix1.get(3, 1); + final long f02 = matrix1.get(0, 2); + final long f12 = matrix1.get(1, 2); + final long f22 = matrix1.get(2, 2); + final long f32 = matrix1.get(3, 2); + final long f03 = matrix1.get(0, 3); + final long f13 = matrix1.get(1, 3); + final long f23 = matrix1.get(2, 3); + final long f33 = matrix1.get(3, 3); + final long f04 = matrix1.get(0, 4); + final long f14 = matrix1.get(1, 4); + final long f24 = matrix1.get(2, 4); + final long f34 = matrix1.get(3, 4); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + final long s30 = matrix2.get(3, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s21 = matrix2.get(2, 1); + final long s31 = matrix2.get(3, 1); + final long s02 = matrix2.get(0, 2); + final long s12 = matrix2.get(1, 2); + final long s22 = matrix2.get(2, 2); + final long s32 = matrix2.get(3, 2); + final long s03 = matrix2.get(0, 3); + final long s13 = matrix2.get(1, 3); + final long s23 = matrix2.get(2, 3); + final long s33 = matrix2.get(3, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23); + output.set(3, 3, f03 * s30 + f13 * s31 + f23 * s32 + f33 * s33); + output.set(0, 4, f04 * s00 + f14 * s01 + f24 * s02 + f34 * s03); + output.set(1, 4, f04 * s10 + f14 * s11 + f24 * s12 + f34 * s13); + output.set(2, 4, f04 * s20 + f14 * s21 + f24 * s22 + f34 * s23); + output.set(3, 4, f04 * s30 + f14 * s31 + f24 * s32 + f34 * s33); return output; } private static IMatrixSetterLong multiplyMatrix5x4x5(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final long f_c00 = matrix1.get(0, 0); - final long f_c10 = matrix1.get(1, 0); - final long f_c20 = matrix1.get(2, 0); - final long f_c30 = matrix1.get(3, 0); - final long f_c01 = matrix1.get(0, 1); - final long f_c11 = matrix1.get(1, 1); - final long f_c21 = matrix1.get(2, 1); - final long f_c31 = matrix1.get(3, 1); - final long f_c02 = matrix1.get(0, 2); - final long f_c12 = matrix1.get(1, 2); - final long f_c22 = matrix1.get(2, 2); - final long f_c32 = matrix1.get(3, 2); - final long f_c03 = matrix1.get(0, 3); - final long f_c13 = matrix1.get(1, 3); - final long f_c23 = matrix1.get(2, 3); - final long f_c33 = matrix1.get(3, 3); - final long f_c04 = matrix1.get(0, 4); - final long f_c14 = matrix1.get(1, 4); - final long f_c24 = matrix1.get(2, 4); - final long f_c34 = matrix1.get(3, 4); - final long s_c00 = matrix2.get(0, 0); - final long s_c10 = matrix2.get(1, 0); - final long s_c20 = matrix2.get(2, 0); - final long s_c30 = matrix2.get(3, 0); - final long s_c40 = matrix2.get(4, 0); - final long s_c01 = matrix2.get(0, 1); - final long s_c11 = matrix2.get(1, 1); - final long s_c21 = matrix2.get(2, 1); - final long s_c31 = matrix2.get(3, 1); - final long s_c41 = matrix2.get(4, 1); - final long s_c02 = matrix2.get(0, 2); - final long s_c12 = matrix2.get(1, 2); - final long s_c22 = matrix2.get(2, 2); - final long s_c32 = matrix2.get(3, 2); - final long s_c42 = matrix2.get(4, 2); - final long s_c03 = matrix2.get(0, 3); - final long s_c13 = matrix2.get(1, 3); - final long s_c23 = matrix2.get(2, 3); - final long s_c33 = matrix2.get(3, 3); - final long s_c43 = matrix2.get(4, 3); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03); - output.set(0, 4, f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02 + f_c34*s_c03); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13); - output.set(1, 4, f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12 + f_c34*s_c13); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23); - output.set(2, 4, f_c04*s_c20 + f_c14*s_c21 + f_c24*s_c22 + f_c34*s_c23); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33); - output.set(3, 3, f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32 + f_c33*s_c33); - output.set(3, 4, f_c04*s_c30 + f_c14*s_c31 + f_c24*s_c32 + f_c34*s_c33); - output.set(4, 0, f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42 + f_c30*s_c43); - output.set(4, 1, f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42 + f_c31*s_c43); - output.set(4, 2, f_c02*s_c40 + f_c12*s_c41 + f_c22*s_c42 + f_c32*s_c43); - output.set(4, 3, f_c03*s_c40 + f_c13*s_c41 + f_c23*s_c42 + f_c33*s_c43); - output.set(4, 4, f_c04*s_c40 + f_c14*s_c41 + f_c24*s_c42 + f_c34*s_c43); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long f30 = matrix1.get(3, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f21 = matrix1.get(2, 1); + final long f31 = matrix1.get(3, 1); + final long f02 = matrix1.get(0, 2); + final long f12 = matrix1.get(1, 2); + final long f22 = matrix1.get(2, 2); + final long f32 = matrix1.get(3, 2); + final long f03 = matrix1.get(0, 3); + final long f13 = matrix1.get(1, 3); + final long f23 = matrix1.get(2, 3); + final long f33 = matrix1.get(3, 3); + final long f04 = matrix1.get(0, 4); + final long f14 = matrix1.get(1, 4); + final long f24 = matrix1.get(2, 4); + final long f34 = matrix1.get(3, 4); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + final long s30 = matrix2.get(3, 0); + final long s40 = matrix2.get(4, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s21 = matrix2.get(2, 1); + final long s31 = matrix2.get(3, 1); + final long s41 = matrix2.get(4, 1); + final long s02 = matrix2.get(0, 2); + final long s12 = matrix2.get(1, 2); + final long s22 = matrix2.get(2, 2); + final long s32 = matrix2.get(3, 2); + final long s42 = matrix2.get(4, 2); + final long s03 = matrix2.get(0, 3); + final long s13 = matrix2.get(1, 3); + final long s23 = matrix2.get(2, 3); + final long s33 = matrix2.get(3, 3); + final long s43 = matrix2.get(4, 3); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33); + output.set(4, 0, f00 * s40 + f10 * s41 + f20 * s42 + f30 * s43); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33); + output.set(4, 1, f01 * s40 + f11 * s41 + f21 * s42 + f31 * s43); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33); + output.set(4, 2, f02 * s40 + f12 * s41 + f22 * s42 + f32 * s43); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23); + output.set(3, 3, f03 * s30 + f13 * s31 + f23 * s32 + f33 * s33); + output.set(4, 3, f03 * s40 + f13 * s41 + f23 * s42 + f33 * s43); + output.set(0, 4, f04 * s00 + f14 * s01 + f24 * s02 + f34 * s03); + output.set(1, 4, f04 * s10 + f14 * s11 + f24 * s12 + f34 * s13); + output.set(2, 4, f04 * s20 + f14 * s21 + f24 * s22 + f34 * s23); + output.set(3, 4, f04 * s30 + f14 * s31 + f24 * s32 + f34 * s33); + output.set(4, 4, f04 * s40 + f14 * s41 + f24 * s42 + f34 * s43); + return output; + } + + private static IMatrixSetterLong multiplyMatrix1x5x1(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long f30 = matrix1.get(3, 0); + final long f40 = matrix1.get(4, 0); + final long s00 = matrix2.get(0, 0); + final long s01 = matrix2.get(0, 1); + final long s02 = matrix2.get(0, 2); + final long s03 = matrix2.get(0, 3); + final long s04 = matrix2.get(0, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + return output; + } + + private static IMatrixSetterLong multiplyMatrix1x5x2(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long f30 = matrix1.get(3, 0); + final long f40 = matrix1.get(4, 0); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s02 = matrix2.get(0, 2); + final long s12 = matrix2.get(1, 2); + final long s03 = matrix2.get(0, 3); + final long s13 = matrix2.get(1, 3); + final long s04 = matrix2.get(0, 4); + final long s14 = matrix2.get(1, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + return output; + } + + private static IMatrixSetterLong multiplyMatrix1x5x3(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long f30 = matrix1.get(3, 0); + final long f40 = matrix1.get(4, 0); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s21 = matrix2.get(2, 1); + final long s02 = matrix2.get(0, 2); + final long s12 = matrix2.get(1, 2); + final long s22 = matrix2.get(2, 2); + final long s03 = matrix2.get(0, 3); + final long s13 = matrix2.get(1, 3); + final long s23 = matrix2.get(2, 3); + final long s04 = matrix2.get(0, 4); + final long s14 = matrix2.get(1, 4); + final long s24 = matrix2.get(2, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24); + return output; + } + + private static IMatrixSetterLong multiplyMatrix1x5x4(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long f30 = matrix1.get(3, 0); + final long f40 = matrix1.get(4, 0); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + final long s30 = matrix2.get(3, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s21 = matrix2.get(2, 1); + final long s31 = matrix2.get(3, 1); + final long s02 = matrix2.get(0, 2); + final long s12 = matrix2.get(1, 2); + final long s22 = matrix2.get(2, 2); + final long s32 = matrix2.get(3, 2); + final long s03 = matrix2.get(0, 3); + final long s13 = matrix2.get(1, 3); + final long s23 = matrix2.get(2, 3); + final long s33 = matrix2.get(3, 3); + final long s04 = matrix2.get(0, 4); + final long s14 = matrix2.get(1, 4); + final long s24 = matrix2.get(2, 4); + final long s34 = matrix2.get(3, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33 + f40 * s34); + return output; + } + + private static IMatrixSetterLong multiplyMatrix1x5x5(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long f30 = matrix1.get(3, 0); + final long f40 = matrix1.get(4, 0); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + final long s30 = matrix2.get(3, 0); + final long s40 = matrix2.get(4, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s21 = matrix2.get(2, 1); + final long s31 = matrix2.get(3, 1); + final long s41 = matrix2.get(4, 1); + final long s02 = matrix2.get(0, 2); + final long s12 = matrix2.get(1, 2); + final long s22 = matrix2.get(2, 2); + final long s32 = matrix2.get(3, 2); + final long s42 = matrix2.get(4, 2); + final long s03 = matrix2.get(0, 3); + final long s13 = matrix2.get(1, 3); + final long s23 = matrix2.get(2, 3); + final long s33 = matrix2.get(3, 3); + final long s43 = matrix2.get(4, 3); + final long s04 = matrix2.get(0, 4); + final long s14 = matrix2.get(1, 4); + final long s24 = matrix2.get(2, 4); + final long s34 = matrix2.get(3, 4); + final long s44 = matrix2.get(4, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33 + f40 * s34); + output.set(4, 0, f00 * s40 + f10 * s41 + f20 * s42 + f30 * s43 + f40 * s44); + return output; + } + + private static IMatrixSetterLong multiplyMatrix2x5x1(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long f30 = matrix1.get(3, 0); + final long f40 = matrix1.get(4, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f21 = matrix1.get(2, 1); + final long f31 = matrix1.get(3, 1); + final long f41 = matrix1.get(4, 1); + final long s00 = matrix2.get(0, 0); + final long s01 = matrix2.get(0, 1); + final long s02 = matrix2.get(0, 2); + final long s03 = matrix2.get(0, 3); + final long s04 = matrix2.get(0, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); return output; } private static IMatrixSetterLong multiplyMatrix2x5x2(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final long f_c00 = matrix1.get(0, 0); - final long f_c10 = matrix1.get(1, 0); - final long f_c20 = matrix1.get(2, 0); - final long f_c30 = matrix1.get(3, 0); - final long f_c40 = matrix1.get(4, 0); - final long f_c01 = matrix1.get(0, 1); - final long f_c11 = matrix1.get(1, 1); - final long f_c21 = matrix1.get(2, 1); - final long f_c31 = matrix1.get(3, 1); - final long f_c41 = matrix1.get(4, 1); - final long s_c00 = matrix2.get(0, 0); - final long s_c10 = matrix2.get(1, 0); - final long s_c01 = matrix2.get(0, 1); - final long s_c11 = matrix2.get(1, 1); - final long s_c02 = matrix2.get(0, 2); - final long s_c12 = matrix2.get(1, 2); - final long s_c03 = matrix2.get(0, 3); - final long s_c13 = matrix2.get(1, 3); - final long s_c04 = matrix2.get(0, 4); - final long s_c14 = matrix2.get(1, 4); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long f30 = matrix1.get(3, 0); + final long f40 = matrix1.get(4, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f21 = matrix1.get(2, 1); + final long f31 = matrix1.get(3, 1); + final long f41 = matrix1.get(4, 1); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s02 = matrix2.get(0, 2); + final long s12 = matrix2.get(1, 2); + final long s03 = matrix2.get(0, 3); + final long s13 = matrix2.get(1, 3); + final long s04 = matrix2.get(0, 4); + final long s14 = matrix2.get(1, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14); return output; } private static IMatrixSetterLong multiplyMatrix2x5x3(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final long f_c00 = matrix1.get(0, 0); - final long f_c10 = matrix1.get(1, 0); - final long f_c20 = matrix1.get(2, 0); - final long f_c30 = matrix1.get(3, 0); - final long f_c40 = matrix1.get(4, 0); - final long f_c01 = matrix1.get(0, 1); - final long f_c11 = matrix1.get(1, 1); - final long f_c21 = matrix1.get(2, 1); - final long f_c31 = matrix1.get(3, 1); - final long f_c41 = matrix1.get(4, 1); - final long s_c00 = matrix2.get(0, 0); - final long s_c10 = matrix2.get(1, 0); - final long s_c20 = matrix2.get(2, 0); - final long s_c01 = matrix2.get(0, 1); - final long s_c11 = matrix2.get(1, 1); - final long s_c21 = matrix2.get(2, 1); - final long s_c02 = matrix2.get(0, 2); - final long s_c12 = matrix2.get(1, 2); - final long s_c22 = matrix2.get(2, 2); - final long s_c03 = matrix2.get(0, 3); - final long s_c13 = matrix2.get(1, 3); - final long s_c23 = matrix2.get(2, 3); - final long s_c04 = matrix2.get(0, 4); - final long s_c14 = matrix2.get(1, 4); - final long s_c24 = matrix2.get(2, 4); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long f30 = matrix1.get(3, 0); + final long f40 = matrix1.get(4, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f21 = matrix1.get(2, 1); + final long f31 = matrix1.get(3, 1); + final long f41 = matrix1.get(4, 1); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s21 = matrix2.get(2, 1); + final long s02 = matrix2.get(0, 2); + final long s12 = matrix2.get(1, 2); + final long s22 = matrix2.get(2, 2); + final long s03 = matrix2.get(0, 3); + final long s13 = matrix2.get(1, 3); + final long s23 = matrix2.get(2, 3); + final long s04 = matrix2.get(0, 4); + final long s14 = matrix2.get(1, 4); + final long s24 = matrix2.get(2, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24); return output; } private static IMatrixSetterLong multiplyMatrix2x5x4(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final long f_c00 = matrix1.get(0, 0); - final long f_c10 = matrix1.get(1, 0); - final long f_c20 = matrix1.get(2, 0); - final long f_c30 = matrix1.get(3, 0); - final long f_c40 = matrix1.get(4, 0); - final long f_c01 = matrix1.get(0, 1); - final long f_c11 = matrix1.get(1, 1); - final long f_c21 = matrix1.get(2, 1); - final long f_c31 = matrix1.get(3, 1); - final long f_c41 = matrix1.get(4, 1); - final long s_c00 = matrix2.get(0, 0); - final long s_c10 = matrix2.get(1, 0); - final long s_c20 = matrix2.get(2, 0); - final long s_c30 = matrix2.get(3, 0); - final long s_c01 = matrix2.get(0, 1); - final long s_c11 = matrix2.get(1, 1); - final long s_c21 = matrix2.get(2, 1); - final long s_c31 = matrix2.get(3, 1); - final long s_c02 = matrix2.get(0, 2); - final long s_c12 = matrix2.get(1, 2); - final long s_c22 = matrix2.get(2, 2); - final long s_c32 = matrix2.get(3, 2); - final long s_c03 = matrix2.get(0, 3); - final long s_c13 = matrix2.get(1, 3); - final long s_c23 = matrix2.get(2, 3); - final long s_c33 = matrix2.get(3, 3); - final long s_c04 = matrix2.get(0, 4); - final long s_c14 = matrix2.get(1, 4); - final long s_c24 = matrix2.get(2, 4); - final long s_c34 = matrix2.get(3, 4); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33 + f_c40*s_c34); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33 + f_c41*s_c34); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long f30 = matrix1.get(3, 0); + final long f40 = matrix1.get(4, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f21 = matrix1.get(2, 1); + final long f31 = matrix1.get(3, 1); + final long f41 = matrix1.get(4, 1); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + final long s30 = matrix2.get(3, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s21 = matrix2.get(2, 1); + final long s31 = matrix2.get(3, 1); + final long s02 = matrix2.get(0, 2); + final long s12 = matrix2.get(1, 2); + final long s22 = matrix2.get(2, 2); + final long s32 = matrix2.get(3, 2); + final long s03 = matrix2.get(0, 3); + final long s13 = matrix2.get(1, 3); + final long s23 = matrix2.get(2, 3); + final long s33 = matrix2.get(3, 3); + final long s04 = matrix2.get(0, 4); + final long s14 = matrix2.get(1, 4); + final long s24 = matrix2.get(2, 4); + final long s34 = matrix2.get(3, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33 + f40 * s34); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33 + f41 * s34); return output; } private static IMatrixSetterLong multiplyMatrix2x5x5(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final long f_c00 = matrix1.get(0, 0); - final long f_c10 = matrix1.get(1, 0); - final long f_c20 = matrix1.get(2, 0); - final long f_c30 = matrix1.get(3, 0); - final long f_c40 = matrix1.get(4, 0); - final long f_c01 = matrix1.get(0, 1); - final long f_c11 = matrix1.get(1, 1); - final long f_c21 = matrix1.get(2, 1); - final long f_c31 = matrix1.get(3, 1); - final long f_c41 = matrix1.get(4, 1); - final long s_c00 = matrix2.get(0, 0); - final long s_c10 = matrix2.get(1, 0); - final long s_c20 = matrix2.get(2, 0); - final long s_c30 = matrix2.get(3, 0); - final long s_c40 = matrix2.get(4, 0); - final long s_c01 = matrix2.get(0, 1); - final long s_c11 = matrix2.get(1, 1); - final long s_c21 = matrix2.get(2, 1); - final long s_c31 = matrix2.get(3, 1); - final long s_c41 = matrix2.get(4, 1); - final long s_c02 = matrix2.get(0, 2); - final long s_c12 = matrix2.get(1, 2); - final long s_c22 = matrix2.get(2, 2); - final long s_c32 = matrix2.get(3, 2); - final long s_c42 = matrix2.get(4, 2); - final long s_c03 = matrix2.get(0, 3); - final long s_c13 = matrix2.get(1, 3); - final long s_c23 = matrix2.get(2, 3); - final long s_c33 = matrix2.get(3, 3); - final long s_c43 = matrix2.get(4, 3); - final long s_c04 = matrix2.get(0, 4); - final long s_c14 = matrix2.get(1, 4); - final long s_c24 = matrix2.get(2, 4); - final long s_c34 = matrix2.get(3, 4); - final long s_c44 = matrix2.get(4, 4); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33 + f_c40*s_c34); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33 + f_c41*s_c34); - output.set(4, 0, f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42 + f_c30*s_c43 + f_c40*s_c44); - output.set(4, 1, f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42 + f_c31*s_c43 + f_c41*s_c44); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long f30 = matrix1.get(3, 0); + final long f40 = matrix1.get(4, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f21 = matrix1.get(2, 1); + final long f31 = matrix1.get(3, 1); + final long f41 = matrix1.get(4, 1); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + final long s30 = matrix2.get(3, 0); + final long s40 = matrix2.get(4, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s21 = matrix2.get(2, 1); + final long s31 = matrix2.get(3, 1); + final long s41 = matrix2.get(4, 1); + final long s02 = matrix2.get(0, 2); + final long s12 = matrix2.get(1, 2); + final long s22 = matrix2.get(2, 2); + final long s32 = matrix2.get(3, 2); + final long s42 = matrix2.get(4, 2); + final long s03 = matrix2.get(0, 3); + final long s13 = matrix2.get(1, 3); + final long s23 = matrix2.get(2, 3); + final long s33 = matrix2.get(3, 3); + final long s43 = matrix2.get(4, 3); + final long s04 = matrix2.get(0, 4); + final long s14 = matrix2.get(1, 4); + final long s24 = matrix2.get(2, 4); + final long s34 = matrix2.get(3, 4); + final long s44 = matrix2.get(4, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33 + f40 * s34); + output.set(4, 0, f00 * s40 + f10 * s41 + f20 * s42 + f30 * s43 + f40 * s44); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33 + f41 * s34); + output.set(4, 1, f01 * s40 + f11 * s41 + f21 * s42 + f31 * s43 + f41 * s44); + return output; + } + + private static IMatrixSetterLong multiplyMatrix3x5x1(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long f30 = matrix1.get(3, 0); + final long f40 = matrix1.get(4, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f21 = matrix1.get(2, 1); + final long f31 = matrix1.get(3, 1); + final long f41 = matrix1.get(4, 1); + final long f02 = matrix1.get(0, 2); + final long f12 = matrix1.get(1, 2); + final long f22 = matrix1.get(2, 2); + final long f32 = matrix1.get(3, 2); + final long f42 = matrix1.get(4, 2); + final long s00 = matrix2.get(0, 0); + final long s01 = matrix2.get(0, 1); + final long s02 = matrix2.get(0, 2); + final long s03 = matrix2.get(0, 3); + final long s04 = matrix2.get(0, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04); return output; } private static IMatrixSetterLong multiplyMatrix3x5x2(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final long f_c00 = matrix1.get(0, 0); - final long f_c10 = matrix1.get(1, 0); - final long f_c20 = matrix1.get(2, 0); - final long f_c30 = matrix1.get(3, 0); - final long f_c40 = matrix1.get(4, 0); - final long f_c01 = matrix1.get(0, 1); - final long f_c11 = matrix1.get(1, 1); - final long f_c21 = matrix1.get(2, 1); - final long f_c31 = matrix1.get(3, 1); - final long f_c41 = matrix1.get(4, 1); - final long f_c02 = matrix1.get(0, 2); - final long f_c12 = matrix1.get(1, 2); - final long f_c22 = matrix1.get(2, 2); - final long f_c32 = matrix1.get(3, 2); - final long f_c42 = matrix1.get(4, 2); - final long s_c00 = matrix2.get(0, 0); - final long s_c10 = matrix2.get(1, 0); - final long s_c01 = matrix2.get(0, 1); - final long s_c11 = matrix2.get(1, 1); - final long s_c02 = matrix2.get(0, 2); - final long s_c12 = matrix2.get(1, 2); - final long s_c03 = matrix2.get(0, 3); - final long s_c13 = matrix2.get(1, 3); - final long s_c04 = matrix2.get(0, 4); - final long s_c14 = matrix2.get(1, 4); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long f30 = matrix1.get(3, 0); + final long f40 = matrix1.get(4, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f21 = matrix1.get(2, 1); + final long f31 = matrix1.get(3, 1); + final long f41 = matrix1.get(4, 1); + final long f02 = matrix1.get(0, 2); + final long f12 = matrix1.get(1, 2); + final long f22 = matrix1.get(2, 2); + final long f32 = matrix1.get(3, 2); + final long f42 = matrix1.get(4, 2); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s02 = matrix2.get(0, 2); + final long s12 = matrix2.get(1, 2); + final long s03 = matrix2.get(0, 3); + final long s13 = matrix2.get(1, 3); + final long s04 = matrix2.get(0, 4); + final long s14 = matrix2.get(1, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14); return output; } private static IMatrixSetterLong multiplyMatrix3x5x3(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final long f_c00 = matrix1.get(0, 0); - final long f_c10 = matrix1.get(1, 0); - final long f_c20 = matrix1.get(2, 0); - final long f_c30 = matrix1.get(3, 0); - final long f_c40 = matrix1.get(4, 0); - final long f_c01 = matrix1.get(0, 1); - final long f_c11 = matrix1.get(1, 1); - final long f_c21 = matrix1.get(2, 1); - final long f_c31 = matrix1.get(3, 1); - final long f_c41 = matrix1.get(4, 1); - final long f_c02 = matrix1.get(0, 2); - final long f_c12 = matrix1.get(1, 2); - final long f_c22 = matrix1.get(2, 2); - final long f_c32 = matrix1.get(3, 2); - final long f_c42 = matrix1.get(4, 2); - final long s_c00 = matrix2.get(0, 0); - final long s_c10 = matrix2.get(1, 0); - final long s_c20 = matrix2.get(2, 0); - final long s_c01 = matrix2.get(0, 1); - final long s_c11 = matrix2.get(1, 1); - final long s_c21 = matrix2.get(2, 1); - final long s_c02 = matrix2.get(0, 2); - final long s_c12 = matrix2.get(1, 2); - final long s_c22 = matrix2.get(2, 2); - final long s_c03 = matrix2.get(0, 3); - final long s_c13 = matrix2.get(1, 3); - final long s_c23 = matrix2.get(2, 3); - final long s_c04 = matrix2.get(0, 4); - final long s_c14 = matrix2.get(1, 4); - final long s_c24 = matrix2.get(2, 4); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23 + f_c42*s_c24); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long f30 = matrix1.get(3, 0); + final long f40 = matrix1.get(4, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f21 = matrix1.get(2, 1); + final long f31 = matrix1.get(3, 1); + final long f41 = matrix1.get(4, 1); + final long f02 = matrix1.get(0, 2); + final long f12 = matrix1.get(1, 2); + final long f22 = matrix1.get(2, 2); + final long f32 = matrix1.get(3, 2); + final long f42 = matrix1.get(4, 2); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s21 = matrix2.get(2, 1); + final long s02 = matrix2.get(0, 2); + final long s12 = matrix2.get(1, 2); + final long s22 = matrix2.get(2, 2); + final long s03 = matrix2.get(0, 3); + final long s13 = matrix2.get(1, 3); + final long s23 = matrix2.get(2, 3); + final long s04 = matrix2.get(0, 4); + final long s14 = matrix2.get(1, 4); + final long s24 = matrix2.get(2, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23 + f42 * s24); return output; } private static IMatrixSetterLong multiplyMatrix3x5x4(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final long f_c00 = matrix1.get(0, 0); - final long f_c10 = matrix1.get(1, 0); - final long f_c20 = matrix1.get(2, 0); - final long f_c30 = matrix1.get(3, 0); - final long f_c40 = matrix1.get(4, 0); - final long f_c01 = matrix1.get(0, 1); - final long f_c11 = matrix1.get(1, 1); - final long f_c21 = matrix1.get(2, 1); - final long f_c31 = matrix1.get(3, 1); - final long f_c41 = matrix1.get(4, 1); - final long f_c02 = matrix1.get(0, 2); - final long f_c12 = matrix1.get(1, 2); - final long f_c22 = matrix1.get(2, 2); - final long f_c32 = matrix1.get(3, 2); - final long f_c42 = matrix1.get(4, 2); - final long s_c00 = matrix2.get(0, 0); - final long s_c10 = matrix2.get(1, 0); - final long s_c20 = matrix2.get(2, 0); - final long s_c30 = matrix2.get(3, 0); - final long s_c01 = matrix2.get(0, 1); - final long s_c11 = matrix2.get(1, 1); - final long s_c21 = matrix2.get(2, 1); - final long s_c31 = matrix2.get(3, 1); - final long s_c02 = matrix2.get(0, 2); - final long s_c12 = matrix2.get(1, 2); - final long s_c22 = matrix2.get(2, 2); - final long s_c32 = matrix2.get(3, 2); - final long s_c03 = matrix2.get(0, 3); - final long s_c13 = matrix2.get(1, 3); - final long s_c23 = matrix2.get(2, 3); - final long s_c33 = matrix2.get(3, 3); - final long s_c04 = matrix2.get(0, 4); - final long s_c14 = matrix2.get(1, 4); - final long s_c24 = matrix2.get(2, 4); - final long s_c34 = matrix2.get(3, 4); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23 + f_c42*s_c24); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33 + f_c40*s_c34); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33 + f_c41*s_c34); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33 + f_c42*s_c34); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long f30 = matrix1.get(3, 0); + final long f40 = matrix1.get(4, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f21 = matrix1.get(2, 1); + final long f31 = matrix1.get(3, 1); + final long f41 = matrix1.get(4, 1); + final long f02 = matrix1.get(0, 2); + final long f12 = matrix1.get(1, 2); + final long f22 = matrix1.get(2, 2); + final long f32 = matrix1.get(3, 2); + final long f42 = matrix1.get(4, 2); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + final long s30 = matrix2.get(3, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s21 = matrix2.get(2, 1); + final long s31 = matrix2.get(3, 1); + final long s02 = matrix2.get(0, 2); + final long s12 = matrix2.get(1, 2); + final long s22 = matrix2.get(2, 2); + final long s32 = matrix2.get(3, 2); + final long s03 = matrix2.get(0, 3); + final long s13 = matrix2.get(1, 3); + final long s23 = matrix2.get(2, 3); + final long s33 = matrix2.get(3, 3); + final long s04 = matrix2.get(0, 4); + final long s14 = matrix2.get(1, 4); + final long s24 = matrix2.get(2, 4); + final long s34 = matrix2.get(3, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33 + f40 * s34); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33 + f41 * s34); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23 + f42 * s24); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33 + f42 * s34); return output; } private static IMatrixSetterLong multiplyMatrix3x5x5(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final long f_c00 = matrix1.get(0, 0); - final long f_c10 = matrix1.get(1, 0); - final long f_c20 = matrix1.get(2, 0); - final long f_c30 = matrix1.get(3, 0); - final long f_c40 = matrix1.get(4, 0); - final long f_c01 = matrix1.get(0, 1); - final long f_c11 = matrix1.get(1, 1); - final long f_c21 = matrix1.get(2, 1); - final long f_c31 = matrix1.get(3, 1); - final long f_c41 = matrix1.get(4, 1); - final long f_c02 = matrix1.get(0, 2); - final long f_c12 = matrix1.get(1, 2); - final long f_c22 = matrix1.get(2, 2); - final long f_c32 = matrix1.get(3, 2); - final long f_c42 = matrix1.get(4, 2); - final long s_c00 = matrix2.get(0, 0); - final long s_c10 = matrix2.get(1, 0); - final long s_c20 = matrix2.get(2, 0); - final long s_c30 = matrix2.get(3, 0); - final long s_c40 = matrix2.get(4, 0); - final long s_c01 = matrix2.get(0, 1); - final long s_c11 = matrix2.get(1, 1); - final long s_c21 = matrix2.get(2, 1); - final long s_c31 = matrix2.get(3, 1); - final long s_c41 = matrix2.get(4, 1); - final long s_c02 = matrix2.get(0, 2); - final long s_c12 = matrix2.get(1, 2); - final long s_c22 = matrix2.get(2, 2); - final long s_c32 = matrix2.get(3, 2); - final long s_c42 = matrix2.get(4, 2); - final long s_c03 = matrix2.get(0, 3); - final long s_c13 = matrix2.get(1, 3); - final long s_c23 = matrix2.get(2, 3); - final long s_c33 = matrix2.get(3, 3); - final long s_c43 = matrix2.get(4, 3); - final long s_c04 = matrix2.get(0, 4); - final long s_c14 = matrix2.get(1, 4); - final long s_c24 = matrix2.get(2, 4); - final long s_c34 = matrix2.get(3, 4); - final long s_c44 = matrix2.get(4, 4); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23 + f_c42*s_c24); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33 + f_c40*s_c34); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33 + f_c41*s_c34); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33 + f_c42*s_c34); - output.set(4, 0, f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42 + f_c30*s_c43 + f_c40*s_c44); - output.set(4, 1, f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42 + f_c31*s_c43 + f_c41*s_c44); - output.set(4, 2, f_c02*s_c40 + f_c12*s_c41 + f_c22*s_c42 + f_c32*s_c43 + f_c42*s_c44); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long f30 = matrix1.get(3, 0); + final long f40 = matrix1.get(4, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f21 = matrix1.get(2, 1); + final long f31 = matrix1.get(3, 1); + final long f41 = matrix1.get(4, 1); + final long f02 = matrix1.get(0, 2); + final long f12 = matrix1.get(1, 2); + final long f22 = matrix1.get(2, 2); + final long f32 = matrix1.get(3, 2); + final long f42 = matrix1.get(4, 2); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + final long s30 = matrix2.get(3, 0); + final long s40 = matrix2.get(4, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s21 = matrix2.get(2, 1); + final long s31 = matrix2.get(3, 1); + final long s41 = matrix2.get(4, 1); + final long s02 = matrix2.get(0, 2); + final long s12 = matrix2.get(1, 2); + final long s22 = matrix2.get(2, 2); + final long s32 = matrix2.get(3, 2); + final long s42 = matrix2.get(4, 2); + final long s03 = matrix2.get(0, 3); + final long s13 = matrix2.get(1, 3); + final long s23 = matrix2.get(2, 3); + final long s33 = matrix2.get(3, 3); + final long s43 = matrix2.get(4, 3); + final long s04 = matrix2.get(0, 4); + final long s14 = matrix2.get(1, 4); + final long s24 = matrix2.get(2, 4); + final long s34 = matrix2.get(3, 4); + final long s44 = matrix2.get(4, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33 + f40 * s34); + output.set(4, 0, f00 * s40 + f10 * s41 + f20 * s42 + f30 * s43 + f40 * s44); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33 + f41 * s34); + output.set(4, 1, f01 * s40 + f11 * s41 + f21 * s42 + f31 * s43 + f41 * s44); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23 + f42 * s24); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33 + f42 * s34); + output.set(4, 2, f02 * s40 + f12 * s41 + f22 * s42 + f32 * s43 + f42 * s44); + return output; + } + + private static IMatrixSetterLong multiplyMatrix4x5x1(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long f30 = matrix1.get(3, 0); + final long f40 = matrix1.get(4, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f21 = matrix1.get(2, 1); + final long f31 = matrix1.get(3, 1); + final long f41 = matrix1.get(4, 1); + final long f02 = matrix1.get(0, 2); + final long f12 = matrix1.get(1, 2); + final long f22 = matrix1.get(2, 2); + final long f32 = matrix1.get(3, 2); + final long f42 = matrix1.get(4, 2); + final long f03 = matrix1.get(0, 3); + final long f13 = matrix1.get(1, 3); + final long f23 = matrix1.get(2, 3); + final long f33 = matrix1.get(3, 3); + final long f43 = matrix1.get(4, 3); + final long s00 = matrix2.get(0, 0); + final long s01 = matrix2.get(0, 1); + final long s02 = matrix2.get(0, 2); + final long s03 = matrix2.get(0, 3); + final long s04 = matrix2.get(0, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03 + f43 * s04); return output; } private static IMatrixSetterLong multiplyMatrix4x5x2(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final long f_c00 = matrix1.get(0, 0); - final long f_c10 = matrix1.get(1, 0); - final long f_c20 = matrix1.get(2, 0); - final long f_c30 = matrix1.get(3, 0); - final long f_c40 = matrix1.get(4, 0); - final long f_c01 = matrix1.get(0, 1); - final long f_c11 = matrix1.get(1, 1); - final long f_c21 = matrix1.get(2, 1); - final long f_c31 = matrix1.get(3, 1); - final long f_c41 = matrix1.get(4, 1); - final long f_c02 = matrix1.get(0, 2); - final long f_c12 = matrix1.get(1, 2); - final long f_c22 = matrix1.get(2, 2); - final long f_c32 = matrix1.get(3, 2); - final long f_c42 = matrix1.get(4, 2); - final long f_c03 = matrix1.get(0, 3); - final long f_c13 = matrix1.get(1, 3); - final long f_c23 = matrix1.get(2, 3); - final long f_c33 = matrix1.get(3, 3); - final long f_c43 = matrix1.get(4, 3); - final long s_c00 = matrix2.get(0, 0); - final long s_c10 = matrix2.get(1, 0); - final long s_c01 = matrix2.get(0, 1); - final long s_c11 = matrix2.get(1, 1); - final long s_c02 = matrix2.get(0, 2); - final long s_c12 = matrix2.get(1, 2); - final long s_c03 = matrix2.get(0, 3); - final long s_c13 = matrix2.get(1, 3); - final long s_c04 = matrix2.get(0, 4); - final long s_c14 = matrix2.get(1, 4); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03 + f_c43*s_c04); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13 + f_c43*s_c14); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long f30 = matrix1.get(3, 0); + final long f40 = matrix1.get(4, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f21 = matrix1.get(2, 1); + final long f31 = matrix1.get(3, 1); + final long f41 = matrix1.get(4, 1); + final long f02 = matrix1.get(0, 2); + final long f12 = matrix1.get(1, 2); + final long f22 = matrix1.get(2, 2); + final long f32 = matrix1.get(3, 2); + final long f42 = matrix1.get(4, 2); + final long f03 = matrix1.get(0, 3); + final long f13 = matrix1.get(1, 3); + final long f23 = matrix1.get(2, 3); + final long f33 = matrix1.get(3, 3); + final long f43 = matrix1.get(4, 3); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s02 = matrix2.get(0, 2); + final long s12 = matrix2.get(1, 2); + final long s03 = matrix2.get(0, 3); + final long s13 = matrix2.get(1, 3); + final long s04 = matrix2.get(0, 4); + final long s14 = matrix2.get(1, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03 + f43 * s04); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13 + f43 * s14); return output; } private static IMatrixSetterLong multiplyMatrix4x5x3(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final long f_c00 = matrix1.get(0, 0); - final long f_c10 = matrix1.get(1, 0); - final long f_c20 = matrix1.get(2, 0); - final long f_c30 = matrix1.get(3, 0); - final long f_c40 = matrix1.get(4, 0); - final long f_c01 = matrix1.get(0, 1); - final long f_c11 = matrix1.get(1, 1); - final long f_c21 = matrix1.get(2, 1); - final long f_c31 = matrix1.get(3, 1); - final long f_c41 = matrix1.get(4, 1); - final long f_c02 = matrix1.get(0, 2); - final long f_c12 = matrix1.get(1, 2); - final long f_c22 = matrix1.get(2, 2); - final long f_c32 = matrix1.get(3, 2); - final long f_c42 = matrix1.get(4, 2); - final long f_c03 = matrix1.get(0, 3); - final long f_c13 = matrix1.get(1, 3); - final long f_c23 = matrix1.get(2, 3); - final long f_c33 = matrix1.get(3, 3); - final long f_c43 = matrix1.get(4, 3); - final long s_c00 = matrix2.get(0, 0); - final long s_c10 = matrix2.get(1, 0); - final long s_c20 = matrix2.get(2, 0); - final long s_c01 = matrix2.get(0, 1); - final long s_c11 = matrix2.get(1, 1); - final long s_c21 = matrix2.get(2, 1); - final long s_c02 = matrix2.get(0, 2); - final long s_c12 = matrix2.get(1, 2); - final long s_c22 = matrix2.get(2, 2); - final long s_c03 = matrix2.get(0, 3); - final long s_c13 = matrix2.get(1, 3); - final long s_c23 = matrix2.get(2, 3); - final long s_c04 = matrix2.get(0, 4); - final long s_c14 = matrix2.get(1, 4); - final long s_c24 = matrix2.get(2, 4); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03 + f_c43*s_c04); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13 + f_c43*s_c14); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23 + f_c42*s_c24); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23 + f_c43*s_c24); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long f30 = matrix1.get(3, 0); + final long f40 = matrix1.get(4, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f21 = matrix1.get(2, 1); + final long f31 = matrix1.get(3, 1); + final long f41 = matrix1.get(4, 1); + final long f02 = matrix1.get(0, 2); + final long f12 = matrix1.get(1, 2); + final long f22 = matrix1.get(2, 2); + final long f32 = matrix1.get(3, 2); + final long f42 = matrix1.get(4, 2); + final long f03 = matrix1.get(0, 3); + final long f13 = matrix1.get(1, 3); + final long f23 = matrix1.get(2, 3); + final long f33 = matrix1.get(3, 3); + final long f43 = matrix1.get(4, 3); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s21 = matrix2.get(2, 1); + final long s02 = matrix2.get(0, 2); + final long s12 = matrix2.get(1, 2); + final long s22 = matrix2.get(2, 2); + final long s03 = matrix2.get(0, 3); + final long s13 = matrix2.get(1, 3); + final long s23 = matrix2.get(2, 3); + final long s04 = matrix2.get(0, 4); + final long s14 = matrix2.get(1, 4); + final long s24 = matrix2.get(2, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23 + f42 * s24); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03 + f43 * s04); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13 + f43 * s14); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23 + f43 * s24); return output; } private static IMatrixSetterLong multiplyMatrix4x5x4(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final long f_c00 = matrix1.get(0, 0); - final long f_c10 = matrix1.get(1, 0); - final long f_c20 = matrix1.get(2, 0); - final long f_c30 = matrix1.get(3, 0); - final long f_c40 = matrix1.get(4, 0); - final long f_c01 = matrix1.get(0, 1); - final long f_c11 = matrix1.get(1, 1); - final long f_c21 = matrix1.get(2, 1); - final long f_c31 = matrix1.get(3, 1); - final long f_c41 = matrix1.get(4, 1); - final long f_c02 = matrix1.get(0, 2); - final long f_c12 = matrix1.get(1, 2); - final long f_c22 = matrix1.get(2, 2); - final long f_c32 = matrix1.get(3, 2); - final long f_c42 = matrix1.get(4, 2); - final long f_c03 = matrix1.get(0, 3); - final long f_c13 = matrix1.get(1, 3); - final long f_c23 = matrix1.get(2, 3); - final long f_c33 = matrix1.get(3, 3); - final long f_c43 = matrix1.get(4, 3); - final long s_c00 = matrix2.get(0, 0); - final long s_c10 = matrix2.get(1, 0); - final long s_c20 = matrix2.get(2, 0); - final long s_c30 = matrix2.get(3, 0); - final long s_c01 = matrix2.get(0, 1); - final long s_c11 = matrix2.get(1, 1); - final long s_c21 = matrix2.get(2, 1); - final long s_c31 = matrix2.get(3, 1); - final long s_c02 = matrix2.get(0, 2); - final long s_c12 = matrix2.get(1, 2); - final long s_c22 = matrix2.get(2, 2); - final long s_c32 = matrix2.get(3, 2); - final long s_c03 = matrix2.get(0, 3); - final long s_c13 = matrix2.get(1, 3); - final long s_c23 = matrix2.get(2, 3); - final long s_c33 = matrix2.get(3, 3); - final long s_c04 = matrix2.get(0, 4); - final long s_c14 = matrix2.get(1, 4); - final long s_c24 = matrix2.get(2, 4); - final long s_c34 = matrix2.get(3, 4); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03 + f_c43*s_c04); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13 + f_c43*s_c14); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23 + f_c42*s_c24); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23 + f_c43*s_c24); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33 + f_c40*s_c34); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33 + f_c41*s_c34); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33 + f_c42*s_c34); - output.set(3, 3, f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32 + f_c33*s_c33 + f_c43*s_c34); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long f30 = matrix1.get(3, 0); + final long f40 = matrix1.get(4, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f21 = matrix1.get(2, 1); + final long f31 = matrix1.get(3, 1); + final long f41 = matrix1.get(4, 1); + final long f02 = matrix1.get(0, 2); + final long f12 = matrix1.get(1, 2); + final long f22 = matrix1.get(2, 2); + final long f32 = matrix1.get(3, 2); + final long f42 = matrix1.get(4, 2); + final long f03 = matrix1.get(0, 3); + final long f13 = matrix1.get(1, 3); + final long f23 = matrix1.get(2, 3); + final long f33 = matrix1.get(3, 3); + final long f43 = matrix1.get(4, 3); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + final long s30 = matrix2.get(3, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s21 = matrix2.get(2, 1); + final long s31 = matrix2.get(3, 1); + final long s02 = matrix2.get(0, 2); + final long s12 = matrix2.get(1, 2); + final long s22 = matrix2.get(2, 2); + final long s32 = matrix2.get(3, 2); + final long s03 = matrix2.get(0, 3); + final long s13 = matrix2.get(1, 3); + final long s23 = matrix2.get(2, 3); + final long s33 = matrix2.get(3, 3); + final long s04 = matrix2.get(0, 4); + final long s14 = matrix2.get(1, 4); + final long s24 = matrix2.get(2, 4); + final long s34 = matrix2.get(3, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33 + f40 * s34); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33 + f41 * s34); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23 + f42 * s24); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33 + f42 * s34); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03 + f43 * s04); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13 + f43 * s14); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23 + f43 * s24); + output.set(3, 3, f03 * s30 + f13 * s31 + f23 * s32 + f33 * s33 + f43 * s34); return output; } private static IMatrixSetterLong multiplyMatrix4x5x5(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final long f_c00 = matrix1.get(0, 0); - final long f_c10 = matrix1.get(1, 0); - final long f_c20 = matrix1.get(2, 0); - final long f_c30 = matrix1.get(3, 0); - final long f_c40 = matrix1.get(4, 0); - final long f_c01 = matrix1.get(0, 1); - final long f_c11 = matrix1.get(1, 1); - final long f_c21 = matrix1.get(2, 1); - final long f_c31 = matrix1.get(3, 1); - final long f_c41 = matrix1.get(4, 1); - final long f_c02 = matrix1.get(0, 2); - final long f_c12 = matrix1.get(1, 2); - final long f_c22 = matrix1.get(2, 2); - final long f_c32 = matrix1.get(3, 2); - final long f_c42 = matrix1.get(4, 2); - final long f_c03 = matrix1.get(0, 3); - final long f_c13 = matrix1.get(1, 3); - final long f_c23 = matrix1.get(2, 3); - final long f_c33 = matrix1.get(3, 3); - final long f_c43 = matrix1.get(4, 3); - final long s_c00 = matrix2.get(0, 0); - final long s_c10 = matrix2.get(1, 0); - final long s_c20 = matrix2.get(2, 0); - final long s_c30 = matrix2.get(3, 0); - final long s_c40 = matrix2.get(4, 0); - final long s_c01 = matrix2.get(0, 1); - final long s_c11 = matrix2.get(1, 1); - final long s_c21 = matrix2.get(2, 1); - final long s_c31 = matrix2.get(3, 1); - final long s_c41 = matrix2.get(4, 1); - final long s_c02 = matrix2.get(0, 2); - final long s_c12 = matrix2.get(1, 2); - final long s_c22 = matrix2.get(2, 2); - final long s_c32 = matrix2.get(3, 2); - final long s_c42 = matrix2.get(4, 2); - final long s_c03 = matrix2.get(0, 3); - final long s_c13 = matrix2.get(1, 3); - final long s_c23 = matrix2.get(2, 3); - final long s_c33 = matrix2.get(3, 3); - final long s_c43 = matrix2.get(4, 3); - final long s_c04 = matrix2.get(0, 4); - final long s_c14 = matrix2.get(1, 4); - final long s_c24 = matrix2.get(2, 4); - final long s_c34 = matrix2.get(3, 4); - final long s_c44 = matrix2.get(4, 4); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03 + f_c43*s_c04); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13 + f_c43*s_c14); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23 + f_c42*s_c24); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23 + f_c43*s_c24); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33 + f_c40*s_c34); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33 + f_c41*s_c34); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33 + f_c42*s_c34); - output.set(3, 3, f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32 + f_c33*s_c33 + f_c43*s_c34); - output.set(4, 0, f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42 + f_c30*s_c43 + f_c40*s_c44); - output.set(4, 1, f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42 + f_c31*s_c43 + f_c41*s_c44); - output.set(4, 2, f_c02*s_c40 + f_c12*s_c41 + f_c22*s_c42 + f_c32*s_c43 + f_c42*s_c44); - output.set(4, 3, f_c03*s_c40 + f_c13*s_c41 + f_c23*s_c42 + f_c33*s_c43 + f_c43*s_c44); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long f30 = matrix1.get(3, 0); + final long f40 = matrix1.get(4, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f21 = matrix1.get(2, 1); + final long f31 = matrix1.get(3, 1); + final long f41 = matrix1.get(4, 1); + final long f02 = matrix1.get(0, 2); + final long f12 = matrix1.get(1, 2); + final long f22 = matrix1.get(2, 2); + final long f32 = matrix1.get(3, 2); + final long f42 = matrix1.get(4, 2); + final long f03 = matrix1.get(0, 3); + final long f13 = matrix1.get(1, 3); + final long f23 = matrix1.get(2, 3); + final long f33 = matrix1.get(3, 3); + final long f43 = matrix1.get(4, 3); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + final long s30 = matrix2.get(3, 0); + final long s40 = matrix2.get(4, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s21 = matrix2.get(2, 1); + final long s31 = matrix2.get(3, 1); + final long s41 = matrix2.get(4, 1); + final long s02 = matrix2.get(0, 2); + final long s12 = matrix2.get(1, 2); + final long s22 = matrix2.get(2, 2); + final long s32 = matrix2.get(3, 2); + final long s42 = matrix2.get(4, 2); + final long s03 = matrix2.get(0, 3); + final long s13 = matrix2.get(1, 3); + final long s23 = matrix2.get(2, 3); + final long s33 = matrix2.get(3, 3); + final long s43 = matrix2.get(4, 3); + final long s04 = matrix2.get(0, 4); + final long s14 = matrix2.get(1, 4); + final long s24 = matrix2.get(2, 4); + final long s34 = matrix2.get(3, 4); + final long s44 = matrix2.get(4, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33 + f40 * s34); + output.set(4, 0, f00 * s40 + f10 * s41 + f20 * s42 + f30 * s43 + f40 * s44); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33 + f41 * s34); + output.set(4, 1, f01 * s40 + f11 * s41 + f21 * s42 + f31 * s43 + f41 * s44); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23 + f42 * s24); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33 + f42 * s34); + output.set(4, 2, f02 * s40 + f12 * s41 + f22 * s42 + f32 * s43 + f42 * s44); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03 + f43 * s04); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13 + f43 * s14); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23 + f43 * s24); + output.set(3, 3, f03 * s30 + f13 * s31 + f23 * s32 + f33 * s33 + f43 * s34); + output.set(4, 3, f03 * s40 + f13 * s41 + f23 * s42 + f33 * s43 + f43 * s44); + return output; + } + + private static IMatrixSetterLong multiplyMatrix5x5x1(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long f30 = matrix1.get(3, 0); + final long f40 = matrix1.get(4, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f21 = matrix1.get(2, 1); + final long f31 = matrix1.get(3, 1); + final long f41 = matrix1.get(4, 1); + final long f02 = matrix1.get(0, 2); + final long f12 = matrix1.get(1, 2); + final long f22 = matrix1.get(2, 2); + final long f32 = matrix1.get(3, 2); + final long f42 = matrix1.get(4, 2); + final long f03 = matrix1.get(0, 3); + final long f13 = matrix1.get(1, 3); + final long f23 = matrix1.get(2, 3); + final long f33 = matrix1.get(3, 3); + final long f43 = matrix1.get(4, 3); + final long f04 = matrix1.get(0, 4); + final long f14 = matrix1.get(1, 4); + final long f24 = matrix1.get(2, 4); + final long f34 = matrix1.get(3, 4); + final long f44 = matrix1.get(4, 4); + final long s00 = matrix2.get(0, 0); + final long s01 = matrix2.get(0, 1); + final long s02 = matrix2.get(0, 2); + final long s03 = matrix2.get(0, 3); + final long s04 = matrix2.get(0, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03 + f43 * s04); + output.set(0, 4, f04 * s00 + f14 * s01 + f24 * s02 + f34 * s03 + f44 * s04); return output; } private static IMatrixSetterLong multiplyMatrix5x5x2(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final long f_c00 = matrix1.get(0, 0); - final long f_c10 = matrix1.get(1, 0); - final long f_c20 = matrix1.get(2, 0); - final long f_c30 = matrix1.get(3, 0); - final long f_c40 = matrix1.get(4, 0); - final long f_c01 = matrix1.get(0, 1); - final long f_c11 = matrix1.get(1, 1); - final long f_c21 = matrix1.get(2, 1); - final long f_c31 = matrix1.get(3, 1); - final long f_c41 = matrix1.get(4, 1); - final long f_c02 = matrix1.get(0, 2); - final long f_c12 = matrix1.get(1, 2); - final long f_c22 = matrix1.get(2, 2); - final long f_c32 = matrix1.get(3, 2); - final long f_c42 = matrix1.get(4, 2); - final long f_c03 = matrix1.get(0, 3); - final long f_c13 = matrix1.get(1, 3); - final long f_c23 = matrix1.get(2, 3); - final long f_c33 = matrix1.get(3, 3); - final long f_c43 = matrix1.get(4, 3); - final long f_c04 = matrix1.get(0, 4); - final long f_c14 = matrix1.get(1, 4); - final long f_c24 = matrix1.get(2, 4); - final long f_c34 = matrix1.get(3, 4); - final long f_c44 = matrix1.get(4, 4); - final long s_c00 = matrix2.get(0, 0); - final long s_c10 = matrix2.get(1, 0); - final long s_c01 = matrix2.get(0, 1); - final long s_c11 = matrix2.get(1, 1); - final long s_c02 = matrix2.get(0, 2); - final long s_c12 = matrix2.get(1, 2); - final long s_c03 = matrix2.get(0, 3); - final long s_c13 = matrix2.get(1, 3); - final long s_c04 = matrix2.get(0, 4); - final long s_c14 = matrix2.get(1, 4); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03 + f_c43*s_c04); - output.set(0, 4, f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02 + f_c34*s_c03 + f_c44*s_c04); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13 + f_c43*s_c14); - output.set(1, 4, f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12 + f_c34*s_c13 + f_c44*s_c14); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long f30 = matrix1.get(3, 0); + final long f40 = matrix1.get(4, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f21 = matrix1.get(2, 1); + final long f31 = matrix1.get(3, 1); + final long f41 = matrix1.get(4, 1); + final long f02 = matrix1.get(0, 2); + final long f12 = matrix1.get(1, 2); + final long f22 = matrix1.get(2, 2); + final long f32 = matrix1.get(3, 2); + final long f42 = matrix1.get(4, 2); + final long f03 = matrix1.get(0, 3); + final long f13 = matrix1.get(1, 3); + final long f23 = matrix1.get(2, 3); + final long f33 = matrix1.get(3, 3); + final long f43 = matrix1.get(4, 3); + final long f04 = matrix1.get(0, 4); + final long f14 = matrix1.get(1, 4); + final long f24 = matrix1.get(2, 4); + final long f34 = matrix1.get(3, 4); + final long f44 = matrix1.get(4, 4); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s02 = matrix2.get(0, 2); + final long s12 = matrix2.get(1, 2); + final long s03 = matrix2.get(0, 3); + final long s13 = matrix2.get(1, 3); + final long s04 = matrix2.get(0, 4); + final long s14 = matrix2.get(1, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03 + f43 * s04); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13 + f43 * s14); + output.set(0, 4, f04 * s00 + f14 * s01 + f24 * s02 + f34 * s03 + f44 * s04); + output.set(1, 4, f04 * s10 + f14 * s11 + f24 * s12 + f34 * s13 + f44 * s14); return output; } private static IMatrixSetterLong multiplyMatrix5x5x3(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final long f_c00 = matrix1.get(0, 0); - final long f_c10 = matrix1.get(1, 0); - final long f_c20 = matrix1.get(2, 0); - final long f_c30 = matrix1.get(3, 0); - final long f_c40 = matrix1.get(4, 0); - final long f_c01 = matrix1.get(0, 1); - final long f_c11 = matrix1.get(1, 1); - final long f_c21 = matrix1.get(2, 1); - final long f_c31 = matrix1.get(3, 1); - final long f_c41 = matrix1.get(4, 1); - final long f_c02 = matrix1.get(0, 2); - final long f_c12 = matrix1.get(1, 2); - final long f_c22 = matrix1.get(2, 2); - final long f_c32 = matrix1.get(3, 2); - final long f_c42 = matrix1.get(4, 2); - final long f_c03 = matrix1.get(0, 3); - final long f_c13 = matrix1.get(1, 3); - final long f_c23 = matrix1.get(2, 3); - final long f_c33 = matrix1.get(3, 3); - final long f_c43 = matrix1.get(4, 3); - final long f_c04 = matrix1.get(0, 4); - final long f_c14 = matrix1.get(1, 4); - final long f_c24 = matrix1.get(2, 4); - final long f_c34 = matrix1.get(3, 4); - final long f_c44 = matrix1.get(4, 4); - final long s_c00 = matrix2.get(0, 0); - final long s_c10 = matrix2.get(1, 0); - final long s_c20 = matrix2.get(2, 0); - final long s_c01 = matrix2.get(0, 1); - final long s_c11 = matrix2.get(1, 1); - final long s_c21 = matrix2.get(2, 1); - final long s_c02 = matrix2.get(0, 2); - final long s_c12 = matrix2.get(1, 2); - final long s_c22 = matrix2.get(2, 2); - final long s_c03 = matrix2.get(0, 3); - final long s_c13 = matrix2.get(1, 3); - final long s_c23 = matrix2.get(2, 3); - final long s_c04 = matrix2.get(0, 4); - final long s_c14 = matrix2.get(1, 4); - final long s_c24 = matrix2.get(2, 4); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03 + f_c43*s_c04); - output.set(0, 4, f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02 + f_c34*s_c03 + f_c44*s_c04); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13 + f_c43*s_c14); - output.set(1, 4, f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12 + f_c34*s_c13 + f_c44*s_c14); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23 + f_c42*s_c24); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23 + f_c43*s_c24); - output.set(2, 4, f_c04*s_c20 + f_c14*s_c21 + f_c24*s_c22 + f_c34*s_c23 + f_c44*s_c24); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long f30 = matrix1.get(3, 0); + final long f40 = matrix1.get(4, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f21 = matrix1.get(2, 1); + final long f31 = matrix1.get(3, 1); + final long f41 = matrix1.get(4, 1); + final long f02 = matrix1.get(0, 2); + final long f12 = matrix1.get(1, 2); + final long f22 = matrix1.get(2, 2); + final long f32 = matrix1.get(3, 2); + final long f42 = matrix1.get(4, 2); + final long f03 = matrix1.get(0, 3); + final long f13 = matrix1.get(1, 3); + final long f23 = matrix1.get(2, 3); + final long f33 = matrix1.get(3, 3); + final long f43 = matrix1.get(4, 3); + final long f04 = matrix1.get(0, 4); + final long f14 = matrix1.get(1, 4); + final long f24 = matrix1.get(2, 4); + final long f34 = matrix1.get(3, 4); + final long f44 = matrix1.get(4, 4); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s21 = matrix2.get(2, 1); + final long s02 = matrix2.get(0, 2); + final long s12 = matrix2.get(1, 2); + final long s22 = matrix2.get(2, 2); + final long s03 = matrix2.get(0, 3); + final long s13 = matrix2.get(1, 3); + final long s23 = matrix2.get(2, 3); + final long s04 = matrix2.get(0, 4); + final long s14 = matrix2.get(1, 4); + final long s24 = matrix2.get(2, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23 + f42 * s24); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03 + f43 * s04); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13 + f43 * s14); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23 + f43 * s24); + output.set(0, 4, f04 * s00 + f14 * s01 + f24 * s02 + f34 * s03 + f44 * s04); + output.set(1, 4, f04 * s10 + f14 * s11 + f24 * s12 + f34 * s13 + f44 * s14); + output.set(2, 4, f04 * s20 + f14 * s21 + f24 * s22 + f34 * s23 + f44 * s24); return output; } private static IMatrixSetterLong multiplyMatrix5x5x4(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final long f_c00 = matrix1.get(0, 0); - final long f_c10 = matrix1.get(1, 0); - final long f_c20 = matrix1.get(2, 0); - final long f_c30 = matrix1.get(3, 0); - final long f_c40 = matrix1.get(4, 0); - final long f_c01 = matrix1.get(0, 1); - final long f_c11 = matrix1.get(1, 1); - final long f_c21 = matrix1.get(2, 1); - final long f_c31 = matrix1.get(3, 1); - final long f_c41 = matrix1.get(4, 1); - final long f_c02 = matrix1.get(0, 2); - final long f_c12 = matrix1.get(1, 2); - final long f_c22 = matrix1.get(2, 2); - final long f_c32 = matrix1.get(3, 2); - final long f_c42 = matrix1.get(4, 2); - final long f_c03 = matrix1.get(0, 3); - final long f_c13 = matrix1.get(1, 3); - final long f_c23 = matrix1.get(2, 3); - final long f_c33 = matrix1.get(3, 3); - final long f_c43 = matrix1.get(4, 3); - final long f_c04 = matrix1.get(0, 4); - final long f_c14 = matrix1.get(1, 4); - final long f_c24 = matrix1.get(2, 4); - final long f_c34 = matrix1.get(3, 4); - final long f_c44 = matrix1.get(4, 4); - final long s_c00 = matrix2.get(0, 0); - final long s_c10 = matrix2.get(1, 0); - final long s_c20 = matrix2.get(2, 0); - final long s_c30 = matrix2.get(3, 0); - final long s_c01 = matrix2.get(0, 1); - final long s_c11 = matrix2.get(1, 1); - final long s_c21 = matrix2.get(2, 1); - final long s_c31 = matrix2.get(3, 1); - final long s_c02 = matrix2.get(0, 2); - final long s_c12 = matrix2.get(1, 2); - final long s_c22 = matrix2.get(2, 2); - final long s_c32 = matrix2.get(3, 2); - final long s_c03 = matrix2.get(0, 3); - final long s_c13 = matrix2.get(1, 3); - final long s_c23 = matrix2.get(2, 3); - final long s_c33 = matrix2.get(3, 3); - final long s_c04 = matrix2.get(0, 4); - final long s_c14 = matrix2.get(1, 4); - final long s_c24 = matrix2.get(2, 4); - final long s_c34 = matrix2.get(3, 4); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03 + f_c43*s_c04); - output.set(0, 4, f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02 + f_c34*s_c03 + f_c44*s_c04); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13 + f_c43*s_c14); - output.set(1, 4, f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12 + f_c34*s_c13 + f_c44*s_c14); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23 + f_c42*s_c24); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23 + f_c43*s_c24); - output.set(2, 4, f_c04*s_c20 + f_c14*s_c21 + f_c24*s_c22 + f_c34*s_c23 + f_c44*s_c24); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33 + f_c40*s_c34); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33 + f_c41*s_c34); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33 + f_c42*s_c34); - output.set(3, 3, f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32 + f_c33*s_c33 + f_c43*s_c34); - output.set(3, 4, f_c04*s_c30 + f_c14*s_c31 + f_c24*s_c32 + f_c34*s_c33 + f_c44*s_c34); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long f30 = matrix1.get(3, 0); + final long f40 = matrix1.get(4, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f21 = matrix1.get(2, 1); + final long f31 = matrix1.get(3, 1); + final long f41 = matrix1.get(4, 1); + final long f02 = matrix1.get(0, 2); + final long f12 = matrix1.get(1, 2); + final long f22 = matrix1.get(2, 2); + final long f32 = matrix1.get(3, 2); + final long f42 = matrix1.get(4, 2); + final long f03 = matrix1.get(0, 3); + final long f13 = matrix1.get(1, 3); + final long f23 = matrix1.get(2, 3); + final long f33 = matrix1.get(3, 3); + final long f43 = matrix1.get(4, 3); + final long f04 = matrix1.get(0, 4); + final long f14 = matrix1.get(1, 4); + final long f24 = matrix1.get(2, 4); + final long f34 = matrix1.get(3, 4); + final long f44 = matrix1.get(4, 4); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + final long s30 = matrix2.get(3, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s21 = matrix2.get(2, 1); + final long s31 = matrix2.get(3, 1); + final long s02 = matrix2.get(0, 2); + final long s12 = matrix2.get(1, 2); + final long s22 = matrix2.get(2, 2); + final long s32 = matrix2.get(3, 2); + final long s03 = matrix2.get(0, 3); + final long s13 = matrix2.get(1, 3); + final long s23 = matrix2.get(2, 3); + final long s33 = matrix2.get(3, 3); + final long s04 = matrix2.get(0, 4); + final long s14 = matrix2.get(1, 4); + final long s24 = matrix2.get(2, 4); + final long s34 = matrix2.get(3, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33 + f40 * s34); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33 + f41 * s34); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23 + f42 * s24); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33 + f42 * s34); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03 + f43 * s04); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13 + f43 * s14); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23 + f43 * s24); + output.set(3, 3, f03 * s30 + f13 * s31 + f23 * s32 + f33 * s33 + f43 * s34); + output.set(0, 4, f04 * s00 + f14 * s01 + f24 * s02 + f34 * s03 + f44 * s04); + output.set(1, 4, f04 * s10 + f14 * s11 + f24 * s12 + f34 * s13 + f44 * s14); + output.set(2, 4, f04 * s20 + f14 * s21 + f24 * s22 + f34 * s23 + f44 * s24); + output.set(3, 4, f04 * s30 + f14 * s31 + f24 * s32 + f34 * s33 + f44 * s34); return output; } private static IMatrixSetterLong multiplyMatrix5x5x5(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final long f_c00 = matrix1.get(0, 0); - final long f_c10 = matrix1.get(1, 0); - final long f_c20 = matrix1.get(2, 0); - final long f_c30 = matrix1.get(3, 0); - final long f_c40 = matrix1.get(4, 0); - final long f_c01 = matrix1.get(0, 1); - final long f_c11 = matrix1.get(1, 1); - final long f_c21 = matrix1.get(2, 1); - final long f_c31 = matrix1.get(3, 1); - final long f_c41 = matrix1.get(4, 1); - final long f_c02 = matrix1.get(0, 2); - final long f_c12 = matrix1.get(1, 2); - final long f_c22 = matrix1.get(2, 2); - final long f_c32 = matrix1.get(3, 2); - final long f_c42 = matrix1.get(4, 2); - final long f_c03 = matrix1.get(0, 3); - final long f_c13 = matrix1.get(1, 3); - final long f_c23 = matrix1.get(2, 3); - final long f_c33 = matrix1.get(3, 3); - final long f_c43 = matrix1.get(4, 3); - final long f_c04 = matrix1.get(0, 4); - final long f_c14 = matrix1.get(1, 4); - final long f_c24 = matrix1.get(2, 4); - final long f_c34 = matrix1.get(3, 4); - final long f_c44 = matrix1.get(4, 4); - final long s_c00 = matrix2.get(0, 0); - final long s_c10 = matrix2.get(1, 0); - final long s_c20 = matrix2.get(2, 0); - final long s_c30 = matrix2.get(3, 0); - final long s_c40 = matrix2.get(4, 0); - final long s_c01 = matrix2.get(0, 1); - final long s_c11 = matrix2.get(1, 1); - final long s_c21 = matrix2.get(2, 1); - final long s_c31 = matrix2.get(3, 1); - final long s_c41 = matrix2.get(4, 1); - final long s_c02 = matrix2.get(0, 2); - final long s_c12 = matrix2.get(1, 2); - final long s_c22 = matrix2.get(2, 2); - final long s_c32 = matrix2.get(3, 2); - final long s_c42 = matrix2.get(4, 2); - final long s_c03 = matrix2.get(0, 3); - final long s_c13 = matrix2.get(1, 3); - final long s_c23 = matrix2.get(2, 3); - final long s_c33 = matrix2.get(3, 3); - final long s_c43 = matrix2.get(4, 3); - final long s_c04 = matrix2.get(0, 4); - final long s_c14 = matrix2.get(1, 4); - final long s_c24 = matrix2.get(2, 4); - final long s_c34 = matrix2.get(3, 4); - final long s_c44 = matrix2.get(4, 4); - output.set(0, 0, f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04); - output.set(0, 1, f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04); - output.set(0, 2, f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04); - output.set(0, 3, f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03 + f_c43*s_c04); - output.set(0, 4, f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02 + f_c34*s_c03 + f_c44*s_c04); - output.set(1, 0, f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14); - output.set(1, 1, f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14); - output.set(1, 2, f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14); - output.set(1, 3, f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13 + f_c43*s_c14); - output.set(1, 4, f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12 + f_c34*s_c13 + f_c44*s_c14); - output.set(2, 0, f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24); - output.set(2, 1, f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24); - output.set(2, 2, f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23 + f_c42*s_c24); - output.set(2, 3, f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23 + f_c43*s_c24); - output.set(2, 4, f_c04*s_c20 + f_c14*s_c21 + f_c24*s_c22 + f_c34*s_c23 + f_c44*s_c24); - output.set(3, 0, f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33 + f_c40*s_c34); - output.set(3, 1, f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33 + f_c41*s_c34); - output.set(3, 2, f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33 + f_c42*s_c34); - output.set(3, 3, f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32 + f_c33*s_c33 + f_c43*s_c34); - output.set(3, 4, f_c04*s_c30 + f_c14*s_c31 + f_c24*s_c32 + f_c34*s_c33 + f_c44*s_c34); - output.set(4, 0, f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42 + f_c30*s_c43 + f_c40*s_c44); - output.set(4, 1, f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42 + f_c31*s_c43 + f_c41*s_c44); - output.set(4, 2, f_c02*s_c40 + f_c12*s_c41 + f_c22*s_c42 + f_c32*s_c43 + f_c42*s_c44); - output.set(4, 3, f_c03*s_c40 + f_c13*s_c41 + f_c23*s_c42 + f_c33*s_c43 + f_c43*s_c44); - output.set(4, 4, f_c04*s_c40 + f_c14*s_c41 + f_c24*s_c42 + f_c34*s_c43 + f_c44*s_c44); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final long f00 = matrix1.get(0, 0); + final long f10 = matrix1.get(1, 0); + final long f20 = matrix1.get(2, 0); + final long f30 = matrix1.get(3, 0); + final long f40 = matrix1.get(4, 0); + final long f01 = matrix1.get(0, 1); + final long f11 = matrix1.get(1, 1); + final long f21 = matrix1.get(2, 1); + final long f31 = matrix1.get(3, 1); + final long f41 = matrix1.get(4, 1); + final long f02 = matrix1.get(0, 2); + final long f12 = matrix1.get(1, 2); + final long f22 = matrix1.get(2, 2); + final long f32 = matrix1.get(3, 2); + final long f42 = matrix1.get(4, 2); + final long f03 = matrix1.get(0, 3); + final long f13 = matrix1.get(1, 3); + final long f23 = matrix1.get(2, 3); + final long f33 = matrix1.get(3, 3); + final long f43 = matrix1.get(4, 3); + final long f04 = matrix1.get(0, 4); + final long f14 = matrix1.get(1, 4); + final long f24 = matrix1.get(2, 4); + final long f34 = matrix1.get(3, 4); + final long f44 = matrix1.get(4, 4); + final long s00 = matrix2.get(0, 0); + final long s10 = matrix2.get(1, 0); + final long s20 = matrix2.get(2, 0); + final long s30 = matrix2.get(3, 0); + final long s40 = matrix2.get(4, 0); + final long s01 = matrix2.get(0, 1); + final long s11 = matrix2.get(1, 1); + final long s21 = matrix2.get(2, 1); + final long s31 = matrix2.get(3, 1); + final long s41 = matrix2.get(4, 1); + final long s02 = matrix2.get(0, 2); + final long s12 = matrix2.get(1, 2); + final long s22 = matrix2.get(2, 2); + final long s32 = matrix2.get(3, 2); + final long s42 = matrix2.get(4, 2); + final long s03 = matrix2.get(0, 3); + final long s13 = matrix2.get(1, 3); + final long s23 = matrix2.get(2, 3); + final long s33 = matrix2.get(3, 3); + final long s43 = matrix2.get(4, 3); + final long s04 = matrix2.get(0, 4); + final long s14 = matrix2.get(1, 4); + final long s24 = matrix2.get(2, 4); + final long s34 = matrix2.get(3, 4); + final long s44 = matrix2.get(4, 4); + output.set(0, 0, f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04); + output.set(1, 0, f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14); + output.set(2, 0, f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24); + output.set(3, 0, f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33 + f40 * s34); + output.set(4, 0, f00 * s40 + f10 * s41 + f20 * s42 + f30 * s43 + f40 * s44); + output.set(0, 1, f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04); + output.set(1, 1, f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14); + output.set(2, 1, f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24); + output.set(3, 1, f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33 + f41 * s34); + output.set(4, 1, f01 * s40 + f11 * s41 + f21 * s42 + f31 * s43 + f41 * s44); + output.set(0, 2, f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04); + output.set(1, 2, f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14); + output.set(2, 2, f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23 + f42 * s24); + output.set(3, 2, f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33 + f42 * s34); + output.set(4, 2, f02 * s40 + f12 * s41 + f22 * s42 + f32 * s43 + f42 * s44); + output.set(0, 3, f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03 + f43 * s04); + output.set(1, 3, f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13 + f43 * s14); + output.set(2, 3, f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23 + f43 * s24); + output.set(3, 3, f03 * s30 + f13 * s31 + f23 * s32 + f33 * s33 + f43 * s34); + output.set(4, 3, f03 * s40 + f13 * s41 + f23 * s42 + f33 * s43 + f43 * s44); + output.set(0, 4, f04 * s00 + f14 * s01 + f24 * s02 + f34 * s03 + f44 * s04); + output.set(1, 4, f04 * s10 + f14 * s11 + f24 * s12 + f34 * s13 + f44 * s14); + output.set(2, 4, f04 * s20 + f14 * s21 + f24 * s22 + f34 * s23 + f44 * s24); + output.set(3, 4, f04 * s30 + f14 * s31 + f24 * s32 + f34 * s33 + f44 * s34); + output.set(4, 4, f04 * s40 + f14 * s41 + f24 * s42 + f34 * s43 + f44 * s44); return output; } /** * Automatically generated concrete matrix multiplication. If no mapping exist, this method returns null. * - * @return new Long2Dimensional + * @return new Long2Dimensional */ - @org.jetbrains.annotations.Nullable - public static Long2Dimensional multiplyMatrix(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2) { + @org.jetbrains.annotations.Nullable + public static Long2Dimensional multiplyMatrix(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2) { if (matrix1.getColumns() != matrix2.getRows()) return null; - switch (matrix1.getColumns()) { - case 2: switch (matrix1.getRows()) { - case 2: switch (matrix2.getColumns()) { + switch(matrix1.getColumns()) { + case 1: switch(matrix1.getRows()) { + case 1: switch(matrix2.getColumns()) { + case 1: return (Long2Dimensional) multiplyMatrix1x1x1(matrix1, matrix2, new Long2Dimensional(1, 1)); + case 2: return (Long2Dimensional) multiplyMatrix1x1x2(matrix1, matrix2, new Long2Dimensional(2, 1)); + case 3: return (Long2Dimensional) multiplyMatrix1x1x3(matrix1, matrix2, new Long2Dimensional(3, 1)); + case 4: return (Long2Dimensional) multiplyMatrix1x1x4(matrix1, matrix2, new Long2Dimensional(4, 1)); + case 5: return (Long2Dimensional) multiplyMatrix1x1x5(matrix1, matrix2, new Long2Dimensional(5, 1)); + default: return null; + } + case 2: switch(matrix2.getColumns()) { + case 1: return (Long2Dimensional) multiplyMatrix2x1x1(matrix1, matrix2, new Long2Dimensional(1, 2)); + case 2: return (Long2Dimensional) multiplyMatrix2x1x2(matrix1, matrix2, new Long2Dimensional(2, 2)); + case 3: return (Long2Dimensional) multiplyMatrix2x1x3(matrix1, matrix2, new Long2Dimensional(3, 2)); + case 4: return (Long2Dimensional) multiplyMatrix2x1x4(matrix1, matrix2, new Long2Dimensional(4, 2)); + case 5: return (Long2Dimensional) multiplyMatrix2x1x5(matrix1, matrix2, new Long2Dimensional(5, 2)); + default: return null; + } + case 3: switch(matrix2.getColumns()) { + case 1: return (Long2Dimensional) multiplyMatrix3x1x1(matrix1, matrix2, new Long2Dimensional(1, 3)); + case 2: return (Long2Dimensional) multiplyMatrix3x1x2(matrix1, matrix2, new Long2Dimensional(2, 3)); + case 3: return (Long2Dimensional) multiplyMatrix3x1x3(matrix1, matrix2, new Long2Dimensional(3, 3)); + case 4: return (Long2Dimensional) multiplyMatrix3x1x4(matrix1, matrix2, new Long2Dimensional(4, 3)); + case 5: return (Long2Dimensional) multiplyMatrix3x1x5(matrix1, matrix2, new Long2Dimensional(5, 3)); + default: return null; + } + case 4: switch(matrix2.getColumns()) { + case 1: return (Long2Dimensional) multiplyMatrix4x1x1(matrix1, matrix2, new Long2Dimensional(1, 4)); + case 2: return (Long2Dimensional) multiplyMatrix4x1x2(matrix1, matrix2, new Long2Dimensional(2, 4)); + case 3: return (Long2Dimensional) multiplyMatrix4x1x3(matrix1, matrix2, new Long2Dimensional(3, 4)); + case 4: return (Long2Dimensional) multiplyMatrix4x1x4(matrix1, matrix2, new Long2Dimensional(4, 4)); + case 5: return (Long2Dimensional) multiplyMatrix4x1x5(matrix1, matrix2, new Long2Dimensional(5, 4)); + default: return null; + } + case 5: switch(matrix2.getColumns()) { + case 1: return (Long2Dimensional) multiplyMatrix5x1x1(matrix1, matrix2, new Long2Dimensional(1, 5)); + case 2: return (Long2Dimensional) multiplyMatrix5x1x2(matrix1, matrix2, new Long2Dimensional(2, 5)); + case 3: return (Long2Dimensional) multiplyMatrix5x1x3(matrix1, matrix2, new Long2Dimensional(3, 5)); + case 4: return (Long2Dimensional) multiplyMatrix5x1x4(matrix1, matrix2, new Long2Dimensional(4, 5)); + case 5: return (Long2Dimensional) multiplyMatrix5x1x5(matrix1, matrix2, new Long2Dimensional(5, 5)); + default: return null; + } + default: return null; + } + case 2: switch(matrix1.getRows()) { + case 1: switch(matrix2.getColumns()) { + case 1: return (Long2Dimensional) multiplyMatrix1x2x1(matrix1, matrix2, new Long2Dimensional(1, 1)); + case 2: return (Long2Dimensional) multiplyMatrix1x2x2(matrix1, matrix2, new Long2Dimensional(2, 1)); + case 3: return (Long2Dimensional) multiplyMatrix1x2x3(matrix1, matrix2, new Long2Dimensional(3, 1)); + case 4: return (Long2Dimensional) multiplyMatrix1x2x4(matrix1, matrix2, new Long2Dimensional(4, 1)); + case 5: return (Long2Dimensional) multiplyMatrix1x2x5(matrix1, matrix2, new Long2Dimensional(5, 1)); + default: return null; + } + case 2: switch(matrix2.getColumns()) { + case 1: return (Long2Dimensional) multiplyMatrix2x2x1(matrix1, matrix2, new Long2Dimensional(1, 2)); case 2: return (Long2Dimensional) multiplyMatrix2x2x2(matrix1, matrix2, new Long2Dimensional(2, 2)); case 3: return (Long2Dimensional) multiplyMatrix2x2x3(matrix1, matrix2, new Long2Dimensional(3, 2)); case 4: return (Long2Dimensional) multiplyMatrix2x2x4(matrix1, matrix2, new Long2Dimensional(4, 2)); case 5: return (Long2Dimensional) multiplyMatrix2x2x5(matrix1, matrix2, new Long2Dimensional(5, 2)); default: return null; } - case 3: switch (matrix2.getColumns()) { + case 3: switch(matrix2.getColumns()) { + case 1: return (Long2Dimensional) multiplyMatrix3x2x1(matrix1, matrix2, new Long2Dimensional(1, 3)); case 2: return (Long2Dimensional) multiplyMatrix3x2x2(matrix1, matrix2, new Long2Dimensional(2, 3)); case 3: return (Long2Dimensional) multiplyMatrix3x2x3(matrix1, matrix2, new Long2Dimensional(3, 3)); case 4: return (Long2Dimensional) multiplyMatrix3x2x4(matrix1, matrix2, new Long2Dimensional(4, 3)); case 5: return (Long2Dimensional) multiplyMatrix3x2x5(matrix1, matrix2, new Long2Dimensional(5, 3)); default: return null; } - case 4: switch (matrix2.getColumns()) { + case 4: switch(matrix2.getColumns()) { + case 1: return (Long2Dimensional) multiplyMatrix4x2x1(matrix1, matrix2, new Long2Dimensional(1, 4)); case 2: return (Long2Dimensional) multiplyMatrix4x2x2(matrix1, matrix2, new Long2Dimensional(2, 4)); case 3: return (Long2Dimensional) multiplyMatrix4x2x3(matrix1, matrix2, new Long2Dimensional(3, 4)); case 4: return (Long2Dimensional) multiplyMatrix4x2x4(matrix1, matrix2, new Long2Dimensional(4, 4)); case 5: return (Long2Dimensional) multiplyMatrix4x2x5(matrix1, matrix2, new Long2Dimensional(5, 4)); default: return null; } - case 5: switch (matrix2.getColumns()) { + case 5: switch(matrix2.getColumns()) { + case 1: return (Long2Dimensional) multiplyMatrix5x2x1(matrix1, matrix2, new Long2Dimensional(1, 5)); case 2: return (Long2Dimensional) multiplyMatrix5x2x2(matrix1, matrix2, new Long2Dimensional(2, 5)); case 3: return (Long2Dimensional) multiplyMatrix5x2x3(matrix1, matrix2, new Long2Dimensional(3, 5)); case 4: return (Long2Dimensional) multiplyMatrix5x2x4(matrix1, matrix2, new Long2Dimensional(4, 5)); @@ -2788,29 +4230,41 @@ public final class MultiplicationsLong { } default: return null; } - case 3: switch (matrix1.getRows()) { - case 2: switch (matrix2.getColumns()) { + case 3: switch(matrix1.getRows()) { + case 1: switch(matrix2.getColumns()) { + case 1: return (Long2Dimensional) multiplyMatrix1x3x1(matrix1, matrix2, new Long2Dimensional(1, 1)); + case 2: return (Long2Dimensional) multiplyMatrix1x3x2(matrix1, matrix2, new Long2Dimensional(2, 1)); + case 3: return (Long2Dimensional) multiplyMatrix1x3x3(matrix1, matrix2, new Long2Dimensional(3, 1)); + case 4: return (Long2Dimensional) multiplyMatrix1x3x4(matrix1, matrix2, new Long2Dimensional(4, 1)); + case 5: return (Long2Dimensional) multiplyMatrix1x3x5(matrix1, matrix2, new Long2Dimensional(5, 1)); + default: return null; + } + case 2: switch(matrix2.getColumns()) { + case 1: return (Long2Dimensional) multiplyMatrix2x3x1(matrix1, matrix2, new Long2Dimensional(1, 2)); case 2: return (Long2Dimensional) multiplyMatrix2x3x2(matrix1, matrix2, new Long2Dimensional(2, 2)); case 3: return (Long2Dimensional) multiplyMatrix2x3x3(matrix1, matrix2, new Long2Dimensional(3, 2)); case 4: return (Long2Dimensional) multiplyMatrix2x3x4(matrix1, matrix2, new Long2Dimensional(4, 2)); case 5: return (Long2Dimensional) multiplyMatrix2x3x5(matrix1, matrix2, new Long2Dimensional(5, 2)); default: return null; } - case 3: switch (matrix2.getColumns()) { + case 3: switch(matrix2.getColumns()) { + case 1: return (Long2Dimensional) multiplyMatrix3x3x1(matrix1, matrix2, new Long2Dimensional(1, 3)); case 2: return (Long2Dimensional) multiplyMatrix3x3x2(matrix1, matrix2, new Long2Dimensional(2, 3)); case 3: return (Long2Dimensional) multiplyMatrix3x3x3(matrix1, matrix2, new Long2Dimensional(3, 3)); case 4: return (Long2Dimensional) multiplyMatrix3x3x4(matrix1, matrix2, new Long2Dimensional(4, 3)); case 5: return (Long2Dimensional) multiplyMatrix3x3x5(matrix1, matrix2, new Long2Dimensional(5, 3)); default: return null; } - case 4: switch (matrix2.getColumns()) { + case 4: switch(matrix2.getColumns()) { + case 1: return (Long2Dimensional) multiplyMatrix4x3x1(matrix1, matrix2, new Long2Dimensional(1, 4)); case 2: return (Long2Dimensional) multiplyMatrix4x3x2(matrix1, matrix2, new Long2Dimensional(2, 4)); case 3: return (Long2Dimensional) multiplyMatrix4x3x3(matrix1, matrix2, new Long2Dimensional(3, 4)); case 4: return (Long2Dimensional) multiplyMatrix4x3x4(matrix1, matrix2, new Long2Dimensional(4, 4)); case 5: return (Long2Dimensional) multiplyMatrix4x3x5(matrix1, matrix2, new Long2Dimensional(5, 4)); default: return null; } - case 5: switch (matrix2.getColumns()) { + case 5: switch(matrix2.getColumns()) { + case 1: return (Long2Dimensional) multiplyMatrix5x3x1(matrix1, matrix2, new Long2Dimensional(1, 5)); case 2: return (Long2Dimensional) multiplyMatrix5x3x2(matrix1, matrix2, new Long2Dimensional(2, 5)); case 3: return (Long2Dimensional) multiplyMatrix5x3x3(matrix1, matrix2, new Long2Dimensional(3, 5)); case 4: return (Long2Dimensional) multiplyMatrix5x3x4(matrix1, matrix2, new Long2Dimensional(4, 5)); @@ -2819,29 +4273,41 @@ public final class MultiplicationsLong { } default: return null; } - case 4: switch (matrix1.getRows()) { - case 2: switch (matrix2.getColumns()) { + case 4: switch(matrix1.getRows()) { + case 1: switch(matrix2.getColumns()) { + case 1: return (Long2Dimensional) multiplyMatrix1x4x1(matrix1, matrix2, new Long2Dimensional(1, 1)); + case 2: return (Long2Dimensional) multiplyMatrix1x4x2(matrix1, matrix2, new Long2Dimensional(2, 1)); + case 3: return (Long2Dimensional) multiplyMatrix1x4x3(matrix1, matrix2, new Long2Dimensional(3, 1)); + case 4: return (Long2Dimensional) multiplyMatrix1x4x4(matrix1, matrix2, new Long2Dimensional(4, 1)); + case 5: return (Long2Dimensional) multiplyMatrix1x4x5(matrix1, matrix2, new Long2Dimensional(5, 1)); + default: return null; + } + case 2: switch(matrix2.getColumns()) { + case 1: return (Long2Dimensional) multiplyMatrix2x4x1(matrix1, matrix2, new Long2Dimensional(1, 2)); case 2: return (Long2Dimensional) multiplyMatrix2x4x2(matrix1, matrix2, new Long2Dimensional(2, 2)); case 3: return (Long2Dimensional) multiplyMatrix2x4x3(matrix1, matrix2, new Long2Dimensional(3, 2)); case 4: return (Long2Dimensional) multiplyMatrix2x4x4(matrix1, matrix2, new Long2Dimensional(4, 2)); case 5: return (Long2Dimensional) multiplyMatrix2x4x5(matrix1, matrix2, new Long2Dimensional(5, 2)); default: return null; } - case 3: switch (matrix2.getColumns()) { + case 3: switch(matrix2.getColumns()) { + case 1: return (Long2Dimensional) multiplyMatrix3x4x1(matrix1, matrix2, new Long2Dimensional(1, 3)); case 2: return (Long2Dimensional) multiplyMatrix3x4x2(matrix1, matrix2, new Long2Dimensional(2, 3)); case 3: return (Long2Dimensional) multiplyMatrix3x4x3(matrix1, matrix2, new Long2Dimensional(3, 3)); case 4: return (Long2Dimensional) multiplyMatrix3x4x4(matrix1, matrix2, new Long2Dimensional(4, 3)); case 5: return (Long2Dimensional) multiplyMatrix3x4x5(matrix1, matrix2, new Long2Dimensional(5, 3)); default: return null; } - case 4: switch (matrix2.getColumns()) { + case 4: switch(matrix2.getColumns()) { + case 1: return (Long2Dimensional) multiplyMatrix4x4x1(matrix1, matrix2, new Long2Dimensional(1, 4)); case 2: return (Long2Dimensional) multiplyMatrix4x4x2(matrix1, matrix2, new Long2Dimensional(2, 4)); case 3: return (Long2Dimensional) multiplyMatrix4x4x3(matrix1, matrix2, new Long2Dimensional(3, 4)); case 4: return (Long2Dimensional) multiplyMatrix4x4x4(matrix1, matrix2, new Long2Dimensional(4, 4)); case 5: return (Long2Dimensional) multiplyMatrix4x4x5(matrix1, matrix2, new Long2Dimensional(5, 4)); default: return null; } - case 5: switch (matrix2.getColumns()) { + case 5: switch(matrix2.getColumns()) { + case 1: return (Long2Dimensional) multiplyMatrix5x4x1(matrix1, matrix2, new Long2Dimensional(1, 5)); case 2: return (Long2Dimensional) multiplyMatrix5x4x2(matrix1, matrix2, new Long2Dimensional(2, 5)); case 3: return (Long2Dimensional) multiplyMatrix5x4x3(matrix1, matrix2, new Long2Dimensional(3, 5)); case 4: return (Long2Dimensional) multiplyMatrix5x4x4(matrix1, matrix2, new Long2Dimensional(4, 5)); @@ -2850,29 +4316,41 @@ public final class MultiplicationsLong { } default: return null; } - case 5: switch (matrix1.getRows()) { - case 2: switch (matrix2.getColumns()) { + case 5: switch(matrix1.getRows()) { + case 1: switch(matrix2.getColumns()) { + case 1: return (Long2Dimensional) multiplyMatrix1x5x1(matrix1, matrix2, new Long2Dimensional(1, 1)); + case 2: return (Long2Dimensional) multiplyMatrix1x5x2(matrix1, matrix2, new Long2Dimensional(2, 1)); + case 3: return (Long2Dimensional) multiplyMatrix1x5x3(matrix1, matrix2, new Long2Dimensional(3, 1)); + case 4: return (Long2Dimensional) multiplyMatrix1x5x4(matrix1, matrix2, new Long2Dimensional(4, 1)); + case 5: return (Long2Dimensional) multiplyMatrix1x5x5(matrix1, matrix2, new Long2Dimensional(5, 1)); + default: return null; + } + case 2: switch(matrix2.getColumns()) { + case 1: return (Long2Dimensional) multiplyMatrix2x5x1(matrix1, matrix2, new Long2Dimensional(1, 2)); case 2: return (Long2Dimensional) multiplyMatrix2x5x2(matrix1, matrix2, new Long2Dimensional(2, 2)); case 3: return (Long2Dimensional) multiplyMatrix2x5x3(matrix1, matrix2, new Long2Dimensional(3, 2)); case 4: return (Long2Dimensional) multiplyMatrix2x5x4(matrix1, matrix2, new Long2Dimensional(4, 2)); case 5: return (Long2Dimensional) multiplyMatrix2x5x5(matrix1, matrix2, new Long2Dimensional(5, 2)); default: return null; } - case 3: switch (matrix2.getColumns()) { + case 3: switch(matrix2.getColumns()) { + case 1: return (Long2Dimensional) multiplyMatrix3x5x1(matrix1, matrix2, new Long2Dimensional(1, 3)); case 2: return (Long2Dimensional) multiplyMatrix3x5x2(matrix1, matrix2, new Long2Dimensional(2, 3)); case 3: return (Long2Dimensional) multiplyMatrix3x5x3(matrix1, matrix2, new Long2Dimensional(3, 3)); case 4: return (Long2Dimensional) multiplyMatrix3x5x4(matrix1, matrix2, new Long2Dimensional(4, 3)); case 5: return (Long2Dimensional) multiplyMatrix3x5x5(matrix1, matrix2, new Long2Dimensional(5, 3)); default: return null; } - case 4: switch (matrix2.getColumns()) { + case 4: switch(matrix2.getColumns()) { + case 1: return (Long2Dimensional) multiplyMatrix4x5x1(matrix1, matrix2, new Long2Dimensional(1, 4)); case 2: return (Long2Dimensional) multiplyMatrix4x5x2(matrix1, matrix2, new Long2Dimensional(2, 4)); case 3: return (Long2Dimensional) multiplyMatrix4x5x3(matrix1, matrix2, new Long2Dimensional(3, 4)); case 4: return (Long2Dimensional) multiplyMatrix4x5x4(matrix1, matrix2, new Long2Dimensional(4, 4)); case 5: return (Long2Dimensional) multiplyMatrix4x5x5(matrix1, matrix2, new Long2Dimensional(5, 4)); default: return null; } - case 5: switch (matrix2.getColumns()) { + case 5: switch(matrix2.getColumns()) { + case 1: return (Long2Dimensional) multiplyMatrix5x5x1(matrix1, matrix2, new Long2Dimensional(1, 5)); case 2: return (Long2Dimensional) multiplyMatrix5x5x2(matrix1, matrix2, new Long2Dimensional(2, 5)); case 3: return (Long2Dimensional) multiplyMatrix5x5x3(matrix1, matrix2, new Long2Dimensional(3, 5)); case 4: return (Long2Dimensional) multiplyMatrix5x5x4(matrix1, matrix2, new Long2Dimensional(4, 5)); @@ -2884,39 +4362,94 @@ public final class MultiplicationsLong { default: return null; } } - /** - * Automatically generated concrete matrix multiplication. If no mapping exist, this method returns null. - * This method writes the result to specified [output] - * @return provided IMatrixSetterLong if mapping exists and computed, or null if mapping does not exist + * Automatically generated concrete matrix multiplication. + * This function writes the result onto specified output, and returns it, if mapping exists and computed, otherwise returns null. + * + * @return provided output, or null if mapping does not exist */ - @org.jetbrains.annotations.Nullable - public static IMatrixSetterLong multiplyMatrix(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { + @org.jetbrains.annotations.Nullable + public static IMatrixSetterLong multiplyMatrix(final IMatrixGetterLong matrix1, final IMatrixGetterLong matrix2, final IMatrixSetterLong output) { if (matrix1.getColumns() != matrix2.getRows()) return null; - switch (matrix1.getColumns()) { - case 2: switch (matrix1.getRows()) { - case 2: switch (matrix2.getColumns()) { + switch(matrix1.getColumns()) { + case 1: switch(matrix1.getRows()) { + case 1: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix1x1x1(matrix1, matrix2, output); + case 2: return multiplyMatrix1x1x2(matrix1, matrix2, output); + case 3: return multiplyMatrix1x1x3(matrix1, matrix2, output); + case 4: return multiplyMatrix1x1x4(matrix1, matrix2, output); + case 5: return multiplyMatrix1x1x5(matrix1, matrix2, output); + default: return null; + } + case 2: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix2x1x1(matrix1, matrix2, output); + case 2: return multiplyMatrix2x1x2(matrix1, matrix2, output); + case 3: return multiplyMatrix2x1x3(matrix1, matrix2, output); + case 4: return multiplyMatrix2x1x4(matrix1, matrix2, output); + case 5: return multiplyMatrix2x1x5(matrix1, matrix2, output); + default: return null; + } + case 3: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix3x1x1(matrix1, matrix2, output); + case 2: return multiplyMatrix3x1x2(matrix1, matrix2, output); + case 3: return multiplyMatrix3x1x3(matrix1, matrix2, output); + case 4: return multiplyMatrix3x1x4(matrix1, matrix2, output); + case 5: return multiplyMatrix3x1x5(matrix1, matrix2, output); + default: return null; + } + case 4: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix4x1x1(matrix1, matrix2, output); + case 2: return multiplyMatrix4x1x2(matrix1, matrix2, output); + case 3: return multiplyMatrix4x1x3(matrix1, matrix2, output); + case 4: return multiplyMatrix4x1x4(matrix1, matrix2, output); + case 5: return multiplyMatrix4x1x5(matrix1, matrix2, output); + default: return null; + } + case 5: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix5x1x1(matrix1, matrix2, output); + case 2: return multiplyMatrix5x1x2(matrix1, matrix2, output); + case 3: return multiplyMatrix5x1x3(matrix1, matrix2, output); + case 4: return multiplyMatrix5x1x4(matrix1, matrix2, output); + case 5: return multiplyMatrix5x1x5(matrix1, matrix2, output); + default: return null; + } + default: return null; + } + case 2: switch(matrix1.getRows()) { + case 1: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix1x2x1(matrix1, matrix2, output); + case 2: return multiplyMatrix1x2x2(matrix1, matrix2, output); + case 3: return multiplyMatrix1x2x3(matrix1, matrix2, output); + case 4: return multiplyMatrix1x2x4(matrix1, matrix2, output); + case 5: return multiplyMatrix1x2x5(matrix1, matrix2, output); + default: return null; + } + case 2: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix2x2x1(matrix1, matrix2, output); case 2: return multiplyMatrix2x2x2(matrix1, matrix2, output); case 3: return multiplyMatrix2x2x3(matrix1, matrix2, output); case 4: return multiplyMatrix2x2x4(matrix1, matrix2, output); case 5: return multiplyMatrix2x2x5(matrix1, matrix2, output); default: return null; } - case 3: switch (matrix2.getColumns()) { + case 3: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix3x2x1(matrix1, matrix2, output); case 2: return multiplyMatrix3x2x2(matrix1, matrix2, output); case 3: return multiplyMatrix3x2x3(matrix1, matrix2, output); case 4: return multiplyMatrix3x2x4(matrix1, matrix2, output); case 5: return multiplyMatrix3x2x5(matrix1, matrix2, output); default: return null; } - case 4: switch (matrix2.getColumns()) { + case 4: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix4x2x1(matrix1, matrix2, output); case 2: return multiplyMatrix4x2x2(matrix1, matrix2, output); case 3: return multiplyMatrix4x2x3(matrix1, matrix2, output); case 4: return multiplyMatrix4x2x4(matrix1, matrix2, output); case 5: return multiplyMatrix4x2x5(matrix1, matrix2, output); default: return null; } - case 5: switch (matrix2.getColumns()) { + case 5: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix5x2x1(matrix1, matrix2, output); case 2: return multiplyMatrix5x2x2(matrix1, matrix2, output); case 3: return multiplyMatrix5x2x3(matrix1, matrix2, output); case 4: return multiplyMatrix5x2x4(matrix1, matrix2, output); @@ -2925,29 +4458,41 @@ public final class MultiplicationsLong { } default: return null; } - case 3: switch (matrix1.getRows()) { - case 2: switch (matrix2.getColumns()) { + case 3: switch(matrix1.getRows()) { + case 1: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix1x3x1(matrix1, matrix2, output); + case 2: return multiplyMatrix1x3x2(matrix1, matrix2, output); + case 3: return multiplyMatrix1x3x3(matrix1, matrix2, output); + case 4: return multiplyMatrix1x3x4(matrix1, matrix2, output); + case 5: return multiplyMatrix1x3x5(matrix1, matrix2, output); + default: return null; + } + case 2: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix2x3x1(matrix1, matrix2, output); case 2: return multiplyMatrix2x3x2(matrix1, matrix2, output); case 3: return multiplyMatrix2x3x3(matrix1, matrix2, output); case 4: return multiplyMatrix2x3x4(matrix1, matrix2, output); case 5: return multiplyMatrix2x3x5(matrix1, matrix2, output); default: return null; } - case 3: switch (matrix2.getColumns()) { + case 3: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix3x3x1(matrix1, matrix2, output); case 2: return multiplyMatrix3x3x2(matrix1, matrix2, output); case 3: return multiplyMatrix3x3x3(matrix1, matrix2, output); case 4: return multiplyMatrix3x3x4(matrix1, matrix2, output); case 5: return multiplyMatrix3x3x5(matrix1, matrix2, output); default: return null; } - case 4: switch (matrix2.getColumns()) { + case 4: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix4x3x1(matrix1, matrix2, output); case 2: return multiplyMatrix4x3x2(matrix1, matrix2, output); case 3: return multiplyMatrix4x3x3(matrix1, matrix2, output); case 4: return multiplyMatrix4x3x4(matrix1, matrix2, output); case 5: return multiplyMatrix4x3x5(matrix1, matrix2, output); default: return null; } - case 5: switch (matrix2.getColumns()) { + case 5: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix5x3x1(matrix1, matrix2, output); case 2: return multiplyMatrix5x3x2(matrix1, matrix2, output); case 3: return multiplyMatrix5x3x3(matrix1, matrix2, output); case 4: return multiplyMatrix5x3x4(matrix1, matrix2, output); @@ -2956,29 +4501,41 @@ public final class MultiplicationsLong { } default: return null; } - case 4: switch (matrix1.getRows()) { - case 2: switch (matrix2.getColumns()) { + case 4: switch(matrix1.getRows()) { + case 1: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix1x4x1(matrix1, matrix2, output); + case 2: return multiplyMatrix1x4x2(matrix1, matrix2, output); + case 3: return multiplyMatrix1x4x3(matrix1, matrix2, output); + case 4: return multiplyMatrix1x4x4(matrix1, matrix2, output); + case 5: return multiplyMatrix1x4x5(matrix1, matrix2, output); + default: return null; + } + case 2: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix2x4x1(matrix1, matrix2, output); case 2: return multiplyMatrix2x4x2(matrix1, matrix2, output); case 3: return multiplyMatrix2x4x3(matrix1, matrix2, output); case 4: return multiplyMatrix2x4x4(matrix1, matrix2, output); case 5: return multiplyMatrix2x4x5(matrix1, matrix2, output); default: return null; } - case 3: switch (matrix2.getColumns()) { + case 3: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix3x4x1(matrix1, matrix2, output); case 2: return multiplyMatrix3x4x2(matrix1, matrix2, output); case 3: return multiplyMatrix3x4x3(matrix1, matrix2, output); case 4: return multiplyMatrix3x4x4(matrix1, matrix2, output); case 5: return multiplyMatrix3x4x5(matrix1, matrix2, output); default: return null; } - case 4: switch (matrix2.getColumns()) { + case 4: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix4x4x1(matrix1, matrix2, output); case 2: return multiplyMatrix4x4x2(matrix1, matrix2, output); case 3: return multiplyMatrix4x4x3(matrix1, matrix2, output); case 4: return multiplyMatrix4x4x4(matrix1, matrix2, output); case 5: return multiplyMatrix4x4x5(matrix1, matrix2, output); default: return null; } - case 5: switch (matrix2.getColumns()) { + case 5: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix5x4x1(matrix1, matrix2, output); case 2: return multiplyMatrix5x4x2(matrix1, matrix2, output); case 3: return multiplyMatrix5x4x3(matrix1, matrix2, output); case 4: return multiplyMatrix5x4x4(matrix1, matrix2, output); @@ -2987,29 +4544,41 @@ public final class MultiplicationsLong { } default: return null; } - case 5: switch (matrix1.getRows()) { - case 2: switch (matrix2.getColumns()) { + case 5: switch(matrix1.getRows()) { + case 1: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix1x5x1(matrix1, matrix2, output); + case 2: return multiplyMatrix1x5x2(matrix1, matrix2, output); + case 3: return multiplyMatrix1x5x3(matrix1, matrix2, output); + case 4: return multiplyMatrix1x5x4(matrix1, matrix2, output); + case 5: return multiplyMatrix1x5x5(matrix1, matrix2, output); + default: return null; + } + case 2: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix2x5x1(matrix1, matrix2, output); case 2: return multiplyMatrix2x5x2(matrix1, matrix2, output); case 3: return multiplyMatrix2x5x3(matrix1, matrix2, output); case 4: return multiplyMatrix2x5x4(matrix1, matrix2, output); case 5: return multiplyMatrix2x5x5(matrix1, matrix2, output); default: return null; } - case 3: switch (matrix2.getColumns()) { + case 3: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix3x5x1(matrix1, matrix2, output); case 2: return multiplyMatrix3x5x2(matrix1, matrix2, output); case 3: return multiplyMatrix3x5x3(matrix1, matrix2, output); case 4: return multiplyMatrix3x5x4(matrix1, matrix2, output); case 5: return multiplyMatrix3x5x5(matrix1, matrix2, output); default: return null; } - case 4: switch (matrix2.getColumns()) { + case 4: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix4x5x1(matrix1, matrix2, output); case 2: return multiplyMatrix4x5x2(matrix1, matrix2, output); case 3: return multiplyMatrix4x5x3(matrix1, matrix2, output); case 4: return multiplyMatrix4x5x4(matrix1, matrix2, output); case 5: return multiplyMatrix4x5x5(matrix1, matrix2, output); default: return null; } - case 5: switch (matrix2.getColumns()) { + case 5: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix5x5x1(matrix1, matrix2, output); case 2: return multiplyMatrix5x5x2(matrix1, matrix2, output); case 3: return multiplyMatrix5x5x3(matrix1, matrix2, output); case 4: return multiplyMatrix5x5x4(matrix1, matrix2, output); diff --git a/src/kvector/java/ru/dbotthepony/kvector/matrix/generated/MultiplicationsShort.java b/src/kvector/java/ru/dbotthepony/kvector/matrix/generated/MultiplicationsShort.java index 88bb10d7..76e62921 100644 --- a/src/kvector/java/ru/dbotthepony/kvector/matrix/generated/MultiplicationsShort.java +++ b/src/kvector/java/ru/dbotthepony/kvector/matrix/generated/MultiplicationsShort.java @@ -3,7 +3,6 @@ package ru.dbotthepony.kvector.matrix.generated; import ru.dbotthepony.kvector.api.*; import ru.dbotthepony.kvector.narray.*; -// Some metaprogramming ///////////////////////////////// // THIS FILE IS AUTO GENERATED // // DO NOT EDIT // @@ -11,2775 +10,4218 @@ import ru.dbotthepony.kvector.narray.*; public final class MultiplicationsShort { private MultiplicationsShort() {} + private static IMatrixSetterShort multiplyMatrix1x1x1(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final short f00 = matrix1.get(0, 0); + final short s00 = matrix2.get(0, 0); + output.set(0, 0, (short) (f00 * s00)); + return output; + } + + private static IMatrixSetterShort multiplyMatrix1x1x2(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final short f00 = matrix1.get(0, 0); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + output.set(0, 0, (short) (f00 * s00)); + output.set(1, 0, (short) (f00 * s10)); + return output; + } + + private static IMatrixSetterShort multiplyMatrix1x1x3(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final short f00 = matrix1.get(0, 0); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + output.set(0, 0, (short) (f00 * s00)); + output.set(1, 0, (short) (f00 * s10)); + output.set(2, 0, (short) (f00 * s20)); + return output; + } + + private static IMatrixSetterShort multiplyMatrix1x1x4(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final short f00 = matrix1.get(0, 0); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + final short s30 = matrix2.get(3, 0); + output.set(0, 0, (short) (f00 * s00)); + output.set(1, 0, (short) (f00 * s10)); + output.set(2, 0, (short) (f00 * s20)); + output.set(3, 0, (short) (f00 * s30)); + return output; + } + + private static IMatrixSetterShort multiplyMatrix1x1x5(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final short f00 = matrix1.get(0, 0); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + final short s30 = matrix2.get(3, 0); + final short s40 = matrix2.get(4, 0); + output.set(0, 0, (short) (f00 * s00)); + output.set(1, 0, (short) (f00 * s10)); + output.set(2, 0, (short) (f00 * s20)); + output.set(3, 0, (short) (f00 * s30)); + output.set(4, 0, (short) (f00 * s40)); + return output; + } + + private static IMatrixSetterShort multiplyMatrix2x1x1(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final short f00 = matrix1.get(0, 0); + final short f01 = matrix1.get(0, 1); + final short s00 = matrix2.get(0, 0); + output.set(0, 0, (short) (f00 * s00)); + output.set(0, 1, (short) (f01 * s00)); + return output; + } + + private static IMatrixSetterShort multiplyMatrix2x1x2(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final short f00 = matrix1.get(0, 0); + final short f01 = matrix1.get(0, 1); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + output.set(0, 0, (short) (f00 * s00)); + output.set(1, 0, (short) (f00 * s10)); + output.set(0, 1, (short) (f01 * s00)); + output.set(1, 1, (short) (f01 * s10)); + return output; + } + + private static IMatrixSetterShort multiplyMatrix2x1x3(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final short f00 = matrix1.get(0, 0); + final short f01 = matrix1.get(0, 1); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + output.set(0, 0, (short) (f00 * s00)); + output.set(1, 0, (short) (f00 * s10)); + output.set(2, 0, (short) (f00 * s20)); + output.set(0, 1, (short) (f01 * s00)); + output.set(1, 1, (short) (f01 * s10)); + output.set(2, 1, (short) (f01 * s20)); + return output; + } + + private static IMatrixSetterShort multiplyMatrix2x1x4(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final short f00 = matrix1.get(0, 0); + final short f01 = matrix1.get(0, 1); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + final short s30 = matrix2.get(3, 0); + output.set(0, 0, (short) (f00 * s00)); + output.set(1, 0, (short) (f00 * s10)); + output.set(2, 0, (short) (f00 * s20)); + output.set(3, 0, (short) (f00 * s30)); + output.set(0, 1, (short) (f01 * s00)); + output.set(1, 1, (short) (f01 * s10)); + output.set(2, 1, (short) (f01 * s20)); + output.set(3, 1, (short) (f01 * s30)); + return output; + } + + private static IMatrixSetterShort multiplyMatrix2x1x5(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final short f00 = matrix1.get(0, 0); + final short f01 = matrix1.get(0, 1); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + final short s30 = matrix2.get(3, 0); + final short s40 = matrix2.get(4, 0); + output.set(0, 0, (short) (f00 * s00)); + output.set(1, 0, (short) (f00 * s10)); + output.set(2, 0, (short) (f00 * s20)); + output.set(3, 0, (short) (f00 * s30)); + output.set(4, 0, (short) (f00 * s40)); + output.set(0, 1, (short) (f01 * s00)); + output.set(1, 1, (short) (f01 * s10)); + output.set(2, 1, (short) (f01 * s20)); + output.set(3, 1, (short) (f01 * s30)); + output.set(4, 1, (short) (f01 * s40)); + return output; + } + + private static IMatrixSetterShort multiplyMatrix3x1x1(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final short f00 = matrix1.get(0, 0); + final short f01 = matrix1.get(0, 1); + final short f02 = matrix1.get(0, 2); + final short s00 = matrix2.get(0, 0); + output.set(0, 0, (short) (f00 * s00)); + output.set(0, 1, (short) (f01 * s00)); + output.set(0, 2, (short) (f02 * s00)); + return output; + } + + private static IMatrixSetterShort multiplyMatrix3x1x2(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final short f00 = matrix1.get(0, 0); + final short f01 = matrix1.get(0, 1); + final short f02 = matrix1.get(0, 2); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + output.set(0, 0, (short) (f00 * s00)); + output.set(1, 0, (short) (f00 * s10)); + output.set(0, 1, (short) (f01 * s00)); + output.set(1, 1, (short) (f01 * s10)); + output.set(0, 2, (short) (f02 * s00)); + output.set(1, 2, (short) (f02 * s10)); + return output; + } + + private static IMatrixSetterShort multiplyMatrix3x1x3(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final short f00 = matrix1.get(0, 0); + final short f01 = matrix1.get(0, 1); + final short f02 = matrix1.get(0, 2); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + output.set(0, 0, (short) (f00 * s00)); + output.set(1, 0, (short) (f00 * s10)); + output.set(2, 0, (short) (f00 * s20)); + output.set(0, 1, (short) (f01 * s00)); + output.set(1, 1, (short) (f01 * s10)); + output.set(2, 1, (short) (f01 * s20)); + output.set(0, 2, (short) (f02 * s00)); + output.set(1, 2, (short) (f02 * s10)); + output.set(2, 2, (short) (f02 * s20)); + return output; + } + + private static IMatrixSetterShort multiplyMatrix3x1x4(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final short f00 = matrix1.get(0, 0); + final short f01 = matrix1.get(0, 1); + final short f02 = matrix1.get(0, 2); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + final short s30 = matrix2.get(3, 0); + output.set(0, 0, (short) (f00 * s00)); + output.set(1, 0, (short) (f00 * s10)); + output.set(2, 0, (short) (f00 * s20)); + output.set(3, 0, (short) (f00 * s30)); + output.set(0, 1, (short) (f01 * s00)); + output.set(1, 1, (short) (f01 * s10)); + output.set(2, 1, (short) (f01 * s20)); + output.set(3, 1, (short) (f01 * s30)); + output.set(0, 2, (short) (f02 * s00)); + output.set(1, 2, (short) (f02 * s10)); + output.set(2, 2, (short) (f02 * s20)); + output.set(3, 2, (short) (f02 * s30)); + return output; + } + + private static IMatrixSetterShort multiplyMatrix3x1x5(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final short f00 = matrix1.get(0, 0); + final short f01 = matrix1.get(0, 1); + final short f02 = matrix1.get(0, 2); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + final short s30 = matrix2.get(3, 0); + final short s40 = matrix2.get(4, 0); + output.set(0, 0, (short) (f00 * s00)); + output.set(1, 0, (short) (f00 * s10)); + output.set(2, 0, (short) (f00 * s20)); + output.set(3, 0, (short) (f00 * s30)); + output.set(4, 0, (short) (f00 * s40)); + output.set(0, 1, (short) (f01 * s00)); + output.set(1, 1, (short) (f01 * s10)); + output.set(2, 1, (short) (f01 * s20)); + output.set(3, 1, (short) (f01 * s30)); + output.set(4, 1, (short) (f01 * s40)); + output.set(0, 2, (short) (f02 * s00)); + output.set(1, 2, (short) (f02 * s10)); + output.set(2, 2, (short) (f02 * s20)); + output.set(3, 2, (short) (f02 * s30)); + output.set(4, 2, (short) (f02 * s40)); + return output; + } + + private static IMatrixSetterShort multiplyMatrix4x1x1(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final short f00 = matrix1.get(0, 0); + final short f01 = matrix1.get(0, 1); + final short f02 = matrix1.get(0, 2); + final short f03 = matrix1.get(0, 3); + final short s00 = matrix2.get(0, 0); + output.set(0, 0, (short) (f00 * s00)); + output.set(0, 1, (short) (f01 * s00)); + output.set(0, 2, (short) (f02 * s00)); + output.set(0, 3, (short) (f03 * s00)); + return output; + } + + private static IMatrixSetterShort multiplyMatrix4x1x2(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final short f00 = matrix1.get(0, 0); + final short f01 = matrix1.get(0, 1); + final short f02 = matrix1.get(0, 2); + final short f03 = matrix1.get(0, 3); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + output.set(0, 0, (short) (f00 * s00)); + output.set(1, 0, (short) (f00 * s10)); + output.set(0, 1, (short) (f01 * s00)); + output.set(1, 1, (short) (f01 * s10)); + output.set(0, 2, (short) (f02 * s00)); + output.set(1, 2, (short) (f02 * s10)); + output.set(0, 3, (short) (f03 * s00)); + output.set(1, 3, (short) (f03 * s10)); + return output; + } + + private static IMatrixSetterShort multiplyMatrix4x1x3(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final short f00 = matrix1.get(0, 0); + final short f01 = matrix1.get(0, 1); + final short f02 = matrix1.get(0, 2); + final short f03 = matrix1.get(0, 3); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + output.set(0, 0, (short) (f00 * s00)); + output.set(1, 0, (short) (f00 * s10)); + output.set(2, 0, (short) (f00 * s20)); + output.set(0, 1, (short) (f01 * s00)); + output.set(1, 1, (short) (f01 * s10)); + output.set(2, 1, (short) (f01 * s20)); + output.set(0, 2, (short) (f02 * s00)); + output.set(1, 2, (short) (f02 * s10)); + output.set(2, 2, (short) (f02 * s20)); + output.set(0, 3, (short) (f03 * s00)); + output.set(1, 3, (short) (f03 * s10)); + output.set(2, 3, (short) (f03 * s20)); + return output; + } + + private static IMatrixSetterShort multiplyMatrix4x1x4(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final short f00 = matrix1.get(0, 0); + final short f01 = matrix1.get(0, 1); + final short f02 = matrix1.get(0, 2); + final short f03 = matrix1.get(0, 3); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + final short s30 = matrix2.get(3, 0); + output.set(0, 0, (short) (f00 * s00)); + output.set(1, 0, (short) (f00 * s10)); + output.set(2, 0, (short) (f00 * s20)); + output.set(3, 0, (short) (f00 * s30)); + output.set(0, 1, (short) (f01 * s00)); + output.set(1, 1, (short) (f01 * s10)); + output.set(2, 1, (short) (f01 * s20)); + output.set(3, 1, (short) (f01 * s30)); + output.set(0, 2, (short) (f02 * s00)); + output.set(1, 2, (short) (f02 * s10)); + output.set(2, 2, (short) (f02 * s20)); + output.set(3, 2, (short) (f02 * s30)); + output.set(0, 3, (short) (f03 * s00)); + output.set(1, 3, (short) (f03 * s10)); + output.set(2, 3, (short) (f03 * s20)); + output.set(3, 3, (short) (f03 * s30)); + return output; + } + + private static IMatrixSetterShort multiplyMatrix4x1x5(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final short f00 = matrix1.get(0, 0); + final short f01 = matrix1.get(0, 1); + final short f02 = matrix1.get(0, 2); + final short f03 = matrix1.get(0, 3); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + final short s30 = matrix2.get(3, 0); + final short s40 = matrix2.get(4, 0); + output.set(0, 0, (short) (f00 * s00)); + output.set(1, 0, (short) (f00 * s10)); + output.set(2, 0, (short) (f00 * s20)); + output.set(3, 0, (short) (f00 * s30)); + output.set(4, 0, (short) (f00 * s40)); + output.set(0, 1, (short) (f01 * s00)); + output.set(1, 1, (short) (f01 * s10)); + output.set(2, 1, (short) (f01 * s20)); + output.set(3, 1, (short) (f01 * s30)); + output.set(4, 1, (short) (f01 * s40)); + output.set(0, 2, (short) (f02 * s00)); + output.set(1, 2, (short) (f02 * s10)); + output.set(2, 2, (short) (f02 * s20)); + output.set(3, 2, (short) (f02 * s30)); + output.set(4, 2, (short) (f02 * s40)); + output.set(0, 3, (short) (f03 * s00)); + output.set(1, 3, (short) (f03 * s10)); + output.set(2, 3, (short) (f03 * s20)); + output.set(3, 3, (short) (f03 * s30)); + output.set(4, 3, (short) (f03 * s40)); + return output; + } + + private static IMatrixSetterShort multiplyMatrix5x1x1(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final short f00 = matrix1.get(0, 0); + final short f01 = matrix1.get(0, 1); + final short f02 = matrix1.get(0, 2); + final short f03 = matrix1.get(0, 3); + final short f04 = matrix1.get(0, 4); + final short s00 = matrix2.get(0, 0); + output.set(0, 0, (short) (f00 * s00)); + output.set(0, 1, (short) (f01 * s00)); + output.set(0, 2, (short) (f02 * s00)); + output.set(0, 3, (short) (f03 * s00)); + output.set(0, 4, (short) (f04 * s00)); + return output; + } + + private static IMatrixSetterShort multiplyMatrix5x1x2(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final short f00 = matrix1.get(0, 0); + final short f01 = matrix1.get(0, 1); + final short f02 = matrix1.get(0, 2); + final short f03 = matrix1.get(0, 3); + final short f04 = matrix1.get(0, 4); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + output.set(0, 0, (short) (f00 * s00)); + output.set(1, 0, (short) (f00 * s10)); + output.set(0, 1, (short) (f01 * s00)); + output.set(1, 1, (short) (f01 * s10)); + output.set(0, 2, (short) (f02 * s00)); + output.set(1, 2, (short) (f02 * s10)); + output.set(0, 3, (short) (f03 * s00)); + output.set(1, 3, (short) (f03 * s10)); + output.set(0, 4, (short) (f04 * s00)); + output.set(1, 4, (short) (f04 * s10)); + return output; + } + + private static IMatrixSetterShort multiplyMatrix5x1x3(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final short f00 = matrix1.get(0, 0); + final short f01 = matrix1.get(0, 1); + final short f02 = matrix1.get(0, 2); + final short f03 = matrix1.get(0, 3); + final short f04 = matrix1.get(0, 4); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + output.set(0, 0, (short) (f00 * s00)); + output.set(1, 0, (short) (f00 * s10)); + output.set(2, 0, (short) (f00 * s20)); + output.set(0, 1, (short) (f01 * s00)); + output.set(1, 1, (short) (f01 * s10)); + output.set(2, 1, (short) (f01 * s20)); + output.set(0, 2, (short) (f02 * s00)); + output.set(1, 2, (short) (f02 * s10)); + output.set(2, 2, (short) (f02 * s20)); + output.set(0, 3, (short) (f03 * s00)); + output.set(1, 3, (short) (f03 * s10)); + output.set(2, 3, (short) (f03 * s20)); + output.set(0, 4, (short) (f04 * s00)); + output.set(1, 4, (short) (f04 * s10)); + output.set(2, 4, (short) (f04 * s20)); + return output; + } + + private static IMatrixSetterShort multiplyMatrix5x1x4(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final short f00 = matrix1.get(0, 0); + final short f01 = matrix1.get(0, 1); + final short f02 = matrix1.get(0, 2); + final short f03 = matrix1.get(0, 3); + final short f04 = matrix1.get(0, 4); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + final short s30 = matrix2.get(3, 0); + output.set(0, 0, (short) (f00 * s00)); + output.set(1, 0, (short) (f00 * s10)); + output.set(2, 0, (short) (f00 * s20)); + output.set(3, 0, (short) (f00 * s30)); + output.set(0, 1, (short) (f01 * s00)); + output.set(1, 1, (short) (f01 * s10)); + output.set(2, 1, (short) (f01 * s20)); + output.set(3, 1, (short) (f01 * s30)); + output.set(0, 2, (short) (f02 * s00)); + output.set(1, 2, (short) (f02 * s10)); + output.set(2, 2, (short) (f02 * s20)); + output.set(3, 2, (short) (f02 * s30)); + output.set(0, 3, (short) (f03 * s00)); + output.set(1, 3, (short) (f03 * s10)); + output.set(2, 3, (short) (f03 * s20)); + output.set(3, 3, (short) (f03 * s30)); + output.set(0, 4, (short) (f04 * s00)); + output.set(1, 4, (short) (f04 * s10)); + output.set(2, 4, (short) (f04 * s20)); + output.set(3, 4, (short) (f04 * s30)); + return output; + } + + private static IMatrixSetterShort multiplyMatrix5x1x5(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final short f00 = matrix1.get(0, 0); + final short f01 = matrix1.get(0, 1); + final short f02 = matrix1.get(0, 2); + final short f03 = matrix1.get(0, 3); + final short f04 = matrix1.get(0, 4); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + final short s30 = matrix2.get(3, 0); + final short s40 = matrix2.get(4, 0); + output.set(0, 0, (short) (f00 * s00)); + output.set(1, 0, (short) (f00 * s10)); + output.set(2, 0, (short) (f00 * s20)); + output.set(3, 0, (short) (f00 * s30)); + output.set(4, 0, (short) (f00 * s40)); + output.set(0, 1, (short) (f01 * s00)); + output.set(1, 1, (short) (f01 * s10)); + output.set(2, 1, (short) (f01 * s20)); + output.set(3, 1, (short) (f01 * s30)); + output.set(4, 1, (short) (f01 * s40)); + output.set(0, 2, (short) (f02 * s00)); + output.set(1, 2, (short) (f02 * s10)); + output.set(2, 2, (short) (f02 * s20)); + output.set(3, 2, (short) (f02 * s30)); + output.set(4, 2, (short) (f02 * s40)); + output.set(0, 3, (short) (f03 * s00)); + output.set(1, 3, (short) (f03 * s10)); + output.set(2, 3, (short) (f03 * s20)); + output.set(3, 3, (short) (f03 * s30)); + output.set(4, 3, (short) (f03 * s40)); + output.set(0, 4, (short) (f04 * s00)); + output.set(1, 4, (short) (f04 * s10)); + output.set(2, 4, (short) (f04 * s20)); + output.set(3, 4, (short) (f04 * s30)); + output.set(4, 4, (short) (f04 * s40)); + return output; + } + + private static IMatrixSetterShort multiplyMatrix1x2x1(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short s00 = matrix2.get(0, 0); + final short s01 = matrix2.get(0, 1); + output.set(0, 0, (short) (f00 * s00 + f10 * s01)); + return output; + } + + private static IMatrixSetterShort multiplyMatrix1x2x2(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + output.set(0, 0, (short) (f00 * s00 + f10 * s01)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11)); + return output; + } + + private static IMatrixSetterShort multiplyMatrix1x2x3(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s21 = matrix2.get(2, 1); + output.set(0, 0, (short) (f00 * s00 + f10 * s01)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11)); + output.set(2, 0, (short) (f00 * s20 + f10 * s21)); + return output; + } + + private static IMatrixSetterShort multiplyMatrix1x2x4(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + final short s30 = matrix2.get(3, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s21 = matrix2.get(2, 1); + final short s31 = matrix2.get(3, 1); + output.set(0, 0, (short) (f00 * s00 + f10 * s01)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11)); + output.set(2, 0, (short) (f00 * s20 + f10 * s21)); + output.set(3, 0, (short) (f00 * s30 + f10 * s31)); + return output; + } + + private static IMatrixSetterShort multiplyMatrix1x2x5(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + final short s30 = matrix2.get(3, 0); + final short s40 = matrix2.get(4, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s21 = matrix2.get(2, 1); + final short s31 = matrix2.get(3, 1); + final short s41 = matrix2.get(4, 1); + output.set(0, 0, (short) (f00 * s00 + f10 * s01)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11)); + output.set(2, 0, (short) (f00 * s20 + f10 * s21)); + output.set(3, 0, (short) (f00 * s30 + f10 * s31)); + output.set(4, 0, (short) (f00 * s40 + f10 * s41)); + return output; + } + + private static IMatrixSetterShort multiplyMatrix2x2x1(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short s00 = matrix2.get(0, 0); + final short s01 = matrix2.get(0, 1); + output.set(0, 0, (short) (f00 * s00 + f10 * s01)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01)); + return output; + } private static IMatrixSetterShort multiplyMatrix2x2x2(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final short f_c00 = matrix1.get(0, 0); - final short f_c10 = matrix1.get(1, 0); - final short f_c01 = matrix1.get(0, 1); - final short f_c11 = matrix1.get(1, 1); - final short s_c00 = matrix2.get(0, 0); - final short s_c10 = matrix2.get(1, 0); - final short s_c01 = matrix2.get(0, 1); - final short s_c11 = matrix2.get(1, 1); - output.set(0, 0, (short) (f_c00*s_c00 + f_c10*s_c01)); - output.set(0, 1, (short) (f_c01*s_c00 + f_c11*s_c01)); - output.set(1, 0, (short) (f_c00*s_c10 + f_c10*s_c11)); - output.set(1, 1, (short) (f_c01*s_c10 + f_c11*s_c11)); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + output.set(0, 0, (short) (f00 * s00 + f10 * s01)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01)); + output.set(1, 1, (short) (f01 * s10 + f11 * s11)); return output; } private static IMatrixSetterShort multiplyMatrix2x2x3(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final short f_c00 = matrix1.get(0, 0); - final short f_c10 = matrix1.get(1, 0); - final short f_c01 = matrix1.get(0, 1); - final short f_c11 = matrix1.get(1, 1); - final short s_c00 = matrix2.get(0, 0); - final short s_c10 = matrix2.get(1, 0); - final short s_c20 = matrix2.get(2, 0); - final short s_c01 = matrix2.get(0, 1); - final short s_c11 = matrix2.get(1, 1); - final short s_c21 = matrix2.get(2, 1); - output.set(0, 0, (short) (f_c00*s_c00 + f_c10*s_c01)); - output.set(0, 1, (short) (f_c01*s_c00 + f_c11*s_c01)); - output.set(1, 0, (short) (f_c00*s_c10 + f_c10*s_c11)); - output.set(1, 1, (short) (f_c01*s_c10 + f_c11*s_c11)); - output.set(2, 0, (short) (f_c00*s_c20 + f_c10*s_c21)); - output.set(2, 1, (short) (f_c01*s_c20 + f_c11*s_c21)); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s21 = matrix2.get(2, 1); + output.set(0, 0, (short) (f00 * s00 + f10 * s01)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11)); + output.set(2, 0, (short) (f00 * s20 + f10 * s21)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01)); + output.set(1, 1, (short) (f01 * s10 + f11 * s11)); + output.set(2, 1, (short) (f01 * s20 + f11 * s21)); return output; } private static IMatrixSetterShort multiplyMatrix2x2x4(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final short f_c00 = matrix1.get(0, 0); - final short f_c10 = matrix1.get(1, 0); - final short f_c01 = matrix1.get(0, 1); - final short f_c11 = matrix1.get(1, 1); - final short s_c00 = matrix2.get(0, 0); - final short s_c10 = matrix2.get(1, 0); - final short s_c20 = matrix2.get(2, 0); - final short s_c30 = matrix2.get(3, 0); - final short s_c01 = matrix2.get(0, 1); - final short s_c11 = matrix2.get(1, 1); - final short s_c21 = matrix2.get(2, 1); - final short s_c31 = matrix2.get(3, 1); - output.set(0, 0, (short) (f_c00*s_c00 + f_c10*s_c01)); - output.set(0, 1, (short) (f_c01*s_c00 + f_c11*s_c01)); - output.set(1, 0, (short) (f_c00*s_c10 + f_c10*s_c11)); - output.set(1, 1, (short) (f_c01*s_c10 + f_c11*s_c11)); - output.set(2, 0, (short) (f_c00*s_c20 + f_c10*s_c21)); - output.set(2, 1, (short) (f_c01*s_c20 + f_c11*s_c21)); - output.set(3, 0, (short) (f_c00*s_c30 + f_c10*s_c31)); - output.set(3, 1, (short) (f_c01*s_c30 + f_c11*s_c31)); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + final short s30 = matrix2.get(3, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s21 = matrix2.get(2, 1); + final short s31 = matrix2.get(3, 1); + output.set(0, 0, (short) (f00 * s00 + f10 * s01)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11)); + output.set(2, 0, (short) (f00 * s20 + f10 * s21)); + output.set(3, 0, (short) (f00 * s30 + f10 * s31)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01)); + output.set(1, 1, (short) (f01 * s10 + f11 * s11)); + output.set(2, 1, (short) (f01 * s20 + f11 * s21)); + output.set(3, 1, (short) (f01 * s30 + f11 * s31)); return output; } private static IMatrixSetterShort multiplyMatrix2x2x5(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final short f_c00 = matrix1.get(0, 0); - final short f_c10 = matrix1.get(1, 0); - final short f_c01 = matrix1.get(0, 1); - final short f_c11 = matrix1.get(1, 1); - final short s_c00 = matrix2.get(0, 0); - final short s_c10 = matrix2.get(1, 0); - final short s_c20 = matrix2.get(2, 0); - final short s_c30 = matrix2.get(3, 0); - final short s_c40 = matrix2.get(4, 0); - final short s_c01 = matrix2.get(0, 1); - final short s_c11 = matrix2.get(1, 1); - final short s_c21 = matrix2.get(2, 1); - final short s_c31 = matrix2.get(3, 1); - final short s_c41 = matrix2.get(4, 1); - output.set(0, 0, (short) (f_c00*s_c00 + f_c10*s_c01)); - output.set(0, 1, (short) (f_c01*s_c00 + f_c11*s_c01)); - output.set(1, 0, (short) (f_c00*s_c10 + f_c10*s_c11)); - output.set(1, 1, (short) (f_c01*s_c10 + f_c11*s_c11)); - output.set(2, 0, (short) (f_c00*s_c20 + f_c10*s_c21)); - output.set(2, 1, (short) (f_c01*s_c20 + f_c11*s_c21)); - output.set(3, 0, (short) (f_c00*s_c30 + f_c10*s_c31)); - output.set(3, 1, (short) (f_c01*s_c30 + f_c11*s_c31)); - output.set(4, 0, (short) (f_c00*s_c40 + f_c10*s_c41)); - output.set(4, 1, (short) (f_c01*s_c40 + f_c11*s_c41)); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + final short s30 = matrix2.get(3, 0); + final short s40 = matrix2.get(4, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s21 = matrix2.get(2, 1); + final short s31 = matrix2.get(3, 1); + final short s41 = matrix2.get(4, 1); + output.set(0, 0, (short) (f00 * s00 + f10 * s01)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11)); + output.set(2, 0, (short) (f00 * s20 + f10 * s21)); + output.set(3, 0, (short) (f00 * s30 + f10 * s31)); + output.set(4, 0, (short) (f00 * s40 + f10 * s41)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01)); + output.set(1, 1, (short) (f01 * s10 + f11 * s11)); + output.set(2, 1, (short) (f01 * s20 + f11 * s21)); + output.set(3, 1, (short) (f01 * s30 + f11 * s31)); + output.set(4, 1, (short) (f01 * s40 + f11 * s41)); + return output; + } + + private static IMatrixSetterShort multiplyMatrix3x2x1(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f02 = matrix1.get(0, 2); + final short f12 = matrix1.get(1, 2); + final short s00 = matrix2.get(0, 0); + final short s01 = matrix2.get(0, 1); + output.set(0, 0, (short) (f00 * s00 + f10 * s01)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01)); + output.set(0, 2, (short) (f02 * s00 + f12 * s01)); return output; } private static IMatrixSetterShort multiplyMatrix3x2x2(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final short f_c00 = matrix1.get(0, 0); - final short f_c10 = matrix1.get(1, 0); - final short f_c01 = matrix1.get(0, 1); - final short f_c11 = matrix1.get(1, 1); - final short f_c02 = matrix1.get(0, 2); - final short f_c12 = matrix1.get(1, 2); - final short s_c00 = matrix2.get(0, 0); - final short s_c10 = matrix2.get(1, 0); - final short s_c01 = matrix2.get(0, 1); - final short s_c11 = matrix2.get(1, 1); - output.set(0, 0, (short) (f_c00*s_c00 + f_c10*s_c01)); - output.set(0, 1, (short) (f_c01*s_c00 + f_c11*s_c01)); - output.set(0, 2, (short) (f_c02*s_c00 + f_c12*s_c01)); - output.set(1, 0, (short) (f_c00*s_c10 + f_c10*s_c11)); - output.set(1, 1, (short) (f_c01*s_c10 + f_c11*s_c11)); - output.set(1, 2, (short) (f_c02*s_c10 + f_c12*s_c11)); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f02 = matrix1.get(0, 2); + final short f12 = matrix1.get(1, 2); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + output.set(0, 0, (short) (f00 * s00 + f10 * s01)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01)); + output.set(1, 1, (short) (f01 * s10 + f11 * s11)); + output.set(0, 2, (short) (f02 * s00 + f12 * s01)); + output.set(1, 2, (short) (f02 * s10 + f12 * s11)); return output; } private static IMatrixSetterShort multiplyMatrix3x2x3(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final short f_c00 = matrix1.get(0, 0); - final short f_c10 = matrix1.get(1, 0); - final short f_c01 = matrix1.get(0, 1); - final short f_c11 = matrix1.get(1, 1); - final short f_c02 = matrix1.get(0, 2); - final short f_c12 = matrix1.get(1, 2); - final short s_c00 = matrix2.get(0, 0); - final short s_c10 = matrix2.get(1, 0); - final short s_c20 = matrix2.get(2, 0); - final short s_c01 = matrix2.get(0, 1); - final short s_c11 = matrix2.get(1, 1); - final short s_c21 = matrix2.get(2, 1); - output.set(0, 0, (short) (f_c00*s_c00 + f_c10*s_c01)); - output.set(0, 1, (short) (f_c01*s_c00 + f_c11*s_c01)); - output.set(0, 2, (short) (f_c02*s_c00 + f_c12*s_c01)); - output.set(1, 0, (short) (f_c00*s_c10 + f_c10*s_c11)); - output.set(1, 1, (short) (f_c01*s_c10 + f_c11*s_c11)); - output.set(1, 2, (short) (f_c02*s_c10 + f_c12*s_c11)); - output.set(2, 0, (short) (f_c00*s_c20 + f_c10*s_c21)); - output.set(2, 1, (short) (f_c01*s_c20 + f_c11*s_c21)); - output.set(2, 2, (short) (f_c02*s_c20 + f_c12*s_c21)); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f02 = matrix1.get(0, 2); + final short f12 = matrix1.get(1, 2); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s21 = matrix2.get(2, 1); + output.set(0, 0, (short) (f00 * s00 + f10 * s01)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11)); + output.set(2, 0, (short) (f00 * s20 + f10 * s21)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01)); + output.set(1, 1, (short) (f01 * s10 + f11 * s11)); + output.set(2, 1, (short) (f01 * s20 + f11 * s21)); + output.set(0, 2, (short) (f02 * s00 + f12 * s01)); + output.set(1, 2, (short) (f02 * s10 + f12 * s11)); + output.set(2, 2, (short) (f02 * s20 + f12 * s21)); return output; } private static IMatrixSetterShort multiplyMatrix3x2x4(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final short f_c00 = matrix1.get(0, 0); - final short f_c10 = matrix1.get(1, 0); - final short f_c01 = matrix1.get(0, 1); - final short f_c11 = matrix1.get(1, 1); - final short f_c02 = matrix1.get(0, 2); - final short f_c12 = matrix1.get(1, 2); - final short s_c00 = matrix2.get(0, 0); - final short s_c10 = matrix2.get(1, 0); - final short s_c20 = matrix2.get(2, 0); - final short s_c30 = matrix2.get(3, 0); - final short s_c01 = matrix2.get(0, 1); - final short s_c11 = matrix2.get(1, 1); - final short s_c21 = matrix2.get(2, 1); - final short s_c31 = matrix2.get(3, 1); - output.set(0, 0, (short) (f_c00*s_c00 + f_c10*s_c01)); - output.set(0, 1, (short) (f_c01*s_c00 + f_c11*s_c01)); - output.set(0, 2, (short) (f_c02*s_c00 + f_c12*s_c01)); - output.set(1, 0, (short) (f_c00*s_c10 + f_c10*s_c11)); - output.set(1, 1, (short) (f_c01*s_c10 + f_c11*s_c11)); - output.set(1, 2, (short) (f_c02*s_c10 + f_c12*s_c11)); - output.set(2, 0, (short) (f_c00*s_c20 + f_c10*s_c21)); - output.set(2, 1, (short) (f_c01*s_c20 + f_c11*s_c21)); - output.set(2, 2, (short) (f_c02*s_c20 + f_c12*s_c21)); - output.set(3, 0, (short) (f_c00*s_c30 + f_c10*s_c31)); - output.set(3, 1, (short) (f_c01*s_c30 + f_c11*s_c31)); - output.set(3, 2, (short) (f_c02*s_c30 + f_c12*s_c31)); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f02 = matrix1.get(0, 2); + final short f12 = matrix1.get(1, 2); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + final short s30 = matrix2.get(3, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s21 = matrix2.get(2, 1); + final short s31 = matrix2.get(3, 1); + output.set(0, 0, (short) (f00 * s00 + f10 * s01)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11)); + output.set(2, 0, (short) (f00 * s20 + f10 * s21)); + output.set(3, 0, (short) (f00 * s30 + f10 * s31)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01)); + output.set(1, 1, (short) (f01 * s10 + f11 * s11)); + output.set(2, 1, (short) (f01 * s20 + f11 * s21)); + output.set(3, 1, (short) (f01 * s30 + f11 * s31)); + output.set(0, 2, (short) (f02 * s00 + f12 * s01)); + output.set(1, 2, (short) (f02 * s10 + f12 * s11)); + output.set(2, 2, (short) (f02 * s20 + f12 * s21)); + output.set(3, 2, (short) (f02 * s30 + f12 * s31)); return output; } private static IMatrixSetterShort multiplyMatrix3x2x5(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final short f_c00 = matrix1.get(0, 0); - final short f_c10 = matrix1.get(1, 0); - final short f_c01 = matrix1.get(0, 1); - final short f_c11 = matrix1.get(1, 1); - final short f_c02 = matrix1.get(0, 2); - final short f_c12 = matrix1.get(1, 2); - final short s_c00 = matrix2.get(0, 0); - final short s_c10 = matrix2.get(1, 0); - final short s_c20 = matrix2.get(2, 0); - final short s_c30 = matrix2.get(3, 0); - final short s_c40 = matrix2.get(4, 0); - final short s_c01 = matrix2.get(0, 1); - final short s_c11 = matrix2.get(1, 1); - final short s_c21 = matrix2.get(2, 1); - final short s_c31 = matrix2.get(3, 1); - final short s_c41 = matrix2.get(4, 1); - output.set(0, 0, (short) (f_c00*s_c00 + f_c10*s_c01)); - output.set(0, 1, (short) (f_c01*s_c00 + f_c11*s_c01)); - output.set(0, 2, (short) (f_c02*s_c00 + f_c12*s_c01)); - output.set(1, 0, (short) (f_c00*s_c10 + f_c10*s_c11)); - output.set(1, 1, (short) (f_c01*s_c10 + f_c11*s_c11)); - output.set(1, 2, (short) (f_c02*s_c10 + f_c12*s_c11)); - output.set(2, 0, (short) (f_c00*s_c20 + f_c10*s_c21)); - output.set(2, 1, (short) (f_c01*s_c20 + f_c11*s_c21)); - output.set(2, 2, (short) (f_c02*s_c20 + f_c12*s_c21)); - output.set(3, 0, (short) (f_c00*s_c30 + f_c10*s_c31)); - output.set(3, 1, (short) (f_c01*s_c30 + f_c11*s_c31)); - output.set(3, 2, (short) (f_c02*s_c30 + f_c12*s_c31)); - output.set(4, 0, (short) (f_c00*s_c40 + f_c10*s_c41)); - output.set(4, 1, (short) (f_c01*s_c40 + f_c11*s_c41)); - output.set(4, 2, (short) (f_c02*s_c40 + f_c12*s_c41)); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f02 = matrix1.get(0, 2); + final short f12 = matrix1.get(1, 2); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + final short s30 = matrix2.get(3, 0); + final short s40 = matrix2.get(4, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s21 = matrix2.get(2, 1); + final short s31 = matrix2.get(3, 1); + final short s41 = matrix2.get(4, 1); + output.set(0, 0, (short) (f00 * s00 + f10 * s01)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11)); + output.set(2, 0, (short) (f00 * s20 + f10 * s21)); + output.set(3, 0, (short) (f00 * s30 + f10 * s31)); + output.set(4, 0, (short) (f00 * s40 + f10 * s41)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01)); + output.set(1, 1, (short) (f01 * s10 + f11 * s11)); + output.set(2, 1, (short) (f01 * s20 + f11 * s21)); + output.set(3, 1, (short) (f01 * s30 + f11 * s31)); + output.set(4, 1, (short) (f01 * s40 + f11 * s41)); + output.set(0, 2, (short) (f02 * s00 + f12 * s01)); + output.set(1, 2, (short) (f02 * s10 + f12 * s11)); + output.set(2, 2, (short) (f02 * s20 + f12 * s21)); + output.set(3, 2, (short) (f02 * s30 + f12 * s31)); + output.set(4, 2, (short) (f02 * s40 + f12 * s41)); + return output; + } + + private static IMatrixSetterShort multiplyMatrix4x2x1(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f02 = matrix1.get(0, 2); + final short f12 = matrix1.get(1, 2); + final short f03 = matrix1.get(0, 3); + final short f13 = matrix1.get(1, 3); + final short s00 = matrix2.get(0, 0); + final short s01 = matrix2.get(0, 1); + output.set(0, 0, (short) (f00 * s00 + f10 * s01)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01)); + output.set(0, 2, (short) (f02 * s00 + f12 * s01)); + output.set(0, 3, (short) (f03 * s00 + f13 * s01)); return output; } private static IMatrixSetterShort multiplyMatrix4x2x2(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final short f_c00 = matrix1.get(0, 0); - final short f_c10 = matrix1.get(1, 0); - final short f_c01 = matrix1.get(0, 1); - final short f_c11 = matrix1.get(1, 1); - final short f_c02 = matrix1.get(0, 2); - final short f_c12 = matrix1.get(1, 2); - final short f_c03 = matrix1.get(0, 3); - final short f_c13 = matrix1.get(1, 3); - final short s_c00 = matrix2.get(0, 0); - final short s_c10 = matrix2.get(1, 0); - final short s_c01 = matrix2.get(0, 1); - final short s_c11 = matrix2.get(1, 1); - output.set(0, 0, (short) (f_c00*s_c00 + f_c10*s_c01)); - output.set(0, 1, (short) (f_c01*s_c00 + f_c11*s_c01)); - output.set(0, 2, (short) (f_c02*s_c00 + f_c12*s_c01)); - output.set(0, 3, (short) (f_c03*s_c00 + f_c13*s_c01)); - output.set(1, 0, (short) (f_c00*s_c10 + f_c10*s_c11)); - output.set(1, 1, (short) (f_c01*s_c10 + f_c11*s_c11)); - output.set(1, 2, (short) (f_c02*s_c10 + f_c12*s_c11)); - output.set(1, 3, (short) (f_c03*s_c10 + f_c13*s_c11)); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f02 = matrix1.get(0, 2); + final short f12 = matrix1.get(1, 2); + final short f03 = matrix1.get(0, 3); + final short f13 = matrix1.get(1, 3); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + output.set(0, 0, (short) (f00 * s00 + f10 * s01)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01)); + output.set(1, 1, (short) (f01 * s10 + f11 * s11)); + output.set(0, 2, (short) (f02 * s00 + f12 * s01)); + output.set(1, 2, (short) (f02 * s10 + f12 * s11)); + output.set(0, 3, (short) (f03 * s00 + f13 * s01)); + output.set(1, 3, (short) (f03 * s10 + f13 * s11)); return output; } private static IMatrixSetterShort multiplyMatrix4x2x3(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final short f_c00 = matrix1.get(0, 0); - final short f_c10 = matrix1.get(1, 0); - final short f_c01 = matrix1.get(0, 1); - final short f_c11 = matrix1.get(1, 1); - final short f_c02 = matrix1.get(0, 2); - final short f_c12 = matrix1.get(1, 2); - final short f_c03 = matrix1.get(0, 3); - final short f_c13 = matrix1.get(1, 3); - final short s_c00 = matrix2.get(0, 0); - final short s_c10 = matrix2.get(1, 0); - final short s_c20 = matrix2.get(2, 0); - final short s_c01 = matrix2.get(0, 1); - final short s_c11 = matrix2.get(1, 1); - final short s_c21 = matrix2.get(2, 1); - output.set(0, 0, (short) (f_c00*s_c00 + f_c10*s_c01)); - output.set(0, 1, (short) (f_c01*s_c00 + f_c11*s_c01)); - output.set(0, 2, (short) (f_c02*s_c00 + f_c12*s_c01)); - output.set(0, 3, (short) (f_c03*s_c00 + f_c13*s_c01)); - output.set(1, 0, (short) (f_c00*s_c10 + f_c10*s_c11)); - output.set(1, 1, (short) (f_c01*s_c10 + f_c11*s_c11)); - output.set(1, 2, (short) (f_c02*s_c10 + f_c12*s_c11)); - output.set(1, 3, (short) (f_c03*s_c10 + f_c13*s_c11)); - output.set(2, 0, (short) (f_c00*s_c20 + f_c10*s_c21)); - output.set(2, 1, (short) (f_c01*s_c20 + f_c11*s_c21)); - output.set(2, 2, (short) (f_c02*s_c20 + f_c12*s_c21)); - output.set(2, 3, (short) (f_c03*s_c20 + f_c13*s_c21)); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f02 = matrix1.get(0, 2); + final short f12 = matrix1.get(1, 2); + final short f03 = matrix1.get(0, 3); + final short f13 = matrix1.get(1, 3); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s21 = matrix2.get(2, 1); + output.set(0, 0, (short) (f00 * s00 + f10 * s01)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11)); + output.set(2, 0, (short) (f00 * s20 + f10 * s21)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01)); + output.set(1, 1, (short) (f01 * s10 + f11 * s11)); + output.set(2, 1, (short) (f01 * s20 + f11 * s21)); + output.set(0, 2, (short) (f02 * s00 + f12 * s01)); + output.set(1, 2, (short) (f02 * s10 + f12 * s11)); + output.set(2, 2, (short) (f02 * s20 + f12 * s21)); + output.set(0, 3, (short) (f03 * s00 + f13 * s01)); + output.set(1, 3, (short) (f03 * s10 + f13 * s11)); + output.set(2, 3, (short) (f03 * s20 + f13 * s21)); return output; } private static IMatrixSetterShort multiplyMatrix4x2x4(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final short f_c00 = matrix1.get(0, 0); - final short f_c10 = matrix1.get(1, 0); - final short f_c01 = matrix1.get(0, 1); - final short f_c11 = matrix1.get(1, 1); - final short f_c02 = matrix1.get(0, 2); - final short f_c12 = matrix1.get(1, 2); - final short f_c03 = matrix1.get(0, 3); - final short f_c13 = matrix1.get(1, 3); - final short s_c00 = matrix2.get(0, 0); - final short s_c10 = matrix2.get(1, 0); - final short s_c20 = matrix2.get(2, 0); - final short s_c30 = matrix2.get(3, 0); - final short s_c01 = matrix2.get(0, 1); - final short s_c11 = matrix2.get(1, 1); - final short s_c21 = matrix2.get(2, 1); - final short s_c31 = matrix2.get(3, 1); - output.set(0, 0, (short) (f_c00*s_c00 + f_c10*s_c01)); - output.set(0, 1, (short) (f_c01*s_c00 + f_c11*s_c01)); - output.set(0, 2, (short) (f_c02*s_c00 + f_c12*s_c01)); - output.set(0, 3, (short) (f_c03*s_c00 + f_c13*s_c01)); - output.set(1, 0, (short) (f_c00*s_c10 + f_c10*s_c11)); - output.set(1, 1, (short) (f_c01*s_c10 + f_c11*s_c11)); - output.set(1, 2, (short) (f_c02*s_c10 + f_c12*s_c11)); - output.set(1, 3, (short) (f_c03*s_c10 + f_c13*s_c11)); - output.set(2, 0, (short) (f_c00*s_c20 + f_c10*s_c21)); - output.set(2, 1, (short) (f_c01*s_c20 + f_c11*s_c21)); - output.set(2, 2, (short) (f_c02*s_c20 + f_c12*s_c21)); - output.set(2, 3, (short) (f_c03*s_c20 + f_c13*s_c21)); - output.set(3, 0, (short) (f_c00*s_c30 + f_c10*s_c31)); - output.set(3, 1, (short) (f_c01*s_c30 + f_c11*s_c31)); - output.set(3, 2, (short) (f_c02*s_c30 + f_c12*s_c31)); - output.set(3, 3, (short) (f_c03*s_c30 + f_c13*s_c31)); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f02 = matrix1.get(0, 2); + final short f12 = matrix1.get(1, 2); + final short f03 = matrix1.get(0, 3); + final short f13 = matrix1.get(1, 3); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + final short s30 = matrix2.get(3, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s21 = matrix2.get(2, 1); + final short s31 = matrix2.get(3, 1); + output.set(0, 0, (short) (f00 * s00 + f10 * s01)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11)); + output.set(2, 0, (short) (f00 * s20 + f10 * s21)); + output.set(3, 0, (short) (f00 * s30 + f10 * s31)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01)); + output.set(1, 1, (short) (f01 * s10 + f11 * s11)); + output.set(2, 1, (short) (f01 * s20 + f11 * s21)); + output.set(3, 1, (short) (f01 * s30 + f11 * s31)); + output.set(0, 2, (short) (f02 * s00 + f12 * s01)); + output.set(1, 2, (short) (f02 * s10 + f12 * s11)); + output.set(2, 2, (short) (f02 * s20 + f12 * s21)); + output.set(3, 2, (short) (f02 * s30 + f12 * s31)); + output.set(0, 3, (short) (f03 * s00 + f13 * s01)); + output.set(1, 3, (short) (f03 * s10 + f13 * s11)); + output.set(2, 3, (short) (f03 * s20 + f13 * s21)); + output.set(3, 3, (short) (f03 * s30 + f13 * s31)); return output; } private static IMatrixSetterShort multiplyMatrix4x2x5(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final short f_c00 = matrix1.get(0, 0); - final short f_c10 = matrix1.get(1, 0); - final short f_c01 = matrix1.get(0, 1); - final short f_c11 = matrix1.get(1, 1); - final short f_c02 = matrix1.get(0, 2); - final short f_c12 = matrix1.get(1, 2); - final short f_c03 = matrix1.get(0, 3); - final short f_c13 = matrix1.get(1, 3); - final short s_c00 = matrix2.get(0, 0); - final short s_c10 = matrix2.get(1, 0); - final short s_c20 = matrix2.get(2, 0); - final short s_c30 = matrix2.get(3, 0); - final short s_c40 = matrix2.get(4, 0); - final short s_c01 = matrix2.get(0, 1); - final short s_c11 = matrix2.get(1, 1); - final short s_c21 = matrix2.get(2, 1); - final short s_c31 = matrix2.get(3, 1); - final short s_c41 = matrix2.get(4, 1); - output.set(0, 0, (short) (f_c00*s_c00 + f_c10*s_c01)); - output.set(0, 1, (short) (f_c01*s_c00 + f_c11*s_c01)); - output.set(0, 2, (short) (f_c02*s_c00 + f_c12*s_c01)); - output.set(0, 3, (short) (f_c03*s_c00 + f_c13*s_c01)); - output.set(1, 0, (short) (f_c00*s_c10 + f_c10*s_c11)); - output.set(1, 1, (short) (f_c01*s_c10 + f_c11*s_c11)); - output.set(1, 2, (short) (f_c02*s_c10 + f_c12*s_c11)); - output.set(1, 3, (short) (f_c03*s_c10 + f_c13*s_c11)); - output.set(2, 0, (short) (f_c00*s_c20 + f_c10*s_c21)); - output.set(2, 1, (short) (f_c01*s_c20 + f_c11*s_c21)); - output.set(2, 2, (short) (f_c02*s_c20 + f_c12*s_c21)); - output.set(2, 3, (short) (f_c03*s_c20 + f_c13*s_c21)); - output.set(3, 0, (short) (f_c00*s_c30 + f_c10*s_c31)); - output.set(3, 1, (short) (f_c01*s_c30 + f_c11*s_c31)); - output.set(3, 2, (short) (f_c02*s_c30 + f_c12*s_c31)); - output.set(3, 3, (short) (f_c03*s_c30 + f_c13*s_c31)); - output.set(4, 0, (short) (f_c00*s_c40 + f_c10*s_c41)); - output.set(4, 1, (short) (f_c01*s_c40 + f_c11*s_c41)); - output.set(4, 2, (short) (f_c02*s_c40 + f_c12*s_c41)); - output.set(4, 3, (short) (f_c03*s_c40 + f_c13*s_c41)); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f02 = matrix1.get(0, 2); + final short f12 = matrix1.get(1, 2); + final short f03 = matrix1.get(0, 3); + final short f13 = matrix1.get(1, 3); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + final short s30 = matrix2.get(3, 0); + final short s40 = matrix2.get(4, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s21 = matrix2.get(2, 1); + final short s31 = matrix2.get(3, 1); + final short s41 = matrix2.get(4, 1); + output.set(0, 0, (short) (f00 * s00 + f10 * s01)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11)); + output.set(2, 0, (short) (f00 * s20 + f10 * s21)); + output.set(3, 0, (short) (f00 * s30 + f10 * s31)); + output.set(4, 0, (short) (f00 * s40 + f10 * s41)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01)); + output.set(1, 1, (short) (f01 * s10 + f11 * s11)); + output.set(2, 1, (short) (f01 * s20 + f11 * s21)); + output.set(3, 1, (short) (f01 * s30 + f11 * s31)); + output.set(4, 1, (short) (f01 * s40 + f11 * s41)); + output.set(0, 2, (short) (f02 * s00 + f12 * s01)); + output.set(1, 2, (short) (f02 * s10 + f12 * s11)); + output.set(2, 2, (short) (f02 * s20 + f12 * s21)); + output.set(3, 2, (short) (f02 * s30 + f12 * s31)); + output.set(4, 2, (short) (f02 * s40 + f12 * s41)); + output.set(0, 3, (short) (f03 * s00 + f13 * s01)); + output.set(1, 3, (short) (f03 * s10 + f13 * s11)); + output.set(2, 3, (short) (f03 * s20 + f13 * s21)); + output.set(3, 3, (short) (f03 * s30 + f13 * s31)); + output.set(4, 3, (short) (f03 * s40 + f13 * s41)); + return output; + } + + private static IMatrixSetterShort multiplyMatrix5x2x1(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f02 = matrix1.get(0, 2); + final short f12 = matrix1.get(1, 2); + final short f03 = matrix1.get(0, 3); + final short f13 = matrix1.get(1, 3); + final short f04 = matrix1.get(0, 4); + final short f14 = matrix1.get(1, 4); + final short s00 = matrix2.get(0, 0); + final short s01 = matrix2.get(0, 1); + output.set(0, 0, (short) (f00 * s00 + f10 * s01)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01)); + output.set(0, 2, (short) (f02 * s00 + f12 * s01)); + output.set(0, 3, (short) (f03 * s00 + f13 * s01)); + output.set(0, 4, (short) (f04 * s00 + f14 * s01)); return output; } private static IMatrixSetterShort multiplyMatrix5x2x2(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final short f_c00 = matrix1.get(0, 0); - final short f_c10 = matrix1.get(1, 0); - final short f_c01 = matrix1.get(0, 1); - final short f_c11 = matrix1.get(1, 1); - final short f_c02 = matrix1.get(0, 2); - final short f_c12 = matrix1.get(1, 2); - final short f_c03 = matrix1.get(0, 3); - final short f_c13 = matrix1.get(1, 3); - final short f_c04 = matrix1.get(0, 4); - final short f_c14 = matrix1.get(1, 4); - final short s_c00 = matrix2.get(0, 0); - final short s_c10 = matrix2.get(1, 0); - final short s_c01 = matrix2.get(0, 1); - final short s_c11 = matrix2.get(1, 1); - output.set(0, 0, (short) (f_c00*s_c00 + f_c10*s_c01)); - output.set(0, 1, (short) (f_c01*s_c00 + f_c11*s_c01)); - output.set(0, 2, (short) (f_c02*s_c00 + f_c12*s_c01)); - output.set(0, 3, (short) (f_c03*s_c00 + f_c13*s_c01)); - output.set(0, 4, (short) (f_c04*s_c00 + f_c14*s_c01)); - output.set(1, 0, (short) (f_c00*s_c10 + f_c10*s_c11)); - output.set(1, 1, (short) (f_c01*s_c10 + f_c11*s_c11)); - output.set(1, 2, (short) (f_c02*s_c10 + f_c12*s_c11)); - output.set(1, 3, (short) (f_c03*s_c10 + f_c13*s_c11)); - output.set(1, 4, (short) (f_c04*s_c10 + f_c14*s_c11)); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f02 = matrix1.get(0, 2); + final short f12 = matrix1.get(1, 2); + final short f03 = matrix1.get(0, 3); + final short f13 = matrix1.get(1, 3); + final short f04 = matrix1.get(0, 4); + final short f14 = matrix1.get(1, 4); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + output.set(0, 0, (short) (f00 * s00 + f10 * s01)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01)); + output.set(1, 1, (short) (f01 * s10 + f11 * s11)); + output.set(0, 2, (short) (f02 * s00 + f12 * s01)); + output.set(1, 2, (short) (f02 * s10 + f12 * s11)); + output.set(0, 3, (short) (f03 * s00 + f13 * s01)); + output.set(1, 3, (short) (f03 * s10 + f13 * s11)); + output.set(0, 4, (short) (f04 * s00 + f14 * s01)); + output.set(1, 4, (short) (f04 * s10 + f14 * s11)); return output; } private static IMatrixSetterShort multiplyMatrix5x2x3(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final short f_c00 = matrix1.get(0, 0); - final short f_c10 = matrix1.get(1, 0); - final short f_c01 = matrix1.get(0, 1); - final short f_c11 = matrix1.get(1, 1); - final short f_c02 = matrix1.get(0, 2); - final short f_c12 = matrix1.get(1, 2); - final short f_c03 = matrix1.get(0, 3); - final short f_c13 = matrix1.get(1, 3); - final short f_c04 = matrix1.get(0, 4); - final short f_c14 = matrix1.get(1, 4); - final short s_c00 = matrix2.get(0, 0); - final short s_c10 = matrix2.get(1, 0); - final short s_c20 = matrix2.get(2, 0); - final short s_c01 = matrix2.get(0, 1); - final short s_c11 = matrix2.get(1, 1); - final short s_c21 = matrix2.get(2, 1); - output.set(0, 0, (short) (f_c00*s_c00 + f_c10*s_c01)); - output.set(0, 1, (short) (f_c01*s_c00 + f_c11*s_c01)); - output.set(0, 2, (short) (f_c02*s_c00 + f_c12*s_c01)); - output.set(0, 3, (short) (f_c03*s_c00 + f_c13*s_c01)); - output.set(0, 4, (short) (f_c04*s_c00 + f_c14*s_c01)); - output.set(1, 0, (short) (f_c00*s_c10 + f_c10*s_c11)); - output.set(1, 1, (short) (f_c01*s_c10 + f_c11*s_c11)); - output.set(1, 2, (short) (f_c02*s_c10 + f_c12*s_c11)); - output.set(1, 3, (short) (f_c03*s_c10 + f_c13*s_c11)); - output.set(1, 4, (short) (f_c04*s_c10 + f_c14*s_c11)); - output.set(2, 0, (short) (f_c00*s_c20 + f_c10*s_c21)); - output.set(2, 1, (short) (f_c01*s_c20 + f_c11*s_c21)); - output.set(2, 2, (short) (f_c02*s_c20 + f_c12*s_c21)); - output.set(2, 3, (short) (f_c03*s_c20 + f_c13*s_c21)); - output.set(2, 4, (short) (f_c04*s_c20 + f_c14*s_c21)); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f02 = matrix1.get(0, 2); + final short f12 = matrix1.get(1, 2); + final short f03 = matrix1.get(0, 3); + final short f13 = matrix1.get(1, 3); + final short f04 = matrix1.get(0, 4); + final short f14 = matrix1.get(1, 4); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s21 = matrix2.get(2, 1); + output.set(0, 0, (short) (f00 * s00 + f10 * s01)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11)); + output.set(2, 0, (short) (f00 * s20 + f10 * s21)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01)); + output.set(1, 1, (short) (f01 * s10 + f11 * s11)); + output.set(2, 1, (short) (f01 * s20 + f11 * s21)); + output.set(0, 2, (short) (f02 * s00 + f12 * s01)); + output.set(1, 2, (short) (f02 * s10 + f12 * s11)); + output.set(2, 2, (short) (f02 * s20 + f12 * s21)); + output.set(0, 3, (short) (f03 * s00 + f13 * s01)); + output.set(1, 3, (short) (f03 * s10 + f13 * s11)); + output.set(2, 3, (short) (f03 * s20 + f13 * s21)); + output.set(0, 4, (short) (f04 * s00 + f14 * s01)); + output.set(1, 4, (short) (f04 * s10 + f14 * s11)); + output.set(2, 4, (short) (f04 * s20 + f14 * s21)); return output; } private static IMatrixSetterShort multiplyMatrix5x2x4(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final short f_c00 = matrix1.get(0, 0); - final short f_c10 = matrix1.get(1, 0); - final short f_c01 = matrix1.get(0, 1); - final short f_c11 = matrix1.get(1, 1); - final short f_c02 = matrix1.get(0, 2); - final short f_c12 = matrix1.get(1, 2); - final short f_c03 = matrix1.get(0, 3); - final short f_c13 = matrix1.get(1, 3); - final short f_c04 = matrix1.get(0, 4); - final short f_c14 = matrix1.get(1, 4); - final short s_c00 = matrix2.get(0, 0); - final short s_c10 = matrix2.get(1, 0); - final short s_c20 = matrix2.get(2, 0); - final short s_c30 = matrix2.get(3, 0); - final short s_c01 = matrix2.get(0, 1); - final short s_c11 = matrix2.get(1, 1); - final short s_c21 = matrix2.get(2, 1); - final short s_c31 = matrix2.get(3, 1); - output.set(0, 0, (short) (f_c00*s_c00 + f_c10*s_c01)); - output.set(0, 1, (short) (f_c01*s_c00 + f_c11*s_c01)); - output.set(0, 2, (short) (f_c02*s_c00 + f_c12*s_c01)); - output.set(0, 3, (short) (f_c03*s_c00 + f_c13*s_c01)); - output.set(0, 4, (short) (f_c04*s_c00 + f_c14*s_c01)); - output.set(1, 0, (short) (f_c00*s_c10 + f_c10*s_c11)); - output.set(1, 1, (short) (f_c01*s_c10 + f_c11*s_c11)); - output.set(1, 2, (short) (f_c02*s_c10 + f_c12*s_c11)); - output.set(1, 3, (short) (f_c03*s_c10 + f_c13*s_c11)); - output.set(1, 4, (short) (f_c04*s_c10 + f_c14*s_c11)); - output.set(2, 0, (short) (f_c00*s_c20 + f_c10*s_c21)); - output.set(2, 1, (short) (f_c01*s_c20 + f_c11*s_c21)); - output.set(2, 2, (short) (f_c02*s_c20 + f_c12*s_c21)); - output.set(2, 3, (short) (f_c03*s_c20 + f_c13*s_c21)); - output.set(2, 4, (short) (f_c04*s_c20 + f_c14*s_c21)); - output.set(3, 0, (short) (f_c00*s_c30 + f_c10*s_c31)); - output.set(3, 1, (short) (f_c01*s_c30 + f_c11*s_c31)); - output.set(3, 2, (short) (f_c02*s_c30 + f_c12*s_c31)); - output.set(3, 3, (short) (f_c03*s_c30 + f_c13*s_c31)); - output.set(3, 4, (short) (f_c04*s_c30 + f_c14*s_c31)); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f02 = matrix1.get(0, 2); + final short f12 = matrix1.get(1, 2); + final short f03 = matrix1.get(0, 3); + final short f13 = matrix1.get(1, 3); + final short f04 = matrix1.get(0, 4); + final short f14 = matrix1.get(1, 4); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + final short s30 = matrix2.get(3, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s21 = matrix2.get(2, 1); + final short s31 = matrix2.get(3, 1); + output.set(0, 0, (short) (f00 * s00 + f10 * s01)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11)); + output.set(2, 0, (short) (f00 * s20 + f10 * s21)); + output.set(3, 0, (short) (f00 * s30 + f10 * s31)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01)); + output.set(1, 1, (short) (f01 * s10 + f11 * s11)); + output.set(2, 1, (short) (f01 * s20 + f11 * s21)); + output.set(3, 1, (short) (f01 * s30 + f11 * s31)); + output.set(0, 2, (short) (f02 * s00 + f12 * s01)); + output.set(1, 2, (short) (f02 * s10 + f12 * s11)); + output.set(2, 2, (short) (f02 * s20 + f12 * s21)); + output.set(3, 2, (short) (f02 * s30 + f12 * s31)); + output.set(0, 3, (short) (f03 * s00 + f13 * s01)); + output.set(1, 3, (short) (f03 * s10 + f13 * s11)); + output.set(2, 3, (short) (f03 * s20 + f13 * s21)); + output.set(3, 3, (short) (f03 * s30 + f13 * s31)); + output.set(0, 4, (short) (f04 * s00 + f14 * s01)); + output.set(1, 4, (short) (f04 * s10 + f14 * s11)); + output.set(2, 4, (short) (f04 * s20 + f14 * s21)); + output.set(3, 4, (short) (f04 * s30 + f14 * s31)); return output; } private static IMatrixSetterShort multiplyMatrix5x2x5(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final short f_c00 = matrix1.get(0, 0); - final short f_c10 = matrix1.get(1, 0); - final short f_c01 = matrix1.get(0, 1); - final short f_c11 = matrix1.get(1, 1); - final short f_c02 = matrix1.get(0, 2); - final short f_c12 = matrix1.get(1, 2); - final short f_c03 = matrix1.get(0, 3); - final short f_c13 = matrix1.get(1, 3); - final short f_c04 = matrix1.get(0, 4); - final short f_c14 = matrix1.get(1, 4); - final short s_c00 = matrix2.get(0, 0); - final short s_c10 = matrix2.get(1, 0); - final short s_c20 = matrix2.get(2, 0); - final short s_c30 = matrix2.get(3, 0); - final short s_c40 = matrix2.get(4, 0); - final short s_c01 = matrix2.get(0, 1); - final short s_c11 = matrix2.get(1, 1); - final short s_c21 = matrix2.get(2, 1); - final short s_c31 = matrix2.get(3, 1); - final short s_c41 = matrix2.get(4, 1); - output.set(0, 0, (short) (f_c00*s_c00 + f_c10*s_c01)); - output.set(0, 1, (short) (f_c01*s_c00 + f_c11*s_c01)); - output.set(0, 2, (short) (f_c02*s_c00 + f_c12*s_c01)); - output.set(0, 3, (short) (f_c03*s_c00 + f_c13*s_c01)); - output.set(0, 4, (short) (f_c04*s_c00 + f_c14*s_c01)); - output.set(1, 0, (short) (f_c00*s_c10 + f_c10*s_c11)); - output.set(1, 1, (short) (f_c01*s_c10 + f_c11*s_c11)); - output.set(1, 2, (short) (f_c02*s_c10 + f_c12*s_c11)); - output.set(1, 3, (short) (f_c03*s_c10 + f_c13*s_c11)); - output.set(1, 4, (short) (f_c04*s_c10 + f_c14*s_c11)); - output.set(2, 0, (short) (f_c00*s_c20 + f_c10*s_c21)); - output.set(2, 1, (short) (f_c01*s_c20 + f_c11*s_c21)); - output.set(2, 2, (short) (f_c02*s_c20 + f_c12*s_c21)); - output.set(2, 3, (short) (f_c03*s_c20 + f_c13*s_c21)); - output.set(2, 4, (short) (f_c04*s_c20 + f_c14*s_c21)); - output.set(3, 0, (short) (f_c00*s_c30 + f_c10*s_c31)); - output.set(3, 1, (short) (f_c01*s_c30 + f_c11*s_c31)); - output.set(3, 2, (short) (f_c02*s_c30 + f_c12*s_c31)); - output.set(3, 3, (short) (f_c03*s_c30 + f_c13*s_c31)); - output.set(3, 4, (short) (f_c04*s_c30 + f_c14*s_c31)); - output.set(4, 0, (short) (f_c00*s_c40 + f_c10*s_c41)); - output.set(4, 1, (short) (f_c01*s_c40 + f_c11*s_c41)); - output.set(4, 2, (short) (f_c02*s_c40 + f_c12*s_c41)); - output.set(4, 3, (short) (f_c03*s_c40 + f_c13*s_c41)); - output.set(4, 4, (short) (f_c04*s_c40 + f_c14*s_c41)); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f02 = matrix1.get(0, 2); + final short f12 = matrix1.get(1, 2); + final short f03 = matrix1.get(0, 3); + final short f13 = matrix1.get(1, 3); + final short f04 = matrix1.get(0, 4); + final short f14 = matrix1.get(1, 4); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + final short s30 = matrix2.get(3, 0); + final short s40 = matrix2.get(4, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s21 = matrix2.get(2, 1); + final short s31 = matrix2.get(3, 1); + final short s41 = matrix2.get(4, 1); + output.set(0, 0, (short) (f00 * s00 + f10 * s01)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11)); + output.set(2, 0, (short) (f00 * s20 + f10 * s21)); + output.set(3, 0, (short) (f00 * s30 + f10 * s31)); + output.set(4, 0, (short) (f00 * s40 + f10 * s41)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01)); + output.set(1, 1, (short) (f01 * s10 + f11 * s11)); + output.set(2, 1, (short) (f01 * s20 + f11 * s21)); + output.set(3, 1, (short) (f01 * s30 + f11 * s31)); + output.set(4, 1, (short) (f01 * s40 + f11 * s41)); + output.set(0, 2, (short) (f02 * s00 + f12 * s01)); + output.set(1, 2, (short) (f02 * s10 + f12 * s11)); + output.set(2, 2, (short) (f02 * s20 + f12 * s21)); + output.set(3, 2, (short) (f02 * s30 + f12 * s31)); + output.set(4, 2, (short) (f02 * s40 + f12 * s41)); + output.set(0, 3, (short) (f03 * s00 + f13 * s01)); + output.set(1, 3, (short) (f03 * s10 + f13 * s11)); + output.set(2, 3, (short) (f03 * s20 + f13 * s21)); + output.set(3, 3, (short) (f03 * s30 + f13 * s31)); + output.set(4, 3, (short) (f03 * s40 + f13 * s41)); + output.set(0, 4, (short) (f04 * s00 + f14 * s01)); + output.set(1, 4, (short) (f04 * s10 + f14 * s11)); + output.set(2, 4, (short) (f04 * s20 + f14 * s21)); + output.set(3, 4, (short) (f04 * s30 + f14 * s31)); + output.set(4, 4, (short) (f04 * s40 + f14 * s41)); + return output; + } + + private static IMatrixSetterShort multiplyMatrix1x3x1(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short s00 = matrix2.get(0, 0); + final short s01 = matrix2.get(0, 1); + final short s02 = matrix2.get(0, 2); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02)); + return output; + } + + private static IMatrixSetterShort multiplyMatrix1x3x2(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s02 = matrix2.get(0, 2); + final short s12 = matrix2.get(1, 2); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11 + f20 * s12)); + return output; + } + + private static IMatrixSetterShort multiplyMatrix1x3x3(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s21 = matrix2.get(2, 1); + final short s02 = matrix2.get(0, 2); + final short s12 = matrix2.get(1, 2); + final short s22 = matrix2.get(2, 2); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11 + f20 * s12)); + output.set(2, 0, (short) (f00 * s20 + f10 * s21 + f20 * s22)); + return output; + } + + private static IMatrixSetterShort multiplyMatrix1x3x4(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + final short s30 = matrix2.get(3, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s21 = matrix2.get(2, 1); + final short s31 = matrix2.get(3, 1); + final short s02 = matrix2.get(0, 2); + final short s12 = matrix2.get(1, 2); + final short s22 = matrix2.get(2, 2); + final short s32 = matrix2.get(3, 2); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11 + f20 * s12)); + output.set(2, 0, (short) (f00 * s20 + f10 * s21 + f20 * s22)); + output.set(3, 0, (short) (f00 * s30 + f10 * s31 + f20 * s32)); + return output; + } + + private static IMatrixSetterShort multiplyMatrix1x3x5(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + final short s30 = matrix2.get(3, 0); + final short s40 = matrix2.get(4, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s21 = matrix2.get(2, 1); + final short s31 = matrix2.get(3, 1); + final short s41 = matrix2.get(4, 1); + final short s02 = matrix2.get(0, 2); + final short s12 = matrix2.get(1, 2); + final short s22 = matrix2.get(2, 2); + final short s32 = matrix2.get(3, 2); + final short s42 = matrix2.get(4, 2); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11 + f20 * s12)); + output.set(2, 0, (short) (f00 * s20 + f10 * s21 + f20 * s22)); + output.set(3, 0, (short) (f00 * s30 + f10 * s31 + f20 * s32)); + output.set(4, 0, (short) (f00 * s40 + f10 * s41 + f20 * s42)); + return output; + } + + private static IMatrixSetterShort multiplyMatrix2x3x1(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f21 = matrix1.get(2, 1); + final short s00 = matrix2.get(0, 0); + final short s01 = matrix2.get(0, 1); + final short s02 = matrix2.get(0, 2); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01 + f21 * s02)); return output; } private static IMatrixSetterShort multiplyMatrix2x3x2(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final short f_c00 = matrix1.get(0, 0); - final short f_c10 = matrix1.get(1, 0); - final short f_c20 = matrix1.get(2, 0); - final short f_c01 = matrix1.get(0, 1); - final short f_c11 = matrix1.get(1, 1); - final short f_c21 = matrix1.get(2, 1); - final short s_c00 = matrix2.get(0, 0); - final short s_c10 = matrix2.get(1, 0); - final short s_c01 = matrix2.get(0, 1); - final short s_c11 = matrix2.get(1, 1); - final short s_c02 = matrix2.get(0, 2); - final short s_c12 = matrix2.get(1, 2); - output.set(0, 0, (short) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02)); - output.set(0, 1, (short) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02)); - output.set(1, 0, (short) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12)); - output.set(1, 1, (short) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12)); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f21 = matrix1.get(2, 1); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s02 = matrix2.get(0, 2); + final short s12 = matrix2.get(1, 2); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11 + f20 * s12)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01 + f21 * s02)); + output.set(1, 1, (short) (f01 * s10 + f11 * s11 + f21 * s12)); return output; } private static IMatrixSetterShort multiplyMatrix2x3x3(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final short f_c00 = matrix1.get(0, 0); - final short f_c10 = matrix1.get(1, 0); - final short f_c20 = matrix1.get(2, 0); - final short f_c01 = matrix1.get(0, 1); - final short f_c11 = matrix1.get(1, 1); - final short f_c21 = matrix1.get(2, 1); - final short s_c00 = matrix2.get(0, 0); - final short s_c10 = matrix2.get(1, 0); - final short s_c20 = matrix2.get(2, 0); - final short s_c01 = matrix2.get(0, 1); - final short s_c11 = matrix2.get(1, 1); - final short s_c21 = matrix2.get(2, 1); - final short s_c02 = matrix2.get(0, 2); - final short s_c12 = matrix2.get(1, 2); - final short s_c22 = matrix2.get(2, 2); - output.set(0, 0, (short) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02)); - output.set(0, 1, (short) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02)); - output.set(1, 0, (short) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12)); - output.set(1, 1, (short) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12)); - output.set(2, 0, (short) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22)); - output.set(2, 1, (short) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22)); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f21 = matrix1.get(2, 1); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s21 = matrix2.get(2, 1); + final short s02 = matrix2.get(0, 2); + final short s12 = matrix2.get(1, 2); + final short s22 = matrix2.get(2, 2); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11 + f20 * s12)); + output.set(2, 0, (short) (f00 * s20 + f10 * s21 + f20 * s22)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01 + f21 * s02)); + output.set(1, 1, (short) (f01 * s10 + f11 * s11 + f21 * s12)); + output.set(2, 1, (short) (f01 * s20 + f11 * s21 + f21 * s22)); return output; } private static IMatrixSetterShort multiplyMatrix2x3x4(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final short f_c00 = matrix1.get(0, 0); - final short f_c10 = matrix1.get(1, 0); - final short f_c20 = matrix1.get(2, 0); - final short f_c01 = matrix1.get(0, 1); - final short f_c11 = matrix1.get(1, 1); - final short f_c21 = matrix1.get(2, 1); - final short s_c00 = matrix2.get(0, 0); - final short s_c10 = matrix2.get(1, 0); - final short s_c20 = matrix2.get(2, 0); - final short s_c30 = matrix2.get(3, 0); - final short s_c01 = matrix2.get(0, 1); - final short s_c11 = matrix2.get(1, 1); - final short s_c21 = matrix2.get(2, 1); - final short s_c31 = matrix2.get(3, 1); - final short s_c02 = matrix2.get(0, 2); - final short s_c12 = matrix2.get(1, 2); - final short s_c22 = matrix2.get(2, 2); - final short s_c32 = matrix2.get(3, 2); - output.set(0, 0, (short) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02)); - output.set(0, 1, (short) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02)); - output.set(1, 0, (short) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12)); - output.set(1, 1, (short) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12)); - output.set(2, 0, (short) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22)); - output.set(2, 1, (short) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22)); - output.set(3, 0, (short) (f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32)); - output.set(3, 1, (short) (f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32)); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f21 = matrix1.get(2, 1); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + final short s30 = matrix2.get(3, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s21 = matrix2.get(2, 1); + final short s31 = matrix2.get(3, 1); + final short s02 = matrix2.get(0, 2); + final short s12 = matrix2.get(1, 2); + final short s22 = matrix2.get(2, 2); + final short s32 = matrix2.get(3, 2); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11 + f20 * s12)); + output.set(2, 0, (short) (f00 * s20 + f10 * s21 + f20 * s22)); + output.set(3, 0, (short) (f00 * s30 + f10 * s31 + f20 * s32)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01 + f21 * s02)); + output.set(1, 1, (short) (f01 * s10 + f11 * s11 + f21 * s12)); + output.set(2, 1, (short) (f01 * s20 + f11 * s21 + f21 * s22)); + output.set(3, 1, (short) (f01 * s30 + f11 * s31 + f21 * s32)); return output; } private static IMatrixSetterShort multiplyMatrix2x3x5(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final short f_c00 = matrix1.get(0, 0); - final short f_c10 = matrix1.get(1, 0); - final short f_c20 = matrix1.get(2, 0); - final short f_c01 = matrix1.get(0, 1); - final short f_c11 = matrix1.get(1, 1); - final short f_c21 = matrix1.get(2, 1); - final short s_c00 = matrix2.get(0, 0); - final short s_c10 = matrix2.get(1, 0); - final short s_c20 = matrix2.get(2, 0); - final short s_c30 = matrix2.get(3, 0); - final short s_c40 = matrix2.get(4, 0); - final short s_c01 = matrix2.get(0, 1); - final short s_c11 = matrix2.get(1, 1); - final short s_c21 = matrix2.get(2, 1); - final short s_c31 = matrix2.get(3, 1); - final short s_c41 = matrix2.get(4, 1); - final short s_c02 = matrix2.get(0, 2); - final short s_c12 = matrix2.get(1, 2); - final short s_c22 = matrix2.get(2, 2); - final short s_c32 = matrix2.get(3, 2); - final short s_c42 = matrix2.get(4, 2); - output.set(0, 0, (short) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02)); - output.set(0, 1, (short) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02)); - output.set(1, 0, (short) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12)); - output.set(1, 1, (short) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12)); - output.set(2, 0, (short) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22)); - output.set(2, 1, (short) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22)); - output.set(3, 0, (short) (f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32)); - output.set(3, 1, (short) (f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32)); - output.set(4, 0, (short) (f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42)); - output.set(4, 1, (short) (f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42)); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f21 = matrix1.get(2, 1); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + final short s30 = matrix2.get(3, 0); + final short s40 = matrix2.get(4, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s21 = matrix2.get(2, 1); + final short s31 = matrix2.get(3, 1); + final short s41 = matrix2.get(4, 1); + final short s02 = matrix2.get(0, 2); + final short s12 = matrix2.get(1, 2); + final short s22 = matrix2.get(2, 2); + final short s32 = matrix2.get(3, 2); + final short s42 = matrix2.get(4, 2); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11 + f20 * s12)); + output.set(2, 0, (short) (f00 * s20 + f10 * s21 + f20 * s22)); + output.set(3, 0, (short) (f00 * s30 + f10 * s31 + f20 * s32)); + output.set(4, 0, (short) (f00 * s40 + f10 * s41 + f20 * s42)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01 + f21 * s02)); + output.set(1, 1, (short) (f01 * s10 + f11 * s11 + f21 * s12)); + output.set(2, 1, (short) (f01 * s20 + f11 * s21 + f21 * s22)); + output.set(3, 1, (short) (f01 * s30 + f11 * s31 + f21 * s32)); + output.set(4, 1, (short) (f01 * s40 + f11 * s41 + f21 * s42)); + return output; + } + + private static IMatrixSetterShort multiplyMatrix3x3x1(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f21 = matrix1.get(2, 1); + final short f02 = matrix1.get(0, 2); + final short f12 = matrix1.get(1, 2); + final short f22 = matrix1.get(2, 2); + final short s00 = matrix2.get(0, 0); + final short s01 = matrix2.get(0, 1); + final short s02 = matrix2.get(0, 2); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01 + f21 * s02)); + output.set(0, 2, (short) (f02 * s00 + f12 * s01 + f22 * s02)); return output; } private static IMatrixSetterShort multiplyMatrix3x3x2(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final short f_c00 = matrix1.get(0, 0); - final short f_c10 = matrix1.get(1, 0); - final short f_c20 = matrix1.get(2, 0); - final short f_c01 = matrix1.get(0, 1); - final short f_c11 = matrix1.get(1, 1); - final short f_c21 = matrix1.get(2, 1); - final short f_c02 = matrix1.get(0, 2); - final short f_c12 = matrix1.get(1, 2); - final short f_c22 = matrix1.get(2, 2); - final short s_c00 = matrix2.get(0, 0); - final short s_c10 = matrix2.get(1, 0); - final short s_c01 = matrix2.get(0, 1); - final short s_c11 = matrix2.get(1, 1); - final short s_c02 = matrix2.get(0, 2); - final short s_c12 = matrix2.get(1, 2); - output.set(0, 0, (short) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02)); - output.set(0, 1, (short) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02)); - output.set(0, 2, (short) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02)); - output.set(1, 0, (short) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12)); - output.set(1, 1, (short) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12)); - output.set(1, 2, (short) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12)); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f21 = matrix1.get(2, 1); + final short f02 = matrix1.get(0, 2); + final short f12 = matrix1.get(1, 2); + final short f22 = matrix1.get(2, 2); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s02 = matrix2.get(0, 2); + final short s12 = matrix2.get(1, 2); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11 + f20 * s12)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01 + f21 * s02)); + output.set(1, 1, (short) (f01 * s10 + f11 * s11 + f21 * s12)); + output.set(0, 2, (short) (f02 * s00 + f12 * s01 + f22 * s02)); + output.set(1, 2, (short) (f02 * s10 + f12 * s11 + f22 * s12)); return output; } private static IMatrixSetterShort multiplyMatrix3x3x3(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final short f_c00 = matrix1.get(0, 0); - final short f_c10 = matrix1.get(1, 0); - final short f_c20 = matrix1.get(2, 0); - final short f_c01 = matrix1.get(0, 1); - final short f_c11 = matrix1.get(1, 1); - final short f_c21 = matrix1.get(2, 1); - final short f_c02 = matrix1.get(0, 2); - final short f_c12 = matrix1.get(1, 2); - final short f_c22 = matrix1.get(2, 2); - final short s_c00 = matrix2.get(0, 0); - final short s_c10 = matrix2.get(1, 0); - final short s_c20 = matrix2.get(2, 0); - final short s_c01 = matrix2.get(0, 1); - final short s_c11 = matrix2.get(1, 1); - final short s_c21 = matrix2.get(2, 1); - final short s_c02 = matrix2.get(0, 2); - final short s_c12 = matrix2.get(1, 2); - final short s_c22 = matrix2.get(2, 2); - output.set(0, 0, (short) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02)); - output.set(0, 1, (short) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02)); - output.set(0, 2, (short) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02)); - output.set(1, 0, (short) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12)); - output.set(1, 1, (short) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12)); - output.set(1, 2, (short) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12)); - output.set(2, 0, (short) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22)); - output.set(2, 1, (short) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22)); - output.set(2, 2, (short) (f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22)); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f21 = matrix1.get(2, 1); + final short f02 = matrix1.get(0, 2); + final short f12 = matrix1.get(1, 2); + final short f22 = matrix1.get(2, 2); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s21 = matrix2.get(2, 1); + final short s02 = matrix2.get(0, 2); + final short s12 = matrix2.get(1, 2); + final short s22 = matrix2.get(2, 2); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11 + f20 * s12)); + output.set(2, 0, (short) (f00 * s20 + f10 * s21 + f20 * s22)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01 + f21 * s02)); + output.set(1, 1, (short) (f01 * s10 + f11 * s11 + f21 * s12)); + output.set(2, 1, (short) (f01 * s20 + f11 * s21 + f21 * s22)); + output.set(0, 2, (short) (f02 * s00 + f12 * s01 + f22 * s02)); + output.set(1, 2, (short) (f02 * s10 + f12 * s11 + f22 * s12)); + output.set(2, 2, (short) (f02 * s20 + f12 * s21 + f22 * s22)); return output; } private static IMatrixSetterShort multiplyMatrix3x3x4(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final short f_c00 = matrix1.get(0, 0); - final short f_c10 = matrix1.get(1, 0); - final short f_c20 = matrix1.get(2, 0); - final short f_c01 = matrix1.get(0, 1); - final short f_c11 = matrix1.get(1, 1); - final short f_c21 = matrix1.get(2, 1); - final short f_c02 = matrix1.get(0, 2); - final short f_c12 = matrix1.get(1, 2); - final short f_c22 = matrix1.get(2, 2); - final short s_c00 = matrix2.get(0, 0); - final short s_c10 = matrix2.get(1, 0); - final short s_c20 = matrix2.get(2, 0); - final short s_c30 = matrix2.get(3, 0); - final short s_c01 = matrix2.get(0, 1); - final short s_c11 = matrix2.get(1, 1); - final short s_c21 = matrix2.get(2, 1); - final short s_c31 = matrix2.get(3, 1); - final short s_c02 = matrix2.get(0, 2); - final short s_c12 = matrix2.get(1, 2); - final short s_c22 = matrix2.get(2, 2); - final short s_c32 = matrix2.get(3, 2); - output.set(0, 0, (short) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02)); - output.set(0, 1, (short) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02)); - output.set(0, 2, (short) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02)); - output.set(1, 0, (short) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12)); - output.set(1, 1, (short) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12)); - output.set(1, 2, (short) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12)); - output.set(2, 0, (short) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22)); - output.set(2, 1, (short) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22)); - output.set(2, 2, (short) (f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22)); - output.set(3, 0, (short) (f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32)); - output.set(3, 1, (short) (f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32)); - output.set(3, 2, (short) (f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32)); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f21 = matrix1.get(2, 1); + final short f02 = matrix1.get(0, 2); + final short f12 = matrix1.get(1, 2); + final short f22 = matrix1.get(2, 2); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + final short s30 = matrix2.get(3, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s21 = matrix2.get(2, 1); + final short s31 = matrix2.get(3, 1); + final short s02 = matrix2.get(0, 2); + final short s12 = matrix2.get(1, 2); + final short s22 = matrix2.get(2, 2); + final short s32 = matrix2.get(3, 2); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11 + f20 * s12)); + output.set(2, 0, (short) (f00 * s20 + f10 * s21 + f20 * s22)); + output.set(3, 0, (short) (f00 * s30 + f10 * s31 + f20 * s32)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01 + f21 * s02)); + output.set(1, 1, (short) (f01 * s10 + f11 * s11 + f21 * s12)); + output.set(2, 1, (short) (f01 * s20 + f11 * s21 + f21 * s22)); + output.set(3, 1, (short) (f01 * s30 + f11 * s31 + f21 * s32)); + output.set(0, 2, (short) (f02 * s00 + f12 * s01 + f22 * s02)); + output.set(1, 2, (short) (f02 * s10 + f12 * s11 + f22 * s12)); + output.set(2, 2, (short) (f02 * s20 + f12 * s21 + f22 * s22)); + output.set(3, 2, (short) (f02 * s30 + f12 * s31 + f22 * s32)); return output; } private static IMatrixSetterShort multiplyMatrix3x3x5(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final short f_c00 = matrix1.get(0, 0); - final short f_c10 = matrix1.get(1, 0); - final short f_c20 = matrix1.get(2, 0); - final short f_c01 = matrix1.get(0, 1); - final short f_c11 = matrix1.get(1, 1); - final short f_c21 = matrix1.get(2, 1); - final short f_c02 = matrix1.get(0, 2); - final short f_c12 = matrix1.get(1, 2); - final short f_c22 = matrix1.get(2, 2); - final short s_c00 = matrix2.get(0, 0); - final short s_c10 = matrix2.get(1, 0); - final short s_c20 = matrix2.get(2, 0); - final short s_c30 = matrix2.get(3, 0); - final short s_c40 = matrix2.get(4, 0); - final short s_c01 = matrix2.get(0, 1); - final short s_c11 = matrix2.get(1, 1); - final short s_c21 = matrix2.get(2, 1); - final short s_c31 = matrix2.get(3, 1); - final short s_c41 = matrix2.get(4, 1); - final short s_c02 = matrix2.get(0, 2); - final short s_c12 = matrix2.get(1, 2); - final short s_c22 = matrix2.get(2, 2); - final short s_c32 = matrix2.get(3, 2); - final short s_c42 = matrix2.get(4, 2); - output.set(0, 0, (short) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02)); - output.set(0, 1, (short) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02)); - output.set(0, 2, (short) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02)); - output.set(1, 0, (short) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12)); - output.set(1, 1, (short) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12)); - output.set(1, 2, (short) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12)); - output.set(2, 0, (short) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22)); - output.set(2, 1, (short) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22)); - output.set(2, 2, (short) (f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22)); - output.set(3, 0, (short) (f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32)); - output.set(3, 1, (short) (f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32)); - output.set(3, 2, (short) (f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32)); - output.set(4, 0, (short) (f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42)); - output.set(4, 1, (short) (f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42)); - output.set(4, 2, (short) (f_c02*s_c40 + f_c12*s_c41 + f_c22*s_c42)); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f21 = matrix1.get(2, 1); + final short f02 = matrix1.get(0, 2); + final short f12 = matrix1.get(1, 2); + final short f22 = matrix1.get(2, 2); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + final short s30 = matrix2.get(3, 0); + final short s40 = matrix2.get(4, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s21 = matrix2.get(2, 1); + final short s31 = matrix2.get(3, 1); + final short s41 = matrix2.get(4, 1); + final short s02 = matrix2.get(0, 2); + final short s12 = matrix2.get(1, 2); + final short s22 = matrix2.get(2, 2); + final short s32 = matrix2.get(3, 2); + final short s42 = matrix2.get(4, 2); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11 + f20 * s12)); + output.set(2, 0, (short) (f00 * s20 + f10 * s21 + f20 * s22)); + output.set(3, 0, (short) (f00 * s30 + f10 * s31 + f20 * s32)); + output.set(4, 0, (short) (f00 * s40 + f10 * s41 + f20 * s42)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01 + f21 * s02)); + output.set(1, 1, (short) (f01 * s10 + f11 * s11 + f21 * s12)); + output.set(2, 1, (short) (f01 * s20 + f11 * s21 + f21 * s22)); + output.set(3, 1, (short) (f01 * s30 + f11 * s31 + f21 * s32)); + output.set(4, 1, (short) (f01 * s40 + f11 * s41 + f21 * s42)); + output.set(0, 2, (short) (f02 * s00 + f12 * s01 + f22 * s02)); + output.set(1, 2, (short) (f02 * s10 + f12 * s11 + f22 * s12)); + output.set(2, 2, (short) (f02 * s20 + f12 * s21 + f22 * s22)); + output.set(3, 2, (short) (f02 * s30 + f12 * s31 + f22 * s32)); + output.set(4, 2, (short) (f02 * s40 + f12 * s41 + f22 * s42)); + return output; + } + + private static IMatrixSetterShort multiplyMatrix4x3x1(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f21 = matrix1.get(2, 1); + final short f02 = matrix1.get(0, 2); + final short f12 = matrix1.get(1, 2); + final short f22 = matrix1.get(2, 2); + final short f03 = matrix1.get(0, 3); + final short f13 = matrix1.get(1, 3); + final short f23 = matrix1.get(2, 3); + final short s00 = matrix2.get(0, 0); + final short s01 = matrix2.get(0, 1); + final short s02 = matrix2.get(0, 2); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01 + f21 * s02)); + output.set(0, 2, (short) (f02 * s00 + f12 * s01 + f22 * s02)); + output.set(0, 3, (short) (f03 * s00 + f13 * s01 + f23 * s02)); return output; } private static IMatrixSetterShort multiplyMatrix4x3x2(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final short f_c00 = matrix1.get(0, 0); - final short f_c10 = matrix1.get(1, 0); - final short f_c20 = matrix1.get(2, 0); - final short f_c01 = matrix1.get(0, 1); - final short f_c11 = matrix1.get(1, 1); - final short f_c21 = matrix1.get(2, 1); - final short f_c02 = matrix1.get(0, 2); - final short f_c12 = matrix1.get(1, 2); - final short f_c22 = matrix1.get(2, 2); - final short f_c03 = matrix1.get(0, 3); - final short f_c13 = matrix1.get(1, 3); - final short f_c23 = matrix1.get(2, 3); - final short s_c00 = matrix2.get(0, 0); - final short s_c10 = matrix2.get(1, 0); - final short s_c01 = matrix2.get(0, 1); - final short s_c11 = matrix2.get(1, 1); - final short s_c02 = matrix2.get(0, 2); - final short s_c12 = matrix2.get(1, 2); - output.set(0, 0, (short) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02)); - output.set(0, 1, (short) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02)); - output.set(0, 2, (short) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02)); - output.set(0, 3, (short) (f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02)); - output.set(1, 0, (short) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12)); - output.set(1, 1, (short) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12)); - output.set(1, 2, (short) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12)); - output.set(1, 3, (short) (f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12)); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f21 = matrix1.get(2, 1); + final short f02 = matrix1.get(0, 2); + final short f12 = matrix1.get(1, 2); + final short f22 = matrix1.get(2, 2); + final short f03 = matrix1.get(0, 3); + final short f13 = matrix1.get(1, 3); + final short f23 = matrix1.get(2, 3); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s02 = matrix2.get(0, 2); + final short s12 = matrix2.get(1, 2); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11 + f20 * s12)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01 + f21 * s02)); + output.set(1, 1, (short) (f01 * s10 + f11 * s11 + f21 * s12)); + output.set(0, 2, (short) (f02 * s00 + f12 * s01 + f22 * s02)); + output.set(1, 2, (short) (f02 * s10 + f12 * s11 + f22 * s12)); + output.set(0, 3, (short) (f03 * s00 + f13 * s01 + f23 * s02)); + output.set(1, 3, (short) (f03 * s10 + f13 * s11 + f23 * s12)); return output; } private static IMatrixSetterShort multiplyMatrix4x3x3(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final short f_c00 = matrix1.get(0, 0); - final short f_c10 = matrix1.get(1, 0); - final short f_c20 = matrix1.get(2, 0); - final short f_c01 = matrix1.get(0, 1); - final short f_c11 = matrix1.get(1, 1); - final short f_c21 = matrix1.get(2, 1); - final short f_c02 = matrix1.get(0, 2); - final short f_c12 = matrix1.get(1, 2); - final short f_c22 = matrix1.get(2, 2); - final short f_c03 = matrix1.get(0, 3); - final short f_c13 = matrix1.get(1, 3); - final short f_c23 = matrix1.get(2, 3); - final short s_c00 = matrix2.get(0, 0); - final short s_c10 = matrix2.get(1, 0); - final short s_c20 = matrix2.get(2, 0); - final short s_c01 = matrix2.get(0, 1); - final short s_c11 = matrix2.get(1, 1); - final short s_c21 = matrix2.get(2, 1); - final short s_c02 = matrix2.get(0, 2); - final short s_c12 = matrix2.get(1, 2); - final short s_c22 = matrix2.get(2, 2); - output.set(0, 0, (short) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02)); - output.set(0, 1, (short) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02)); - output.set(0, 2, (short) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02)); - output.set(0, 3, (short) (f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02)); - output.set(1, 0, (short) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12)); - output.set(1, 1, (short) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12)); - output.set(1, 2, (short) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12)); - output.set(1, 3, (short) (f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12)); - output.set(2, 0, (short) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22)); - output.set(2, 1, (short) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22)); - output.set(2, 2, (short) (f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22)); - output.set(2, 3, (short) (f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22)); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f21 = matrix1.get(2, 1); + final short f02 = matrix1.get(0, 2); + final short f12 = matrix1.get(1, 2); + final short f22 = matrix1.get(2, 2); + final short f03 = matrix1.get(0, 3); + final short f13 = matrix1.get(1, 3); + final short f23 = matrix1.get(2, 3); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s21 = matrix2.get(2, 1); + final short s02 = matrix2.get(0, 2); + final short s12 = matrix2.get(1, 2); + final short s22 = matrix2.get(2, 2); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11 + f20 * s12)); + output.set(2, 0, (short) (f00 * s20 + f10 * s21 + f20 * s22)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01 + f21 * s02)); + output.set(1, 1, (short) (f01 * s10 + f11 * s11 + f21 * s12)); + output.set(2, 1, (short) (f01 * s20 + f11 * s21 + f21 * s22)); + output.set(0, 2, (short) (f02 * s00 + f12 * s01 + f22 * s02)); + output.set(1, 2, (short) (f02 * s10 + f12 * s11 + f22 * s12)); + output.set(2, 2, (short) (f02 * s20 + f12 * s21 + f22 * s22)); + output.set(0, 3, (short) (f03 * s00 + f13 * s01 + f23 * s02)); + output.set(1, 3, (short) (f03 * s10 + f13 * s11 + f23 * s12)); + output.set(2, 3, (short) (f03 * s20 + f13 * s21 + f23 * s22)); return output; } private static IMatrixSetterShort multiplyMatrix4x3x4(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final short f_c00 = matrix1.get(0, 0); - final short f_c10 = matrix1.get(1, 0); - final short f_c20 = matrix1.get(2, 0); - final short f_c01 = matrix1.get(0, 1); - final short f_c11 = matrix1.get(1, 1); - final short f_c21 = matrix1.get(2, 1); - final short f_c02 = matrix1.get(0, 2); - final short f_c12 = matrix1.get(1, 2); - final short f_c22 = matrix1.get(2, 2); - final short f_c03 = matrix1.get(0, 3); - final short f_c13 = matrix1.get(1, 3); - final short f_c23 = matrix1.get(2, 3); - final short s_c00 = matrix2.get(0, 0); - final short s_c10 = matrix2.get(1, 0); - final short s_c20 = matrix2.get(2, 0); - final short s_c30 = matrix2.get(3, 0); - final short s_c01 = matrix2.get(0, 1); - final short s_c11 = matrix2.get(1, 1); - final short s_c21 = matrix2.get(2, 1); - final short s_c31 = matrix2.get(3, 1); - final short s_c02 = matrix2.get(0, 2); - final short s_c12 = matrix2.get(1, 2); - final short s_c22 = matrix2.get(2, 2); - final short s_c32 = matrix2.get(3, 2); - output.set(0, 0, (short) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02)); - output.set(0, 1, (short) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02)); - output.set(0, 2, (short) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02)); - output.set(0, 3, (short) (f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02)); - output.set(1, 0, (short) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12)); - output.set(1, 1, (short) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12)); - output.set(1, 2, (short) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12)); - output.set(1, 3, (short) (f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12)); - output.set(2, 0, (short) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22)); - output.set(2, 1, (short) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22)); - output.set(2, 2, (short) (f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22)); - output.set(2, 3, (short) (f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22)); - output.set(3, 0, (short) (f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32)); - output.set(3, 1, (short) (f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32)); - output.set(3, 2, (short) (f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32)); - output.set(3, 3, (short) (f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32)); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f21 = matrix1.get(2, 1); + final short f02 = matrix1.get(0, 2); + final short f12 = matrix1.get(1, 2); + final short f22 = matrix1.get(2, 2); + final short f03 = matrix1.get(0, 3); + final short f13 = matrix1.get(1, 3); + final short f23 = matrix1.get(2, 3); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + final short s30 = matrix2.get(3, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s21 = matrix2.get(2, 1); + final short s31 = matrix2.get(3, 1); + final short s02 = matrix2.get(0, 2); + final short s12 = matrix2.get(1, 2); + final short s22 = matrix2.get(2, 2); + final short s32 = matrix2.get(3, 2); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11 + f20 * s12)); + output.set(2, 0, (short) (f00 * s20 + f10 * s21 + f20 * s22)); + output.set(3, 0, (short) (f00 * s30 + f10 * s31 + f20 * s32)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01 + f21 * s02)); + output.set(1, 1, (short) (f01 * s10 + f11 * s11 + f21 * s12)); + output.set(2, 1, (short) (f01 * s20 + f11 * s21 + f21 * s22)); + output.set(3, 1, (short) (f01 * s30 + f11 * s31 + f21 * s32)); + output.set(0, 2, (short) (f02 * s00 + f12 * s01 + f22 * s02)); + output.set(1, 2, (short) (f02 * s10 + f12 * s11 + f22 * s12)); + output.set(2, 2, (short) (f02 * s20 + f12 * s21 + f22 * s22)); + output.set(3, 2, (short) (f02 * s30 + f12 * s31 + f22 * s32)); + output.set(0, 3, (short) (f03 * s00 + f13 * s01 + f23 * s02)); + output.set(1, 3, (short) (f03 * s10 + f13 * s11 + f23 * s12)); + output.set(2, 3, (short) (f03 * s20 + f13 * s21 + f23 * s22)); + output.set(3, 3, (short) (f03 * s30 + f13 * s31 + f23 * s32)); return output; } private static IMatrixSetterShort multiplyMatrix4x3x5(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final short f_c00 = matrix1.get(0, 0); - final short f_c10 = matrix1.get(1, 0); - final short f_c20 = matrix1.get(2, 0); - final short f_c01 = matrix1.get(0, 1); - final short f_c11 = matrix1.get(1, 1); - final short f_c21 = matrix1.get(2, 1); - final short f_c02 = matrix1.get(0, 2); - final short f_c12 = matrix1.get(1, 2); - final short f_c22 = matrix1.get(2, 2); - final short f_c03 = matrix1.get(0, 3); - final short f_c13 = matrix1.get(1, 3); - final short f_c23 = matrix1.get(2, 3); - final short s_c00 = matrix2.get(0, 0); - final short s_c10 = matrix2.get(1, 0); - final short s_c20 = matrix2.get(2, 0); - final short s_c30 = matrix2.get(3, 0); - final short s_c40 = matrix2.get(4, 0); - final short s_c01 = matrix2.get(0, 1); - final short s_c11 = matrix2.get(1, 1); - final short s_c21 = matrix2.get(2, 1); - final short s_c31 = matrix2.get(3, 1); - final short s_c41 = matrix2.get(4, 1); - final short s_c02 = matrix2.get(0, 2); - final short s_c12 = matrix2.get(1, 2); - final short s_c22 = matrix2.get(2, 2); - final short s_c32 = matrix2.get(3, 2); - final short s_c42 = matrix2.get(4, 2); - output.set(0, 0, (short) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02)); - output.set(0, 1, (short) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02)); - output.set(0, 2, (short) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02)); - output.set(0, 3, (short) (f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02)); - output.set(1, 0, (short) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12)); - output.set(1, 1, (short) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12)); - output.set(1, 2, (short) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12)); - output.set(1, 3, (short) (f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12)); - output.set(2, 0, (short) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22)); - output.set(2, 1, (short) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22)); - output.set(2, 2, (short) (f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22)); - output.set(2, 3, (short) (f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22)); - output.set(3, 0, (short) (f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32)); - output.set(3, 1, (short) (f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32)); - output.set(3, 2, (short) (f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32)); - output.set(3, 3, (short) (f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32)); - output.set(4, 0, (short) (f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42)); - output.set(4, 1, (short) (f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42)); - output.set(4, 2, (short) (f_c02*s_c40 + f_c12*s_c41 + f_c22*s_c42)); - output.set(4, 3, (short) (f_c03*s_c40 + f_c13*s_c41 + f_c23*s_c42)); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f21 = matrix1.get(2, 1); + final short f02 = matrix1.get(0, 2); + final short f12 = matrix1.get(1, 2); + final short f22 = matrix1.get(2, 2); + final short f03 = matrix1.get(0, 3); + final short f13 = matrix1.get(1, 3); + final short f23 = matrix1.get(2, 3); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + final short s30 = matrix2.get(3, 0); + final short s40 = matrix2.get(4, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s21 = matrix2.get(2, 1); + final short s31 = matrix2.get(3, 1); + final short s41 = matrix2.get(4, 1); + final short s02 = matrix2.get(0, 2); + final short s12 = matrix2.get(1, 2); + final short s22 = matrix2.get(2, 2); + final short s32 = matrix2.get(3, 2); + final short s42 = matrix2.get(4, 2); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11 + f20 * s12)); + output.set(2, 0, (short) (f00 * s20 + f10 * s21 + f20 * s22)); + output.set(3, 0, (short) (f00 * s30 + f10 * s31 + f20 * s32)); + output.set(4, 0, (short) (f00 * s40 + f10 * s41 + f20 * s42)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01 + f21 * s02)); + output.set(1, 1, (short) (f01 * s10 + f11 * s11 + f21 * s12)); + output.set(2, 1, (short) (f01 * s20 + f11 * s21 + f21 * s22)); + output.set(3, 1, (short) (f01 * s30 + f11 * s31 + f21 * s32)); + output.set(4, 1, (short) (f01 * s40 + f11 * s41 + f21 * s42)); + output.set(0, 2, (short) (f02 * s00 + f12 * s01 + f22 * s02)); + output.set(1, 2, (short) (f02 * s10 + f12 * s11 + f22 * s12)); + output.set(2, 2, (short) (f02 * s20 + f12 * s21 + f22 * s22)); + output.set(3, 2, (short) (f02 * s30 + f12 * s31 + f22 * s32)); + output.set(4, 2, (short) (f02 * s40 + f12 * s41 + f22 * s42)); + output.set(0, 3, (short) (f03 * s00 + f13 * s01 + f23 * s02)); + output.set(1, 3, (short) (f03 * s10 + f13 * s11 + f23 * s12)); + output.set(2, 3, (short) (f03 * s20 + f13 * s21 + f23 * s22)); + output.set(3, 3, (short) (f03 * s30 + f13 * s31 + f23 * s32)); + output.set(4, 3, (short) (f03 * s40 + f13 * s41 + f23 * s42)); + return output; + } + + private static IMatrixSetterShort multiplyMatrix5x3x1(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f21 = matrix1.get(2, 1); + final short f02 = matrix1.get(0, 2); + final short f12 = matrix1.get(1, 2); + final short f22 = matrix1.get(2, 2); + final short f03 = matrix1.get(0, 3); + final short f13 = matrix1.get(1, 3); + final short f23 = matrix1.get(2, 3); + final short f04 = matrix1.get(0, 4); + final short f14 = matrix1.get(1, 4); + final short f24 = matrix1.get(2, 4); + final short s00 = matrix2.get(0, 0); + final short s01 = matrix2.get(0, 1); + final short s02 = matrix2.get(0, 2); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01 + f21 * s02)); + output.set(0, 2, (short) (f02 * s00 + f12 * s01 + f22 * s02)); + output.set(0, 3, (short) (f03 * s00 + f13 * s01 + f23 * s02)); + output.set(0, 4, (short) (f04 * s00 + f14 * s01 + f24 * s02)); return output; } private static IMatrixSetterShort multiplyMatrix5x3x2(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final short f_c00 = matrix1.get(0, 0); - final short f_c10 = matrix1.get(1, 0); - final short f_c20 = matrix1.get(2, 0); - final short f_c01 = matrix1.get(0, 1); - final short f_c11 = matrix1.get(1, 1); - final short f_c21 = matrix1.get(2, 1); - final short f_c02 = matrix1.get(0, 2); - final short f_c12 = matrix1.get(1, 2); - final short f_c22 = matrix1.get(2, 2); - final short f_c03 = matrix1.get(0, 3); - final short f_c13 = matrix1.get(1, 3); - final short f_c23 = matrix1.get(2, 3); - final short f_c04 = matrix1.get(0, 4); - final short f_c14 = matrix1.get(1, 4); - final short f_c24 = matrix1.get(2, 4); - final short s_c00 = matrix2.get(0, 0); - final short s_c10 = matrix2.get(1, 0); - final short s_c01 = matrix2.get(0, 1); - final short s_c11 = matrix2.get(1, 1); - final short s_c02 = matrix2.get(0, 2); - final short s_c12 = matrix2.get(1, 2); - output.set(0, 0, (short) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02)); - output.set(0, 1, (short) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02)); - output.set(0, 2, (short) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02)); - output.set(0, 3, (short) (f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02)); - output.set(0, 4, (short) (f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02)); - output.set(1, 0, (short) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12)); - output.set(1, 1, (short) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12)); - output.set(1, 2, (short) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12)); - output.set(1, 3, (short) (f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12)); - output.set(1, 4, (short) (f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12)); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f21 = matrix1.get(2, 1); + final short f02 = matrix1.get(0, 2); + final short f12 = matrix1.get(1, 2); + final short f22 = matrix1.get(2, 2); + final short f03 = matrix1.get(0, 3); + final short f13 = matrix1.get(1, 3); + final short f23 = matrix1.get(2, 3); + final short f04 = matrix1.get(0, 4); + final short f14 = matrix1.get(1, 4); + final short f24 = matrix1.get(2, 4); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s02 = matrix2.get(0, 2); + final short s12 = matrix2.get(1, 2); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11 + f20 * s12)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01 + f21 * s02)); + output.set(1, 1, (short) (f01 * s10 + f11 * s11 + f21 * s12)); + output.set(0, 2, (short) (f02 * s00 + f12 * s01 + f22 * s02)); + output.set(1, 2, (short) (f02 * s10 + f12 * s11 + f22 * s12)); + output.set(0, 3, (short) (f03 * s00 + f13 * s01 + f23 * s02)); + output.set(1, 3, (short) (f03 * s10 + f13 * s11 + f23 * s12)); + output.set(0, 4, (short) (f04 * s00 + f14 * s01 + f24 * s02)); + output.set(1, 4, (short) (f04 * s10 + f14 * s11 + f24 * s12)); return output; } private static IMatrixSetterShort multiplyMatrix5x3x3(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final short f_c00 = matrix1.get(0, 0); - final short f_c10 = matrix1.get(1, 0); - final short f_c20 = matrix1.get(2, 0); - final short f_c01 = matrix1.get(0, 1); - final short f_c11 = matrix1.get(1, 1); - final short f_c21 = matrix1.get(2, 1); - final short f_c02 = matrix1.get(0, 2); - final short f_c12 = matrix1.get(1, 2); - final short f_c22 = matrix1.get(2, 2); - final short f_c03 = matrix1.get(0, 3); - final short f_c13 = matrix1.get(1, 3); - final short f_c23 = matrix1.get(2, 3); - final short f_c04 = matrix1.get(0, 4); - final short f_c14 = matrix1.get(1, 4); - final short f_c24 = matrix1.get(2, 4); - final short s_c00 = matrix2.get(0, 0); - final short s_c10 = matrix2.get(1, 0); - final short s_c20 = matrix2.get(2, 0); - final short s_c01 = matrix2.get(0, 1); - final short s_c11 = matrix2.get(1, 1); - final short s_c21 = matrix2.get(2, 1); - final short s_c02 = matrix2.get(0, 2); - final short s_c12 = matrix2.get(1, 2); - final short s_c22 = matrix2.get(2, 2); - output.set(0, 0, (short) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02)); - output.set(0, 1, (short) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02)); - output.set(0, 2, (short) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02)); - output.set(0, 3, (short) (f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02)); - output.set(0, 4, (short) (f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02)); - output.set(1, 0, (short) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12)); - output.set(1, 1, (short) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12)); - output.set(1, 2, (short) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12)); - output.set(1, 3, (short) (f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12)); - output.set(1, 4, (short) (f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12)); - output.set(2, 0, (short) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22)); - output.set(2, 1, (short) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22)); - output.set(2, 2, (short) (f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22)); - output.set(2, 3, (short) (f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22)); - output.set(2, 4, (short) (f_c04*s_c20 + f_c14*s_c21 + f_c24*s_c22)); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f21 = matrix1.get(2, 1); + final short f02 = matrix1.get(0, 2); + final short f12 = matrix1.get(1, 2); + final short f22 = matrix1.get(2, 2); + final short f03 = matrix1.get(0, 3); + final short f13 = matrix1.get(1, 3); + final short f23 = matrix1.get(2, 3); + final short f04 = matrix1.get(0, 4); + final short f14 = matrix1.get(1, 4); + final short f24 = matrix1.get(2, 4); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s21 = matrix2.get(2, 1); + final short s02 = matrix2.get(0, 2); + final short s12 = matrix2.get(1, 2); + final short s22 = matrix2.get(2, 2); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11 + f20 * s12)); + output.set(2, 0, (short) (f00 * s20 + f10 * s21 + f20 * s22)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01 + f21 * s02)); + output.set(1, 1, (short) (f01 * s10 + f11 * s11 + f21 * s12)); + output.set(2, 1, (short) (f01 * s20 + f11 * s21 + f21 * s22)); + output.set(0, 2, (short) (f02 * s00 + f12 * s01 + f22 * s02)); + output.set(1, 2, (short) (f02 * s10 + f12 * s11 + f22 * s12)); + output.set(2, 2, (short) (f02 * s20 + f12 * s21 + f22 * s22)); + output.set(0, 3, (short) (f03 * s00 + f13 * s01 + f23 * s02)); + output.set(1, 3, (short) (f03 * s10 + f13 * s11 + f23 * s12)); + output.set(2, 3, (short) (f03 * s20 + f13 * s21 + f23 * s22)); + output.set(0, 4, (short) (f04 * s00 + f14 * s01 + f24 * s02)); + output.set(1, 4, (short) (f04 * s10 + f14 * s11 + f24 * s12)); + output.set(2, 4, (short) (f04 * s20 + f14 * s21 + f24 * s22)); return output; } private static IMatrixSetterShort multiplyMatrix5x3x4(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final short f_c00 = matrix1.get(0, 0); - final short f_c10 = matrix1.get(1, 0); - final short f_c20 = matrix1.get(2, 0); - final short f_c01 = matrix1.get(0, 1); - final short f_c11 = matrix1.get(1, 1); - final short f_c21 = matrix1.get(2, 1); - final short f_c02 = matrix1.get(0, 2); - final short f_c12 = matrix1.get(1, 2); - final short f_c22 = matrix1.get(2, 2); - final short f_c03 = matrix1.get(0, 3); - final short f_c13 = matrix1.get(1, 3); - final short f_c23 = matrix1.get(2, 3); - final short f_c04 = matrix1.get(0, 4); - final short f_c14 = matrix1.get(1, 4); - final short f_c24 = matrix1.get(2, 4); - final short s_c00 = matrix2.get(0, 0); - final short s_c10 = matrix2.get(1, 0); - final short s_c20 = matrix2.get(2, 0); - final short s_c30 = matrix2.get(3, 0); - final short s_c01 = matrix2.get(0, 1); - final short s_c11 = matrix2.get(1, 1); - final short s_c21 = matrix2.get(2, 1); - final short s_c31 = matrix2.get(3, 1); - final short s_c02 = matrix2.get(0, 2); - final short s_c12 = matrix2.get(1, 2); - final short s_c22 = matrix2.get(2, 2); - final short s_c32 = matrix2.get(3, 2); - output.set(0, 0, (short) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02)); - output.set(0, 1, (short) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02)); - output.set(0, 2, (short) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02)); - output.set(0, 3, (short) (f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02)); - output.set(0, 4, (short) (f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02)); - output.set(1, 0, (short) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12)); - output.set(1, 1, (short) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12)); - output.set(1, 2, (short) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12)); - output.set(1, 3, (short) (f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12)); - output.set(1, 4, (short) (f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12)); - output.set(2, 0, (short) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22)); - output.set(2, 1, (short) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22)); - output.set(2, 2, (short) (f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22)); - output.set(2, 3, (short) (f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22)); - output.set(2, 4, (short) (f_c04*s_c20 + f_c14*s_c21 + f_c24*s_c22)); - output.set(3, 0, (short) (f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32)); - output.set(3, 1, (short) (f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32)); - output.set(3, 2, (short) (f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32)); - output.set(3, 3, (short) (f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32)); - output.set(3, 4, (short) (f_c04*s_c30 + f_c14*s_c31 + f_c24*s_c32)); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f21 = matrix1.get(2, 1); + final short f02 = matrix1.get(0, 2); + final short f12 = matrix1.get(1, 2); + final short f22 = matrix1.get(2, 2); + final short f03 = matrix1.get(0, 3); + final short f13 = matrix1.get(1, 3); + final short f23 = matrix1.get(2, 3); + final short f04 = matrix1.get(0, 4); + final short f14 = matrix1.get(1, 4); + final short f24 = matrix1.get(2, 4); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + final short s30 = matrix2.get(3, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s21 = matrix2.get(2, 1); + final short s31 = matrix2.get(3, 1); + final short s02 = matrix2.get(0, 2); + final short s12 = matrix2.get(1, 2); + final short s22 = matrix2.get(2, 2); + final short s32 = matrix2.get(3, 2); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11 + f20 * s12)); + output.set(2, 0, (short) (f00 * s20 + f10 * s21 + f20 * s22)); + output.set(3, 0, (short) (f00 * s30 + f10 * s31 + f20 * s32)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01 + f21 * s02)); + output.set(1, 1, (short) (f01 * s10 + f11 * s11 + f21 * s12)); + output.set(2, 1, (short) (f01 * s20 + f11 * s21 + f21 * s22)); + output.set(3, 1, (short) (f01 * s30 + f11 * s31 + f21 * s32)); + output.set(0, 2, (short) (f02 * s00 + f12 * s01 + f22 * s02)); + output.set(1, 2, (short) (f02 * s10 + f12 * s11 + f22 * s12)); + output.set(2, 2, (short) (f02 * s20 + f12 * s21 + f22 * s22)); + output.set(3, 2, (short) (f02 * s30 + f12 * s31 + f22 * s32)); + output.set(0, 3, (short) (f03 * s00 + f13 * s01 + f23 * s02)); + output.set(1, 3, (short) (f03 * s10 + f13 * s11 + f23 * s12)); + output.set(2, 3, (short) (f03 * s20 + f13 * s21 + f23 * s22)); + output.set(3, 3, (short) (f03 * s30 + f13 * s31 + f23 * s32)); + output.set(0, 4, (short) (f04 * s00 + f14 * s01 + f24 * s02)); + output.set(1, 4, (short) (f04 * s10 + f14 * s11 + f24 * s12)); + output.set(2, 4, (short) (f04 * s20 + f14 * s21 + f24 * s22)); + output.set(3, 4, (short) (f04 * s30 + f14 * s31 + f24 * s32)); return output; } private static IMatrixSetterShort multiplyMatrix5x3x5(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final short f_c00 = matrix1.get(0, 0); - final short f_c10 = matrix1.get(1, 0); - final short f_c20 = matrix1.get(2, 0); - final short f_c01 = matrix1.get(0, 1); - final short f_c11 = matrix1.get(1, 1); - final short f_c21 = matrix1.get(2, 1); - final short f_c02 = matrix1.get(0, 2); - final short f_c12 = matrix1.get(1, 2); - final short f_c22 = matrix1.get(2, 2); - final short f_c03 = matrix1.get(0, 3); - final short f_c13 = matrix1.get(1, 3); - final short f_c23 = matrix1.get(2, 3); - final short f_c04 = matrix1.get(0, 4); - final short f_c14 = matrix1.get(1, 4); - final short f_c24 = matrix1.get(2, 4); - final short s_c00 = matrix2.get(0, 0); - final short s_c10 = matrix2.get(1, 0); - final short s_c20 = matrix2.get(2, 0); - final short s_c30 = matrix2.get(3, 0); - final short s_c40 = matrix2.get(4, 0); - final short s_c01 = matrix2.get(0, 1); - final short s_c11 = matrix2.get(1, 1); - final short s_c21 = matrix2.get(2, 1); - final short s_c31 = matrix2.get(3, 1); - final short s_c41 = matrix2.get(4, 1); - final short s_c02 = matrix2.get(0, 2); - final short s_c12 = matrix2.get(1, 2); - final short s_c22 = matrix2.get(2, 2); - final short s_c32 = matrix2.get(3, 2); - final short s_c42 = matrix2.get(4, 2); - output.set(0, 0, (short) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02)); - output.set(0, 1, (short) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02)); - output.set(0, 2, (short) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02)); - output.set(0, 3, (short) (f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02)); - output.set(0, 4, (short) (f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02)); - output.set(1, 0, (short) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12)); - output.set(1, 1, (short) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12)); - output.set(1, 2, (short) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12)); - output.set(1, 3, (short) (f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12)); - output.set(1, 4, (short) (f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12)); - output.set(2, 0, (short) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22)); - output.set(2, 1, (short) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22)); - output.set(2, 2, (short) (f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22)); - output.set(2, 3, (short) (f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22)); - output.set(2, 4, (short) (f_c04*s_c20 + f_c14*s_c21 + f_c24*s_c22)); - output.set(3, 0, (short) (f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32)); - output.set(3, 1, (short) (f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32)); - output.set(3, 2, (short) (f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32)); - output.set(3, 3, (short) (f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32)); - output.set(3, 4, (short) (f_c04*s_c30 + f_c14*s_c31 + f_c24*s_c32)); - output.set(4, 0, (short) (f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42)); - output.set(4, 1, (short) (f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42)); - output.set(4, 2, (short) (f_c02*s_c40 + f_c12*s_c41 + f_c22*s_c42)); - output.set(4, 3, (short) (f_c03*s_c40 + f_c13*s_c41 + f_c23*s_c42)); - output.set(4, 4, (short) (f_c04*s_c40 + f_c14*s_c41 + f_c24*s_c42)); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f21 = matrix1.get(2, 1); + final short f02 = matrix1.get(0, 2); + final short f12 = matrix1.get(1, 2); + final short f22 = matrix1.get(2, 2); + final short f03 = matrix1.get(0, 3); + final short f13 = matrix1.get(1, 3); + final short f23 = matrix1.get(2, 3); + final short f04 = matrix1.get(0, 4); + final short f14 = matrix1.get(1, 4); + final short f24 = matrix1.get(2, 4); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + final short s30 = matrix2.get(3, 0); + final short s40 = matrix2.get(4, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s21 = matrix2.get(2, 1); + final short s31 = matrix2.get(3, 1); + final short s41 = matrix2.get(4, 1); + final short s02 = matrix2.get(0, 2); + final short s12 = matrix2.get(1, 2); + final short s22 = matrix2.get(2, 2); + final short s32 = matrix2.get(3, 2); + final short s42 = matrix2.get(4, 2); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11 + f20 * s12)); + output.set(2, 0, (short) (f00 * s20 + f10 * s21 + f20 * s22)); + output.set(3, 0, (short) (f00 * s30 + f10 * s31 + f20 * s32)); + output.set(4, 0, (short) (f00 * s40 + f10 * s41 + f20 * s42)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01 + f21 * s02)); + output.set(1, 1, (short) (f01 * s10 + f11 * s11 + f21 * s12)); + output.set(2, 1, (short) (f01 * s20 + f11 * s21 + f21 * s22)); + output.set(3, 1, (short) (f01 * s30 + f11 * s31 + f21 * s32)); + output.set(4, 1, (short) (f01 * s40 + f11 * s41 + f21 * s42)); + output.set(0, 2, (short) (f02 * s00 + f12 * s01 + f22 * s02)); + output.set(1, 2, (short) (f02 * s10 + f12 * s11 + f22 * s12)); + output.set(2, 2, (short) (f02 * s20 + f12 * s21 + f22 * s22)); + output.set(3, 2, (short) (f02 * s30 + f12 * s31 + f22 * s32)); + output.set(4, 2, (short) (f02 * s40 + f12 * s41 + f22 * s42)); + output.set(0, 3, (short) (f03 * s00 + f13 * s01 + f23 * s02)); + output.set(1, 3, (short) (f03 * s10 + f13 * s11 + f23 * s12)); + output.set(2, 3, (short) (f03 * s20 + f13 * s21 + f23 * s22)); + output.set(3, 3, (short) (f03 * s30 + f13 * s31 + f23 * s32)); + output.set(4, 3, (short) (f03 * s40 + f13 * s41 + f23 * s42)); + output.set(0, 4, (short) (f04 * s00 + f14 * s01 + f24 * s02)); + output.set(1, 4, (short) (f04 * s10 + f14 * s11 + f24 * s12)); + output.set(2, 4, (short) (f04 * s20 + f14 * s21 + f24 * s22)); + output.set(3, 4, (short) (f04 * s30 + f14 * s31 + f24 * s32)); + output.set(4, 4, (short) (f04 * s40 + f14 * s41 + f24 * s42)); + return output; + } + + private static IMatrixSetterShort multiplyMatrix1x4x1(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short f30 = matrix1.get(3, 0); + final short s00 = matrix2.get(0, 0); + final short s01 = matrix2.get(0, 1); + final short s02 = matrix2.get(0, 2); + final short s03 = matrix2.get(0, 3); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03)); + return output; + } + + private static IMatrixSetterShort multiplyMatrix1x4x2(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short f30 = matrix1.get(3, 0); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s02 = matrix2.get(0, 2); + final short s12 = matrix2.get(1, 2); + final short s03 = matrix2.get(0, 3); + final short s13 = matrix2.get(1, 3); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13)); + return output; + } + + private static IMatrixSetterShort multiplyMatrix1x4x3(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short f30 = matrix1.get(3, 0); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s21 = matrix2.get(2, 1); + final short s02 = matrix2.get(0, 2); + final short s12 = matrix2.get(1, 2); + final short s22 = matrix2.get(2, 2); + final short s03 = matrix2.get(0, 3); + final short s13 = matrix2.get(1, 3); + final short s23 = matrix2.get(2, 3); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13)); + output.set(2, 0, (short) (f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23)); + return output; + } + + private static IMatrixSetterShort multiplyMatrix1x4x4(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short f30 = matrix1.get(3, 0); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + final short s30 = matrix2.get(3, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s21 = matrix2.get(2, 1); + final short s31 = matrix2.get(3, 1); + final short s02 = matrix2.get(0, 2); + final short s12 = matrix2.get(1, 2); + final short s22 = matrix2.get(2, 2); + final short s32 = matrix2.get(3, 2); + final short s03 = matrix2.get(0, 3); + final short s13 = matrix2.get(1, 3); + final short s23 = matrix2.get(2, 3); + final short s33 = matrix2.get(3, 3); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13)); + output.set(2, 0, (short) (f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23)); + output.set(3, 0, (short) (f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33)); + return output; + } + + private static IMatrixSetterShort multiplyMatrix1x4x5(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short f30 = matrix1.get(3, 0); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + final short s30 = matrix2.get(3, 0); + final short s40 = matrix2.get(4, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s21 = matrix2.get(2, 1); + final short s31 = matrix2.get(3, 1); + final short s41 = matrix2.get(4, 1); + final short s02 = matrix2.get(0, 2); + final short s12 = matrix2.get(1, 2); + final short s22 = matrix2.get(2, 2); + final short s32 = matrix2.get(3, 2); + final short s42 = matrix2.get(4, 2); + final short s03 = matrix2.get(0, 3); + final short s13 = matrix2.get(1, 3); + final short s23 = matrix2.get(2, 3); + final short s33 = matrix2.get(3, 3); + final short s43 = matrix2.get(4, 3); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13)); + output.set(2, 0, (short) (f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23)); + output.set(3, 0, (short) (f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33)); + output.set(4, 0, (short) (f00 * s40 + f10 * s41 + f20 * s42 + f30 * s43)); + return output; + } + + private static IMatrixSetterShort multiplyMatrix2x4x1(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short f30 = matrix1.get(3, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f21 = matrix1.get(2, 1); + final short f31 = matrix1.get(3, 1); + final short s00 = matrix2.get(0, 0); + final short s01 = matrix2.get(0, 1); + final short s02 = matrix2.get(0, 2); + final short s03 = matrix2.get(0, 3); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03)); return output; } private static IMatrixSetterShort multiplyMatrix2x4x2(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final short f_c00 = matrix1.get(0, 0); - final short f_c10 = matrix1.get(1, 0); - final short f_c20 = matrix1.get(2, 0); - final short f_c30 = matrix1.get(3, 0); - final short f_c01 = matrix1.get(0, 1); - final short f_c11 = matrix1.get(1, 1); - final short f_c21 = matrix1.get(2, 1); - final short f_c31 = matrix1.get(3, 1); - final short s_c00 = matrix2.get(0, 0); - final short s_c10 = matrix2.get(1, 0); - final short s_c01 = matrix2.get(0, 1); - final short s_c11 = matrix2.get(1, 1); - final short s_c02 = matrix2.get(0, 2); - final short s_c12 = matrix2.get(1, 2); - final short s_c03 = matrix2.get(0, 3); - final short s_c13 = matrix2.get(1, 3); - output.set(0, 0, (short) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03)); - output.set(0, 1, (short) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03)); - output.set(1, 0, (short) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13)); - output.set(1, 1, (short) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13)); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short f30 = matrix1.get(3, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f21 = matrix1.get(2, 1); + final short f31 = matrix1.get(3, 1); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s02 = matrix2.get(0, 2); + final short s12 = matrix2.get(1, 2); + final short s03 = matrix2.get(0, 3); + final short s13 = matrix2.get(1, 3); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03)); + output.set(1, 1, (short) (f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13)); return output; } private static IMatrixSetterShort multiplyMatrix2x4x3(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final short f_c00 = matrix1.get(0, 0); - final short f_c10 = matrix1.get(1, 0); - final short f_c20 = matrix1.get(2, 0); - final short f_c30 = matrix1.get(3, 0); - final short f_c01 = matrix1.get(0, 1); - final short f_c11 = matrix1.get(1, 1); - final short f_c21 = matrix1.get(2, 1); - final short f_c31 = matrix1.get(3, 1); - final short s_c00 = matrix2.get(0, 0); - final short s_c10 = matrix2.get(1, 0); - final short s_c20 = matrix2.get(2, 0); - final short s_c01 = matrix2.get(0, 1); - final short s_c11 = matrix2.get(1, 1); - final short s_c21 = matrix2.get(2, 1); - final short s_c02 = matrix2.get(0, 2); - final short s_c12 = matrix2.get(1, 2); - final short s_c22 = matrix2.get(2, 2); - final short s_c03 = matrix2.get(0, 3); - final short s_c13 = matrix2.get(1, 3); - final short s_c23 = matrix2.get(2, 3); - output.set(0, 0, (short) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03)); - output.set(0, 1, (short) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03)); - output.set(1, 0, (short) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13)); - output.set(1, 1, (short) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13)); - output.set(2, 0, (short) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23)); - output.set(2, 1, (short) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23)); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short f30 = matrix1.get(3, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f21 = matrix1.get(2, 1); + final short f31 = matrix1.get(3, 1); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s21 = matrix2.get(2, 1); + final short s02 = matrix2.get(0, 2); + final short s12 = matrix2.get(1, 2); + final short s22 = matrix2.get(2, 2); + final short s03 = matrix2.get(0, 3); + final short s13 = matrix2.get(1, 3); + final short s23 = matrix2.get(2, 3); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13)); + output.set(2, 0, (short) (f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03)); + output.set(1, 1, (short) (f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13)); + output.set(2, 1, (short) (f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23)); return output; } private static IMatrixSetterShort multiplyMatrix2x4x4(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final short f_c00 = matrix1.get(0, 0); - final short f_c10 = matrix1.get(1, 0); - final short f_c20 = matrix1.get(2, 0); - final short f_c30 = matrix1.get(3, 0); - final short f_c01 = matrix1.get(0, 1); - final short f_c11 = matrix1.get(1, 1); - final short f_c21 = matrix1.get(2, 1); - final short f_c31 = matrix1.get(3, 1); - final short s_c00 = matrix2.get(0, 0); - final short s_c10 = matrix2.get(1, 0); - final short s_c20 = matrix2.get(2, 0); - final short s_c30 = matrix2.get(3, 0); - final short s_c01 = matrix2.get(0, 1); - final short s_c11 = matrix2.get(1, 1); - final short s_c21 = matrix2.get(2, 1); - final short s_c31 = matrix2.get(3, 1); - final short s_c02 = matrix2.get(0, 2); - final short s_c12 = matrix2.get(1, 2); - final short s_c22 = matrix2.get(2, 2); - final short s_c32 = matrix2.get(3, 2); - final short s_c03 = matrix2.get(0, 3); - final short s_c13 = matrix2.get(1, 3); - final short s_c23 = matrix2.get(2, 3); - final short s_c33 = matrix2.get(3, 3); - output.set(0, 0, (short) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03)); - output.set(0, 1, (short) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03)); - output.set(1, 0, (short) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13)); - output.set(1, 1, (short) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13)); - output.set(2, 0, (short) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23)); - output.set(2, 1, (short) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23)); - output.set(3, 0, (short) (f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33)); - output.set(3, 1, (short) (f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33)); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short f30 = matrix1.get(3, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f21 = matrix1.get(2, 1); + final short f31 = matrix1.get(3, 1); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + final short s30 = matrix2.get(3, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s21 = matrix2.get(2, 1); + final short s31 = matrix2.get(3, 1); + final short s02 = matrix2.get(0, 2); + final short s12 = matrix2.get(1, 2); + final short s22 = matrix2.get(2, 2); + final short s32 = matrix2.get(3, 2); + final short s03 = matrix2.get(0, 3); + final short s13 = matrix2.get(1, 3); + final short s23 = matrix2.get(2, 3); + final short s33 = matrix2.get(3, 3); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13)); + output.set(2, 0, (short) (f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23)); + output.set(3, 0, (short) (f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03)); + output.set(1, 1, (short) (f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13)); + output.set(2, 1, (short) (f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23)); + output.set(3, 1, (short) (f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33)); return output; } private static IMatrixSetterShort multiplyMatrix2x4x5(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final short f_c00 = matrix1.get(0, 0); - final short f_c10 = matrix1.get(1, 0); - final short f_c20 = matrix1.get(2, 0); - final short f_c30 = matrix1.get(3, 0); - final short f_c01 = matrix1.get(0, 1); - final short f_c11 = matrix1.get(1, 1); - final short f_c21 = matrix1.get(2, 1); - final short f_c31 = matrix1.get(3, 1); - final short s_c00 = matrix2.get(0, 0); - final short s_c10 = matrix2.get(1, 0); - final short s_c20 = matrix2.get(2, 0); - final short s_c30 = matrix2.get(3, 0); - final short s_c40 = matrix2.get(4, 0); - final short s_c01 = matrix2.get(0, 1); - final short s_c11 = matrix2.get(1, 1); - final short s_c21 = matrix2.get(2, 1); - final short s_c31 = matrix2.get(3, 1); - final short s_c41 = matrix2.get(4, 1); - final short s_c02 = matrix2.get(0, 2); - final short s_c12 = matrix2.get(1, 2); - final short s_c22 = matrix2.get(2, 2); - final short s_c32 = matrix2.get(3, 2); - final short s_c42 = matrix2.get(4, 2); - final short s_c03 = matrix2.get(0, 3); - final short s_c13 = matrix2.get(1, 3); - final short s_c23 = matrix2.get(2, 3); - final short s_c33 = matrix2.get(3, 3); - final short s_c43 = matrix2.get(4, 3); - output.set(0, 0, (short) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03)); - output.set(0, 1, (short) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03)); - output.set(1, 0, (short) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13)); - output.set(1, 1, (short) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13)); - output.set(2, 0, (short) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23)); - output.set(2, 1, (short) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23)); - output.set(3, 0, (short) (f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33)); - output.set(3, 1, (short) (f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33)); - output.set(4, 0, (short) (f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42 + f_c30*s_c43)); - output.set(4, 1, (short) (f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42 + f_c31*s_c43)); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short f30 = matrix1.get(3, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f21 = matrix1.get(2, 1); + final short f31 = matrix1.get(3, 1); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + final short s30 = matrix2.get(3, 0); + final short s40 = matrix2.get(4, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s21 = matrix2.get(2, 1); + final short s31 = matrix2.get(3, 1); + final short s41 = matrix2.get(4, 1); + final short s02 = matrix2.get(0, 2); + final short s12 = matrix2.get(1, 2); + final short s22 = matrix2.get(2, 2); + final short s32 = matrix2.get(3, 2); + final short s42 = matrix2.get(4, 2); + final short s03 = matrix2.get(0, 3); + final short s13 = matrix2.get(1, 3); + final short s23 = matrix2.get(2, 3); + final short s33 = matrix2.get(3, 3); + final short s43 = matrix2.get(4, 3); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13)); + output.set(2, 0, (short) (f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23)); + output.set(3, 0, (short) (f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33)); + output.set(4, 0, (short) (f00 * s40 + f10 * s41 + f20 * s42 + f30 * s43)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03)); + output.set(1, 1, (short) (f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13)); + output.set(2, 1, (short) (f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23)); + output.set(3, 1, (short) (f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33)); + output.set(4, 1, (short) (f01 * s40 + f11 * s41 + f21 * s42 + f31 * s43)); + return output; + } + + private static IMatrixSetterShort multiplyMatrix3x4x1(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short f30 = matrix1.get(3, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f21 = matrix1.get(2, 1); + final short f31 = matrix1.get(3, 1); + final short f02 = matrix1.get(0, 2); + final short f12 = matrix1.get(1, 2); + final short f22 = matrix1.get(2, 2); + final short f32 = matrix1.get(3, 2); + final short s00 = matrix2.get(0, 0); + final short s01 = matrix2.get(0, 1); + final short s02 = matrix2.get(0, 2); + final short s03 = matrix2.get(0, 3); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03)); + output.set(0, 2, (short) (f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03)); return output; } private static IMatrixSetterShort multiplyMatrix3x4x2(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final short f_c00 = matrix1.get(0, 0); - final short f_c10 = matrix1.get(1, 0); - final short f_c20 = matrix1.get(2, 0); - final short f_c30 = matrix1.get(3, 0); - final short f_c01 = matrix1.get(0, 1); - final short f_c11 = matrix1.get(1, 1); - final short f_c21 = matrix1.get(2, 1); - final short f_c31 = matrix1.get(3, 1); - final short f_c02 = matrix1.get(0, 2); - final short f_c12 = matrix1.get(1, 2); - final short f_c22 = matrix1.get(2, 2); - final short f_c32 = matrix1.get(3, 2); - final short s_c00 = matrix2.get(0, 0); - final short s_c10 = matrix2.get(1, 0); - final short s_c01 = matrix2.get(0, 1); - final short s_c11 = matrix2.get(1, 1); - final short s_c02 = matrix2.get(0, 2); - final short s_c12 = matrix2.get(1, 2); - final short s_c03 = matrix2.get(0, 3); - final short s_c13 = matrix2.get(1, 3); - output.set(0, 0, (short) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03)); - output.set(0, 1, (short) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03)); - output.set(0, 2, (short) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03)); - output.set(1, 0, (short) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13)); - output.set(1, 1, (short) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13)); - output.set(1, 2, (short) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13)); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short f30 = matrix1.get(3, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f21 = matrix1.get(2, 1); + final short f31 = matrix1.get(3, 1); + final short f02 = matrix1.get(0, 2); + final short f12 = matrix1.get(1, 2); + final short f22 = matrix1.get(2, 2); + final short f32 = matrix1.get(3, 2); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s02 = matrix2.get(0, 2); + final short s12 = matrix2.get(1, 2); + final short s03 = matrix2.get(0, 3); + final short s13 = matrix2.get(1, 3); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03)); + output.set(1, 1, (short) (f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13)); + output.set(0, 2, (short) (f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03)); + output.set(1, 2, (short) (f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13)); return output; } private static IMatrixSetterShort multiplyMatrix3x4x3(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final short f_c00 = matrix1.get(0, 0); - final short f_c10 = matrix1.get(1, 0); - final short f_c20 = matrix1.get(2, 0); - final short f_c30 = matrix1.get(3, 0); - final short f_c01 = matrix1.get(0, 1); - final short f_c11 = matrix1.get(1, 1); - final short f_c21 = matrix1.get(2, 1); - final short f_c31 = matrix1.get(3, 1); - final short f_c02 = matrix1.get(0, 2); - final short f_c12 = matrix1.get(1, 2); - final short f_c22 = matrix1.get(2, 2); - final short f_c32 = matrix1.get(3, 2); - final short s_c00 = matrix2.get(0, 0); - final short s_c10 = matrix2.get(1, 0); - final short s_c20 = matrix2.get(2, 0); - final short s_c01 = matrix2.get(0, 1); - final short s_c11 = matrix2.get(1, 1); - final short s_c21 = matrix2.get(2, 1); - final short s_c02 = matrix2.get(0, 2); - final short s_c12 = matrix2.get(1, 2); - final short s_c22 = matrix2.get(2, 2); - final short s_c03 = matrix2.get(0, 3); - final short s_c13 = matrix2.get(1, 3); - final short s_c23 = matrix2.get(2, 3); - output.set(0, 0, (short) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03)); - output.set(0, 1, (short) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03)); - output.set(0, 2, (short) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03)); - output.set(1, 0, (short) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13)); - output.set(1, 1, (short) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13)); - output.set(1, 2, (short) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13)); - output.set(2, 0, (short) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23)); - output.set(2, 1, (short) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23)); - output.set(2, 2, (short) (f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23)); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short f30 = matrix1.get(3, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f21 = matrix1.get(2, 1); + final short f31 = matrix1.get(3, 1); + final short f02 = matrix1.get(0, 2); + final short f12 = matrix1.get(1, 2); + final short f22 = matrix1.get(2, 2); + final short f32 = matrix1.get(3, 2); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s21 = matrix2.get(2, 1); + final short s02 = matrix2.get(0, 2); + final short s12 = matrix2.get(1, 2); + final short s22 = matrix2.get(2, 2); + final short s03 = matrix2.get(0, 3); + final short s13 = matrix2.get(1, 3); + final short s23 = matrix2.get(2, 3); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13)); + output.set(2, 0, (short) (f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03)); + output.set(1, 1, (short) (f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13)); + output.set(2, 1, (short) (f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23)); + output.set(0, 2, (short) (f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03)); + output.set(1, 2, (short) (f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13)); + output.set(2, 2, (short) (f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23)); return output; } private static IMatrixSetterShort multiplyMatrix3x4x4(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final short f_c00 = matrix1.get(0, 0); - final short f_c10 = matrix1.get(1, 0); - final short f_c20 = matrix1.get(2, 0); - final short f_c30 = matrix1.get(3, 0); - final short f_c01 = matrix1.get(0, 1); - final short f_c11 = matrix1.get(1, 1); - final short f_c21 = matrix1.get(2, 1); - final short f_c31 = matrix1.get(3, 1); - final short f_c02 = matrix1.get(0, 2); - final short f_c12 = matrix1.get(1, 2); - final short f_c22 = matrix1.get(2, 2); - final short f_c32 = matrix1.get(3, 2); - final short s_c00 = matrix2.get(0, 0); - final short s_c10 = matrix2.get(1, 0); - final short s_c20 = matrix2.get(2, 0); - final short s_c30 = matrix2.get(3, 0); - final short s_c01 = matrix2.get(0, 1); - final short s_c11 = matrix2.get(1, 1); - final short s_c21 = matrix2.get(2, 1); - final short s_c31 = matrix2.get(3, 1); - final short s_c02 = matrix2.get(0, 2); - final short s_c12 = matrix2.get(1, 2); - final short s_c22 = matrix2.get(2, 2); - final short s_c32 = matrix2.get(3, 2); - final short s_c03 = matrix2.get(0, 3); - final short s_c13 = matrix2.get(1, 3); - final short s_c23 = matrix2.get(2, 3); - final short s_c33 = matrix2.get(3, 3); - output.set(0, 0, (short) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03)); - output.set(0, 1, (short) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03)); - output.set(0, 2, (short) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03)); - output.set(1, 0, (short) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13)); - output.set(1, 1, (short) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13)); - output.set(1, 2, (short) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13)); - output.set(2, 0, (short) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23)); - output.set(2, 1, (short) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23)); - output.set(2, 2, (short) (f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23)); - output.set(3, 0, (short) (f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33)); - output.set(3, 1, (short) (f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33)); - output.set(3, 2, (short) (f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33)); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short f30 = matrix1.get(3, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f21 = matrix1.get(2, 1); + final short f31 = matrix1.get(3, 1); + final short f02 = matrix1.get(0, 2); + final short f12 = matrix1.get(1, 2); + final short f22 = matrix1.get(2, 2); + final short f32 = matrix1.get(3, 2); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + final short s30 = matrix2.get(3, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s21 = matrix2.get(2, 1); + final short s31 = matrix2.get(3, 1); + final short s02 = matrix2.get(0, 2); + final short s12 = matrix2.get(1, 2); + final short s22 = matrix2.get(2, 2); + final short s32 = matrix2.get(3, 2); + final short s03 = matrix2.get(0, 3); + final short s13 = matrix2.get(1, 3); + final short s23 = matrix2.get(2, 3); + final short s33 = matrix2.get(3, 3); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13)); + output.set(2, 0, (short) (f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23)); + output.set(3, 0, (short) (f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03)); + output.set(1, 1, (short) (f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13)); + output.set(2, 1, (short) (f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23)); + output.set(3, 1, (short) (f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33)); + output.set(0, 2, (short) (f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03)); + output.set(1, 2, (short) (f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13)); + output.set(2, 2, (short) (f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23)); + output.set(3, 2, (short) (f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33)); return output; } private static IMatrixSetterShort multiplyMatrix3x4x5(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final short f_c00 = matrix1.get(0, 0); - final short f_c10 = matrix1.get(1, 0); - final short f_c20 = matrix1.get(2, 0); - final short f_c30 = matrix1.get(3, 0); - final short f_c01 = matrix1.get(0, 1); - final short f_c11 = matrix1.get(1, 1); - final short f_c21 = matrix1.get(2, 1); - final short f_c31 = matrix1.get(3, 1); - final short f_c02 = matrix1.get(0, 2); - final short f_c12 = matrix1.get(1, 2); - final short f_c22 = matrix1.get(2, 2); - final short f_c32 = matrix1.get(3, 2); - final short s_c00 = matrix2.get(0, 0); - final short s_c10 = matrix2.get(1, 0); - final short s_c20 = matrix2.get(2, 0); - final short s_c30 = matrix2.get(3, 0); - final short s_c40 = matrix2.get(4, 0); - final short s_c01 = matrix2.get(0, 1); - final short s_c11 = matrix2.get(1, 1); - final short s_c21 = matrix2.get(2, 1); - final short s_c31 = matrix2.get(3, 1); - final short s_c41 = matrix2.get(4, 1); - final short s_c02 = matrix2.get(0, 2); - final short s_c12 = matrix2.get(1, 2); - final short s_c22 = matrix2.get(2, 2); - final short s_c32 = matrix2.get(3, 2); - final short s_c42 = matrix2.get(4, 2); - final short s_c03 = matrix2.get(0, 3); - final short s_c13 = matrix2.get(1, 3); - final short s_c23 = matrix2.get(2, 3); - final short s_c33 = matrix2.get(3, 3); - final short s_c43 = matrix2.get(4, 3); - output.set(0, 0, (short) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03)); - output.set(0, 1, (short) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03)); - output.set(0, 2, (short) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03)); - output.set(1, 0, (short) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13)); - output.set(1, 1, (short) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13)); - output.set(1, 2, (short) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13)); - output.set(2, 0, (short) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23)); - output.set(2, 1, (short) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23)); - output.set(2, 2, (short) (f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23)); - output.set(3, 0, (short) (f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33)); - output.set(3, 1, (short) (f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33)); - output.set(3, 2, (short) (f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33)); - output.set(4, 0, (short) (f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42 + f_c30*s_c43)); - output.set(4, 1, (short) (f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42 + f_c31*s_c43)); - output.set(4, 2, (short) (f_c02*s_c40 + f_c12*s_c41 + f_c22*s_c42 + f_c32*s_c43)); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short f30 = matrix1.get(3, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f21 = matrix1.get(2, 1); + final short f31 = matrix1.get(3, 1); + final short f02 = matrix1.get(0, 2); + final short f12 = matrix1.get(1, 2); + final short f22 = matrix1.get(2, 2); + final short f32 = matrix1.get(3, 2); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + final short s30 = matrix2.get(3, 0); + final short s40 = matrix2.get(4, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s21 = matrix2.get(2, 1); + final short s31 = matrix2.get(3, 1); + final short s41 = matrix2.get(4, 1); + final short s02 = matrix2.get(0, 2); + final short s12 = matrix2.get(1, 2); + final short s22 = matrix2.get(2, 2); + final short s32 = matrix2.get(3, 2); + final short s42 = matrix2.get(4, 2); + final short s03 = matrix2.get(0, 3); + final short s13 = matrix2.get(1, 3); + final short s23 = matrix2.get(2, 3); + final short s33 = matrix2.get(3, 3); + final short s43 = matrix2.get(4, 3); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13)); + output.set(2, 0, (short) (f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23)); + output.set(3, 0, (short) (f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33)); + output.set(4, 0, (short) (f00 * s40 + f10 * s41 + f20 * s42 + f30 * s43)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03)); + output.set(1, 1, (short) (f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13)); + output.set(2, 1, (short) (f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23)); + output.set(3, 1, (short) (f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33)); + output.set(4, 1, (short) (f01 * s40 + f11 * s41 + f21 * s42 + f31 * s43)); + output.set(0, 2, (short) (f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03)); + output.set(1, 2, (short) (f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13)); + output.set(2, 2, (short) (f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23)); + output.set(3, 2, (short) (f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33)); + output.set(4, 2, (short) (f02 * s40 + f12 * s41 + f22 * s42 + f32 * s43)); + return output; + } + + private static IMatrixSetterShort multiplyMatrix4x4x1(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short f30 = matrix1.get(3, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f21 = matrix1.get(2, 1); + final short f31 = matrix1.get(3, 1); + final short f02 = matrix1.get(0, 2); + final short f12 = matrix1.get(1, 2); + final short f22 = matrix1.get(2, 2); + final short f32 = matrix1.get(3, 2); + final short f03 = matrix1.get(0, 3); + final short f13 = matrix1.get(1, 3); + final short f23 = matrix1.get(2, 3); + final short f33 = matrix1.get(3, 3); + final short s00 = matrix2.get(0, 0); + final short s01 = matrix2.get(0, 1); + final short s02 = matrix2.get(0, 2); + final short s03 = matrix2.get(0, 3); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03)); + output.set(0, 2, (short) (f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03)); + output.set(0, 3, (short) (f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03)); return output; } private static IMatrixSetterShort multiplyMatrix4x4x2(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final short f_c00 = matrix1.get(0, 0); - final short f_c10 = matrix1.get(1, 0); - final short f_c20 = matrix1.get(2, 0); - final short f_c30 = matrix1.get(3, 0); - final short f_c01 = matrix1.get(0, 1); - final short f_c11 = matrix1.get(1, 1); - final short f_c21 = matrix1.get(2, 1); - final short f_c31 = matrix1.get(3, 1); - final short f_c02 = matrix1.get(0, 2); - final short f_c12 = matrix1.get(1, 2); - final short f_c22 = matrix1.get(2, 2); - final short f_c32 = matrix1.get(3, 2); - final short f_c03 = matrix1.get(0, 3); - final short f_c13 = matrix1.get(1, 3); - final short f_c23 = matrix1.get(2, 3); - final short f_c33 = matrix1.get(3, 3); - final short s_c00 = matrix2.get(0, 0); - final short s_c10 = matrix2.get(1, 0); - final short s_c01 = matrix2.get(0, 1); - final short s_c11 = matrix2.get(1, 1); - final short s_c02 = matrix2.get(0, 2); - final short s_c12 = matrix2.get(1, 2); - final short s_c03 = matrix2.get(0, 3); - final short s_c13 = matrix2.get(1, 3); - output.set(0, 0, (short) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03)); - output.set(0, 1, (short) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03)); - output.set(0, 2, (short) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03)); - output.set(0, 3, (short) (f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03)); - output.set(1, 0, (short) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13)); - output.set(1, 1, (short) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13)); - output.set(1, 2, (short) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13)); - output.set(1, 3, (short) (f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13)); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short f30 = matrix1.get(3, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f21 = matrix1.get(2, 1); + final short f31 = matrix1.get(3, 1); + final short f02 = matrix1.get(0, 2); + final short f12 = matrix1.get(1, 2); + final short f22 = matrix1.get(2, 2); + final short f32 = matrix1.get(3, 2); + final short f03 = matrix1.get(0, 3); + final short f13 = matrix1.get(1, 3); + final short f23 = matrix1.get(2, 3); + final short f33 = matrix1.get(3, 3); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s02 = matrix2.get(0, 2); + final short s12 = matrix2.get(1, 2); + final short s03 = matrix2.get(0, 3); + final short s13 = matrix2.get(1, 3); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03)); + output.set(1, 1, (short) (f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13)); + output.set(0, 2, (short) (f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03)); + output.set(1, 2, (short) (f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13)); + output.set(0, 3, (short) (f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03)); + output.set(1, 3, (short) (f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13)); return output; } private static IMatrixSetterShort multiplyMatrix4x4x3(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final short f_c00 = matrix1.get(0, 0); - final short f_c10 = matrix1.get(1, 0); - final short f_c20 = matrix1.get(2, 0); - final short f_c30 = matrix1.get(3, 0); - final short f_c01 = matrix1.get(0, 1); - final short f_c11 = matrix1.get(1, 1); - final short f_c21 = matrix1.get(2, 1); - final short f_c31 = matrix1.get(3, 1); - final short f_c02 = matrix1.get(0, 2); - final short f_c12 = matrix1.get(1, 2); - final short f_c22 = matrix1.get(2, 2); - final short f_c32 = matrix1.get(3, 2); - final short f_c03 = matrix1.get(0, 3); - final short f_c13 = matrix1.get(1, 3); - final short f_c23 = matrix1.get(2, 3); - final short f_c33 = matrix1.get(3, 3); - final short s_c00 = matrix2.get(0, 0); - final short s_c10 = matrix2.get(1, 0); - final short s_c20 = matrix2.get(2, 0); - final short s_c01 = matrix2.get(0, 1); - final short s_c11 = matrix2.get(1, 1); - final short s_c21 = matrix2.get(2, 1); - final short s_c02 = matrix2.get(0, 2); - final short s_c12 = matrix2.get(1, 2); - final short s_c22 = matrix2.get(2, 2); - final short s_c03 = matrix2.get(0, 3); - final short s_c13 = matrix2.get(1, 3); - final short s_c23 = matrix2.get(2, 3); - output.set(0, 0, (short) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03)); - output.set(0, 1, (short) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03)); - output.set(0, 2, (short) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03)); - output.set(0, 3, (short) (f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03)); - output.set(1, 0, (short) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13)); - output.set(1, 1, (short) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13)); - output.set(1, 2, (short) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13)); - output.set(1, 3, (short) (f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13)); - output.set(2, 0, (short) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23)); - output.set(2, 1, (short) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23)); - output.set(2, 2, (short) (f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23)); - output.set(2, 3, (short) (f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23)); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short f30 = matrix1.get(3, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f21 = matrix1.get(2, 1); + final short f31 = matrix1.get(3, 1); + final short f02 = matrix1.get(0, 2); + final short f12 = matrix1.get(1, 2); + final short f22 = matrix1.get(2, 2); + final short f32 = matrix1.get(3, 2); + final short f03 = matrix1.get(0, 3); + final short f13 = matrix1.get(1, 3); + final short f23 = matrix1.get(2, 3); + final short f33 = matrix1.get(3, 3); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s21 = matrix2.get(2, 1); + final short s02 = matrix2.get(0, 2); + final short s12 = matrix2.get(1, 2); + final short s22 = matrix2.get(2, 2); + final short s03 = matrix2.get(0, 3); + final short s13 = matrix2.get(1, 3); + final short s23 = matrix2.get(2, 3); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13)); + output.set(2, 0, (short) (f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03)); + output.set(1, 1, (short) (f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13)); + output.set(2, 1, (short) (f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23)); + output.set(0, 2, (short) (f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03)); + output.set(1, 2, (short) (f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13)); + output.set(2, 2, (short) (f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23)); + output.set(0, 3, (short) (f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03)); + output.set(1, 3, (short) (f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13)); + output.set(2, 3, (short) (f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23)); return output; } private static IMatrixSetterShort multiplyMatrix4x4x4(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final short f_c00 = matrix1.get(0, 0); - final short f_c10 = matrix1.get(1, 0); - final short f_c20 = matrix1.get(2, 0); - final short f_c30 = matrix1.get(3, 0); - final short f_c01 = matrix1.get(0, 1); - final short f_c11 = matrix1.get(1, 1); - final short f_c21 = matrix1.get(2, 1); - final short f_c31 = matrix1.get(3, 1); - final short f_c02 = matrix1.get(0, 2); - final short f_c12 = matrix1.get(1, 2); - final short f_c22 = matrix1.get(2, 2); - final short f_c32 = matrix1.get(3, 2); - final short f_c03 = matrix1.get(0, 3); - final short f_c13 = matrix1.get(1, 3); - final short f_c23 = matrix1.get(2, 3); - final short f_c33 = matrix1.get(3, 3); - final short s_c00 = matrix2.get(0, 0); - final short s_c10 = matrix2.get(1, 0); - final short s_c20 = matrix2.get(2, 0); - final short s_c30 = matrix2.get(3, 0); - final short s_c01 = matrix2.get(0, 1); - final short s_c11 = matrix2.get(1, 1); - final short s_c21 = matrix2.get(2, 1); - final short s_c31 = matrix2.get(3, 1); - final short s_c02 = matrix2.get(0, 2); - final short s_c12 = matrix2.get(1, 2); - final short s_c22 = matrix2.get(2, 2); - final short s_c32 = matrix2.get(3, 2); - final short s_c03 = matrix2.get(0, 3); - final short s_c13 = matrix2.get(1, 3); - final short s_c23 = matrix2.get(2, 3); - final short s_c33 = matrix2.get(3, 3); - output.set(0, 0, (short) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03)); - output.set(0, 1, (short) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03)); - output.set(0, 2, (short) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03)); - output.set(0, 3, (short) (f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03)); - output.set(1, 0, (short) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13)); - output.set(1, 1, (short) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13)); - output.set(1, 2, (short) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13)); - output.set(1, 3, (short) (f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13)); - output.set(2, 0, (short) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23)); - output.set(2, 1, (short) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23)); - output.set(2, 2, (short) (f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23)); - output.set(2, 3, (short) (f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23)); - output.set(3, 0, (short) (f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33)); - output.set(3, 1, (short) (f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33)); - output.set(3, 2, (short) (f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33)); - output.set(3, 3, (short) (f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32 + f_c33*s_c33)); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short f30 = matrix1.get(3, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f21 = matrix1.get(2, 1); + final short f31 = matrix1.get(3, 1); + final short f02 = matrix1.get(0, 2); + final short f12 = matrix1.get(1, 2); + final short f22 = matrix1.get(2, 2); + final short f32 = matrix1.get(3, 2); + final short f03 = matrix1.get(0, 3); + final short f13 = matrix1.get(1, 3); + final short f23 = matrix1.get(2, 3); + final short f33 = matrix1.get(3, 3); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + final short s30 = matrix2.get(3, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s21 = matrix2.get(2, 1); + final short s31 = matrix2.get(3, 1); + final short s02 = matrix2.get(0, 2); + final short s12 = matrix2.get(1, 2); + final short s22 = matrix2.get(2, 2); + final short s32 = matrix2.get(3, 2); + final short s03 = matrix2.get(0, 3); + final short s13 = matrix2.get(1, 3); + final short s23 = matrix2.get(2, 3); + final short s33 = matrix2.get(3, 3); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13)); + output.set(2, 0, (short) (f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23)); + output.set(3, 0, (short) (f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03)); + output.set(1, 1, (short) (f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13)); + output.set(2, 1, (short) (f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23)); + output.set(3, 1, (short) (f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33)); + output.set(0, 2, (short) (f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03)); + output.set(1, 2, (short) (f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13)); + output.set(2, 2, (short) (f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23)); + output.set(3, 2, (short) (f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33)); + output.set(0, 3, (short) (f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03)); + output.set(1, 3, (short) (f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13)); + output.set(2, 3, (short) (f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23)); + output.set(3, 3, (short) (f03 * s30 + f13 * s31 + f23 * s32 + f33 * s33)); return output; } private static IMatrixSetterShort multiplyMatrix4x4x5(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final short f_c00 = matrix1.get(0, 0); - final short f_c10 = matrix1.get(1, 0); - final short f_c20 = matrix1.get(2, 0); - final short f_c30 = matrix1.get(3, 0); - final short f_c01 = matrix1.get(0, 1); - final short f_c11 = matrix1.get(1, 1); - final short f_c21 = matrix1.get(2, 1); - final short f_c31 = matrix1.get(3, 1); - final short f_c02 = matrix1.get(0, 2); - final short f_c12 = matrix1.get(1, 2); - final short f_c22 = matrix1.get(2, 2); - final short f_c32 = matrix1.get(3, 2); - final short f_c03 = matrix1.get(0, 3); - final short f_c13 = matrix1.get(1, 3); - final short f_c23 = matrix1.get(2, 3); - final short f_c33 = matrix1.get(3, 3); - final short s_c00 = matrix2.get(0, 0); - final short s_c10 = matrix2.get(1, 0); - final short s_c20 = matrix2.get(2, 0); - final short s_c30 = matrix2.get(3, 0); - final short s_c40 = matrix2.get(4, 0); - final short s_c01 = matrix2.get(0, 1); - final short s_c11 = matrix2.get(1, 1); - final short s_c21 = matrix2.get(2, 1); - final short s_c31 = matrix2.get(3, 1); - final short s_c41 = matrix2.get(4, 1); - final short s_c02 = matrix2.get(0, 2); - final short s_c12 = matrix2.get(1, 2); - final short s_c22 = matrix2.get(2, 2); - final short s_c32 = matrix2.get(3, 2); - final short s_c42 = matrix2.get(4, 2); - final short s_c03 = matrix2.get(0, 3); - final short s_c13 = matrix2.get(1, 3); - final short s_c23 = matrix2.get(2, 3); - final short s_c33 = matrix2.get(3, 3); - final short s_c43 = matrix2.get(4, 3); - output.set(0, 0, (short) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03)); - output.set(0, 1, (short) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03)); - output.set(0, 2, (short) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03)); - output.set(0, 3, (short) (f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03)); - output.set(1, 0, (short) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13)); - output.set(1, 1, (short) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13)); - output.set(1, 2, (short) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13)); - output.set(1, 3, (short) (f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13)); - output.set(2, 0, (short) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23)); - output.set(2, 1, (short) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23)); - output.set(2, 2, (short) (f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23)); - output.set(2, 3, (short) (f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23)); - output.set(3, 0, (short) (f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33)); - output.set(3, 1, (short) (f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33)); - output.set(3, 2, (short) (f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33)); - output.set(3, 3, (short) (f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32 + f_c33*s_c33)); - output.set(4, 0, (short) (f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42 + f_c30*s_c43)); - output.set(4, 1, (short) (f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42 + f_c31*s_c43)); - output.set(4, 2, (short) (f_c02*s_c40 + f_c12*s_c41 + f_c22*s_c42 + f_c32*s_c43)); - output.set(4, 3, (short) (f_c03*s_c40 + f_c13*s_c41 + f_c23*s_c42 + f_c33*s_c43)); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short f30 = matrix1.get(3, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f21 = matrix1.get(2, 1); + final short f31 = matrix1.get(3, 1); + final short f02 = matrix1.get(0, 2); + final short f12 = matrix1.get(1, 2); + final short f22 = matrix1.get(2, 2); + final short f32 = matrix1.get(3, 2); + final short f03 = matrix1.get(0, 3); + final short f13 = matrix1.get(1, 3); + final short f23 = matrix1.get(2, 3); + final short f33 = matrix1.get(3, 3); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + final short s30 = matrix2.get(3, 0); + final short s40 = matrix2.get(4, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s21 = matrix2.get(2, 1); + final short s31 = matrix2.get(3, 1); + final short s41 = matrix2.get(4, 1); + final short s02 = matrix2.get(0, 2); + final short s12 = matrix2.get(1, 2); + final short s22 = matrix2.get(2, 2); + final short s32 = matrix2.get(3, 2); + final short s42 = matrix2.get(4, 2); + final short s03 = matrix2.get(0, 3); + final short s13 = matrix2.get(1, 3); + final short s23 = matrix2.get(2, 3); + final short s33 = matrix2.get(3, 3); + final short s43 = matrix2.get(4, 3); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13)); + output.set(2, 0, (short) (f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23)); + output.set(3, 0, (short) (f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33)); + output.set(4, 0, (short) (f00 * s40 + f10 * s41 + f20 * s42 + f30 * s43)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03)); + output.set(1, 1, (short) (f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13)); + output.set(2, 1, (short) (f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23)); + output.set(3, 1, (short) (f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33)); + output.set(4, 1, (short) (f01 * s40 + f11 * s41 + f21 * s42 + f31 * s43)); + output.set(0, 2, (short) (f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03)); + output.set(1, 2, (short) (f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13)); + output.set(2, 2, (short) (f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23)); + output.set(3, 2, (short) (f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33)); + output.set(4, 2, (short) (f02 * s40 + f12 * s41 + f22 * s42 + f32 * s43)); + output.set(0, 3, (short) (f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03)); + output.set(1, 3, (short) (f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13)); + output.set(2, 3, (short) (f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23)); + output.set(3, 3, (short) (f03 * s30 + f13 * s31 + f23 * s32 + f33 * s33)); + output.set(4, 3, (short) (f03 * s40 + f13 * s41 + f23 * s42 + f33 * s43)); + return output; + } + + private static IMatrixSetterShort multiplyMatrix5x4x1(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short f30 = matrix1.get(3, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f21 = matrix1.get(2, 1); + final short f31 = matrix1.get(3, 1); + final short f02 = matrix1.get(0, 2); + final short f12 = matrix1.get(1, 2); + final short f22 = matrix1.get(2, 2); + final short f32 = matrix1.get(3, 2); + final short f03 = matrix1.get(0, 3); + final short f13 = matrix1.get(1, 3); + final short f23 = matrix1.get(2, 3); + final short f33 = matrix1.get(3, 3); + final short f04 = matrix1.get(0, 4); + final short f14 = matrix1.get(1, 4); + final short f24 = matrix1.get(2, 4); + final short f34 = matrix1.get(3, 4); + final short s00 = matrix2.get(0, 0); + final short s01 = matrix2.get(0, 1); + final short s02 = matrix2.get(0, 2); + final short s03 = matrix2.get(0, 3); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03)); + output.set(0, 2, (short) (f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03)); + output.set(0, 3, (short) (f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03)); + output.set(0, 4, (short) (f04 * s00 + f14 * s01 + f24 * s02 + f34 * s03)); return output; } private static IMatrixSetterShort multiplyMatrix5x4x2(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final short f_c00 = matrix1.get(0, 0); - final short f_c10 = matrix1.get(1, 0); - final short f_c20 = matrix1.get(2, 0); - final short f_c30 = matrix1.get(3, 0); - final short f_c01 = matrix1.get(0, 1); - final short f_c11 = matrix1.get(1, 1); - final short f_c21 = matrix1.get(2, 1); - final short f_c31 = matrix1.get(3, 1); - final short f_c02 = matrix1.get(0, 2); - final short f_c12 = matrix1.get(1, 2); - final short f_c22 = matrix1.get(2, 2); - final short f_c32 = matrix1.get(3, 2); - final short f_c03 = matrix1.get(0, 3); - final short f_c13 = matrix1.get(1, 3); - final short f_c23 = matrix1.get(2, 3); - final short f_c33 = matrix1.get(3, 3); - final short f_c04 = matrix1.get(0, 4); - final short f_c14 = matrix1.get(1, 4); - final short f_c24 = matrix1.get(2, 4); - final short f_c34 = matrix1.get(3, 4); - final short s_c00 = matrix2.get(0, 0); - final short s_c10 = matrix2.get(1, 0); - final short s_c01 = matrix2.get(0, 1); - final short s_c11 = matrix2.get(1, 1); - final short s_c02 = matrix2.get(0, 2); - final short s_c12 = matrix2.get(1, 2); - final short s_c03 = matrix2.get(0, 3); - final short s_c13 = matrix2.get(1, 3); - output.set(0, 0, (short) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03)); - output.set(0, 1, (short) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03)); - output.set(0, 2, (short) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03)); - output.set(0, 3, (short) (f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03)); - output.set(0, 4, (short) (f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02 + f_c34*s_c03)); - output.set(1, 0, (short) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13)); - output.set(1, 1, (short) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13)); - output.set(1, 2, (short) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13)); - output.set(1, 3, (short) (f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13)); - output.set(1, 4, (short) (f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12 + f_c34*s_c13)); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short f30 = matrix1.get(3, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f21 = matrix1.get(2, 1); + final short f31 = matrix1.get(3, 1); + final short f02 = matrix1.get(0, 2); + final short f12 = matrix1.get(1, 2); + final short f22 = matrix1.get(2, 2); + final short f32 = matrix1.get(3, 2); + final short f03 = matrix1.get(0, 3); + final short f13 = matrix1.get(1, 3); + final short f23 = matrix1.get(2, 3); + final short f33 = matrix1.get(3, 3); + final short f04 = matrix1.get(0, 4); + final short f14 = matrix1.get(1, 4); + final short f24 = matrix1.get(2, 4); + final short f34 = matrix1.get(3, 4); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s02 = matrix2.get(0, 2); + final short s12 = matrix2.get(1, 2); + final short s03 = matrix2.get(0, 3); + final short s13 = matrix2.get(1, 3); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03)); + output.set(1, 1, (short) (f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13)); + output.set(0, 2, (short) (f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03)); + output.set(1, 2, (short) (f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13)); + output.set(0, 3, (short) (f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03)); + output.set(1, 3, (short) (f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13)); + output.set(0, 4, (short) (f04 * s00 + f14 * s01 + f24 * s02 + f34 * s03)); + output.set(1, 4, (short) (f04 * s10 + f14 * s11 + f24 * s12 + f34 * s13)); return output; } private static IMatrixSetterShort multiplyMatrix5x4x3(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final short f_c00 = matrix1.get(0, 0); - final short f_c10 = matrix1.get(1, 0); - final short f_c20 = matrix1.get(2, 0); - final short f_c30 = matrix1.get(3, 0); - final short f_c01 = matrix1.get(0, 1); - final short f_c11 = matrix1.get(1, 1); - final short f_c21 = matrix1.get(2, 1); - final short f_c31 = matrix1.get(3, 1); - final short f_c02 = matrix1.get(0, 2); - final short f_c12 = matrix1.get(1, 2); - final short f_c22 = matrix1.get(2, 2); - final short f_c32 = matrix1.get(3, 2); - final short f_c03 = matrix1.get(0, 3); - final short f_c13 = matrix1.get(1, 3); - final short f_c23 = matrix1.get(2, 3); - final short f_c33 = matrix1.get(3, 3); - final short f_c04 = matrix1.get(0, 4); - final short f_c14 = matrix1.get(1, 4); - final short f_c24 = matrix1.get(2, 4); - final short f_c34 = matrix1.get(3, 4); - final short s_c00 = matrix2.get(0, 0); - final short s_c10 = matrix2.get(1, 0); - final short s_c20 = matrix2.get(2, 0); - final short s_c01 = matrix2.get(0, 1); - final short s_c11 = matrix2.get(1, 1); - final short s_c21 = matrix2.get(2, 1); - final short s_c02 = matrix2.get(0, 2); - final short s_c12 = matrix2.get(1, 2); - final short s_c22 = matrix2.get(2, 2); - final short s_c03 = matrix2.get(0, 3); - final short s_c13 = matrix2.get(1, 3); - final short s_c23 = matrix2.get(2, 3); - output.set(0, 0, (short) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03)); - output.set(0, 1, (short) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03)); - output.set(0, 2, (short) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03)); - output.set(0, 3, (short) (f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03)); - output.set(0, 4, (short) (f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02 + f_c34*s_c03)); - output.set(1, 0, (short) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13)); - output.set(1, 1, (short) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13)); - output.set(1, 2, (short) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13)); - output.set(1, 3, (short) (f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13)); - output.set(1, 4, (short) (f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12 + f_c34*s_c13)); - output.set(2, 0, (short) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23)); - output.set(2, 1, (short) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23)); - output.set(2, 2, (short) (f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23)); - output.set(2, 3, (short) (f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23)); - output.set(2, 4, (short) (f_c04*s_c20 + f_c14*s_c21 + f_c24*s_c22 + f_c34*s_c23)); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short f30 = matrix1.get(3, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f21 = matrix1.get(2, 1); + final short f31 = matrix1.get(3, 1); + final short f02 = matrix1.get(0, 2); + final short f12 = matrix1.get(1, 2); + final short f22 = matrix1.get(2, 2); + final short f32 = matrix1.get(3, 2); + final short f03 = matrix1.get(0, 3); + final short f13 = matrix1.get(1, 3); + final short f23 = matrix1.get(2, 3); + final short f33 = matrix1.get(3, 3); + final short f04 = matrix1.get(0, 4); + final short f14 = matrix1.get(1, 4); + final short f24 = matrix1.get(2, 4); + final short f34 = matrix1.get(3, 4); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s21 = matrix2.get(2, 1); + final short s02 = matrix2.get(0, 2); + final short s12 = matrix2.get(1, 2); + final short s22 = matrix2.get(2, 2); + final short s03 = matrix2.get(0, 3); + final short s13 = matrix2.get(1, 3); + final short s23 = matrix2.get(2, 3); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13)); + output.set(2, 0, (short) (f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03)); + output.set(1, 1, (short) (f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13)); + output.set(2, 1, (short) (f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23)); + output.set(0, 2, (short) (f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03)); + output.set(1, 2, (short) (f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13)); + output.set(2, 2, (short) (f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23)); + output.set(0, 3, (short) (f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03)); + output.set(1, 3, (short) (f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13)); + output.set(2, 3, (short) (f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23)); + output.set(0, 4, (short) (f04 * s00 + f14 * s01 + f24 * s02 + f34 * s03)); + output.set(1, 4, (short) (f04 * s10 + f14 * s11 + f24 * s12 + f34 * s13)); + output.set(2, 4, (short) (f04 * s20 + f14 * s21 + f24 * s22 + f34 * s23)); return output; } private static IMatrixSetterShort multiplyMatrix5x4x4(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final short f_c00 = matrix1.get(0, 0); - final short f_c10 = matrix1.get(1, 0); - final short f_c20 = matrix1.get(2, 0); - final short f_c30 = matrix1.get(3, 0); - final short f_c01 = matrix1.get(0, 1); - final short f_c11 = matrix1.get(1, 1); - final short f_c21 = matrix1.get(2, 1); - final short f_c31 = matrix1.get(3, 1); - final short f_c02 = matrix1.get(0, 2); - final short f_c12 = matrix1.get(1, 2); - final short f_c22 = matrix1.get(2, 2); - final short f_c32 = matrix1.get(3, 2); - final short f_c03 = matrix1.get(0, 3); - final short f_c13 = matrix1.get(1, 3); - final short f_c23 = matrix1.get(2, 3); - final short f_c33 = matrix1.get(3, 3); - final short f_c04 = matrix1.get(0, 4); - final short f_c14 = matrix1.get(1, 4); - final short f_c24 = matrix1.get(2, 4); - final short f_c34 = matrix1.get(3, 4); - final short s_c00 = matrix2.get(0, 0); - final short s_c10 = matrix2.get(1, 0); - final short s_c20 = matrix2.get(2, 0); - final short s_c30 = matrix2.get(3, 0); - final short s_c01 = matrix2.get(0, 1); - final short s_c11 = matrix2.get(1, 1); - final short s_c21 = matrix2.get(2, 1); - final short s_c31 = matrix2.get(3, 1); - final short s_c02 = matrix2.get(0, 2); - final short s_c12 = matrix2.get(1, 2); - final short s_c22 = matrix2.get(2, 2); - final short s_c32 = matrix2.get(3, 2); - final short s_c03 = matrix2.get(0, 3); - final short s_c13 = matrix2.get(1, 3); - final short s_c23 = matrix2.get(2, 3); - final short s_c33 = matrix2.get(3, 3); - output.set(0, 0, (short) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03)); - output.set(0, 1, (short) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03)); - output.set(0, 2, (short) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03)); - output.set(0, 3, (short) (f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03)); - output.set(0, 4, (short) (f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02 + f_c34*s_c03)); - output.set(1, 0, (short) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13)); - output.set(1, 1, (short) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13)); - output.set(1, 2, (short) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13)); - output.set(1, 3, (short) (f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13)); - output.set(1, 4, (short) (f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12 + f_c34*s_c13)); - output.set(2, 0, (short) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23)); - output.set(2, 1, (short) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23)); - output.set(2, 2, (short) (f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23)); - output.set(2, 3, (short) (f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23)); - output.set(2, 4, (short) (f_c04*s_c20 + f_c14*s_c21 + f_c24*s_c22 + f_c34*s_c23)); - output.set(3, 0, (short) (f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33)); - output.set(3, 1, (short) (f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33)); - output.set(3, 2, (short) (f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33)); - output.set(3, 3, (short) (f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32 + f_c33*s_c33)); - output.set(3, 4, (short) (f_c04*s_c30 + f_c14*s_c31 + f_c24*s_c32 + f_c34*s_c33)); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short f30 = matrix1.get(3, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f21 = matrix1.get(2, 1); + final short f31 = matrix1.get(3, 1); + final short f02 = matrix1.get(0, 2); + final short f12 = matrix1.get(1, 2); + final short f22 = matrix1.get(2, 2); + final short f32 = matrix1.get(3, 2); + final short f03 = matrix1.get(0, 3); + final short f13 = matrix1.get(1, 3); + final short f23 = matrix1.get(2, 3); + final short f33 = matrix1.get(3, 3); + final short f04 = matrix1.get(0, 4); + final short f14 = matrix1.get(1, 4); + final short f24 = matrix1.get(2, 4); + final short f34 = matrix1.get(3, 4); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + final short s30 = matrix2.get(3, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s21 = matrix2.get(2, 1); + final short s31 = matrix2.get(3, 1); + final short s02 = matrix2.get(0, 2); + final short s12 = matrix2.get(1, 2); + final short s22 = matrix2.get(2, 2); + final short s32 = matrix2.get(3, 2); + final short s03 = matrix2.get(0, 3); + final short s13 = matrix2.get(1, 3); + final short s23 = matrix2.get(2, 3); + final short s33 = matrix2.get(3, 3); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13)); + output.set(2, 0, (short) (f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23)); + output.set(3, 0, (short) (f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03)); + output.set(1, 1, (short) (f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13)); + output.set(2, 1, (short) (f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23)); + output.set(3, 1, (short) (f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33)); + output.set(0, 2, (short) (f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03)); + output.set(1, 2, (short) (f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13)); + output.set(2, 2, (short) (f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23)); + output.set(3, 2, (short) (f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33)); + output.set(0, 3, (short) (f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03)); + output.set(1, 3, (short) (f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13)); + output.set(2, 3, (short) (f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23)); + output.set(3, 3, (short) (f03 * s30 + f13 * s31 + f23 * s32 + f33 * s33)); + output.set(0, 4, (short) (f04 * s00 + f14 * s01 + f24 * s02 + f34 * s03)); + output.set(1, 4, (short) (f04 * s10 + f14 * s11 + f24 * s12 + f34 * s13)); + output.set(2, 4, (short) (f04 * s20 + f14 * s21 + f24 * s22 + f34 * s23)); + output.set(3, 4, (short) (f04 * s30 + f14 * s31 + f24 * s32 + f34 * s33)); return output; } private static IMatrixSetterShort multiplyMatrix5x4x5(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final short f_c00 = matrix1.get(0, 0); - final short f_c10 = matrix1.get(1, 0); - final short f_c20 = matrix1.get(2, 0); - final short f_c30 = matrix1.get(3, 0); - final short f_c01 = matrix1.get(0, 1); - final short f_c11 = matrix1.get(1, 1); - final short f_c21 = matrix1.get(2, 1); - final short f_c31 = matrix1.get(3, 1); - final short f_c02 = matrix1.get(0, 2); - final short f_c12 = matrix1.get(1, 2); - final short f_c22 = matrix1.get(2, 2); - final short f_c32 = matrix1.get(3, 2); - final short f_c03 = matrix1.get(0, 3); - final short f_c13 = matrix1.get(1, 3); - final short f_c23 = matrix1.get(2, 3); - final short f_c33 = matrix1.get(3, 3); - final short f_c04 = matrix1.get(0, 4); - final short f_c14 = matrix1.get(1, 4); - final short f_c24 = matrix1.get(2, 4); - final short f_c34 = matrix1.get(3, 4); - final short s_c00 = matrix2.get(0, 0); - final short s_c10 = matrix2.get(1, 0); - final short s_c20 = matrix2.get(2, 0); - final short s_c30 = matrix2.get(3, 0); - final short s_c40 = matrix2.get(4, 0); - final short s_c01 = matrix2.get(0, 1); - final short s_c11 = matrix2.get(1, 1); - final short s_c21 = matrix2.get(2, 1); - final short s_c31 = matrix2.get(3, 1); - final short s_c41 = matrix2.get(4, 1); - final short s_c02 = matrix2.get(0, 2); - final short s_c12 = matrix2.get(1, 2); - final short s_c22 = matrix2.get(2, 2); - final short s_c32 = matrix2.get(3, 2); - final short s_c42 = matrix2.get(4, 2); - final short s_c03 = matrix2.get(0, 3); - final short s_c13 = matrix2.get(1, 3); - final short s_c23 = matrix2.get(2, 3); - final short s_c33 = matrix2.get(3, 3); - final short s_c43 = matrix2.get(4, 3); - output.set(0, 0, (short) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03)); - output.set(0, 1, (short) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03)); - output.set(0, 2, (short) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03)); - output.set(0, 3, (short) (f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03)); - output.set(0, 4, (short) (f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02 + f_c34*s_c03)); - output.set(1, 0, (short) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13)); - output.set(1, 1, (short) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13)); - output.set(1, 2, (short) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13)); - output.set(1, 3, (short) (f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13)); - output.set(1, 4, (short) (f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12 + f_c34*s_c13)); - output.set(2, 0, (short) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23)); - output.set(2, 1, (short) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23)); - output.set(2, 2, (short) (f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23)); - output.set(2, 3, (short) (f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23)); - output.set(2, 4, (short) (f_c04*s_c20 + f_c14*s_c21 + f_c24*s_c22 + f_c34*s_c23)); - output.set(3, 0, (short) (f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33)); - output.set(3, 1, (short) (f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33)); - output.set(3, 2, (short) (f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33)); - output.set(3, 3, (short) (f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32 + f_c33*s_c33)); - output.set(3, 4, (short) (f_c04*s_c30 + f_c14*s_c31 + f_c24*s_c32 + f_c34*s_c33)); - output.set(4, 0, (short) (f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42 + f_c30*s_c43)); - output.set(4, 1, (short) (f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42 + f_c31*s_c43)); - output.set(4, 2, (short) (f_c02*s_c40 + f_c12*s_c41 + f_c22*s_c42 + f_c32*s_c43)); - output.set(4, 3, (short) (f_c03*s_c40 + f_c13*s_c41 + f_c23*s_c42 + f_c33*s_c43)); - output.set(4, 4, (short) (f_c04*s_c40 + f_c14*s_c41 + f_c24*s_c42 + f_c34*s_c43)); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short f30 = matrix1.get(3, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f21 = matrix1.get(2, 1); + final short f31 = matrix1.get(3, 1); + final short f02 = matrix1.get(0, 2); + final short f12 = matrix1.get(1, 2); + final short f22 = matrix1.get(2, 2); + final short f32 = matrix1.get(3, 2); + final short f03 = matrix1.get(0, 3); + final short f13 = matrix1.get(1, 3); + final short f23 = matrix1.get(2, 3); + final short f33 = matrix1.get(3, 3); + final short f04 = matrix1.get(0, 4); + final short f14 = matrix1.get(1, 4); + final short f24 = matrix1.get(2, 4); + final short f34 = matrix1.get(3, 4); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + final short s30 = matrix2.get(3, 0); + final short s40 = matrix2.get(4, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s21 = matrix2.get(2, 1); + final short s31 = matrix2.get(3, 1); + final short s41 = matrix2.get(4, 1); + final short s02 = matrix2.get(0, 2); + final short s12 = matrix2.get(1, 2); + final short s22 = matrix2.get(2, 2); + final short s32 = matrix2.get(3, 2); + final short s42 = matrix2.get(4, 2); + final short s03 = matrix2.get(0, 3); + final short s13 = matrix2.get(1, 3); + final short s23 = matrix2.get(2, 3); + final short s33 = matrix2.get(3, 3); + final short s43 = matrix2.get(4, 3); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13)); + output.set(2, 0, (short) (f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23)); + output.set(3, 0, (short) (f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33)); + output.set(4, 0, (short) (f00 * s40 + f10 * s41 + f20 * s42 + f30 * s43)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03)); + output.set(1, 1, (short) (f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13)); + output.set(2, 1, (short) (f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23)); + output.set(3, 1, (short) (f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33)); + output.set(4, 1, (short) (f01 * s40 + f11 * s41 + f21 * s42 + f31 * s43)); + output.set(0, 2, (short) (f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03)); + output.set(1, 2, (short) (f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13)); + output.set(2, 2, (short) (f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23)); + output.set(3, 2, (short) (f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33)); + output.set(4, 2, (short) (f02 * s40 + f12 * s41 + f22 * s42 + f32 * s43)); + output.set(0, 3, (short) (f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03)); + output.set(1, 3, (short) (f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13)); + output.set(2, 3, (short) (f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23)); + output.set(3, 3, (short) (f03 * s30 + f13 * s31 + f23 * s32 + f33 * s33)); + output.set(4, 3, (short) (f03 * s40 + f13 * s41 + f23 * s42 + f33 * s43)); + output.set(0, 4, (short) (f04 * s00 + f14 * s01 + f24 * s02 + f34 * s03)); + output.set(1, 4, (short) (f04 * s10 + f14 * s11 + f24 * s12 + f34 * s13)); + output.set(2, 4, (short) (f04 * s20 + f14 * s21 + f24 * s22 + f34 * s23)); + output.set(3, 4, (short) (f04 * s30 + f14 * s31 + f24 * s32 + f34 * s33)); + output.set(4, 4, (short) (f04 * s40 + f14 * s41 + f24 * s42 + f34 * s43)); + return output; + } + + private static IMatrixSetterShort multiplyMatrix1x5x1(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short f30 = matrix1.get(3, 0); + final short f40 = matrix1.get(4, 0); + final short s00 = matrix2.get(0, 0); + final short s01 = matrix2.get(0, 1); + final short s02 = matrix2.get(0, 2); + final short s03 = matrix2.get(0, 3); + final short s04 = matrix2.get(0, 4); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04)); + return output; + } + + private static IMatrixSetterShort multiplyMatrix1x5x2(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short f30 = matrix1.get(3, 0); + final short f40 = matrix1.get(4, 0); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s02 = matrix2.get(0, 2); + final short s12 = matrix2.get(1, 2); + final short s03 = matrix2.get(0, 3); + final short s13 = matrix2.get(1, 3); + final short s04 = matrix2.get(0, 4); + final short s14 = matrix2.get(1, 4); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14)); + return output; + } + + private static IMatrixSetterShort multiplyMatrix1x5x3(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short f30 = matrix1.get(3, 0); + final short f40 = matrix1.get(4, 0); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s21 = matrix2.get(2, 1); + final short s02 = matrix2.get(0, 2); + final short s12 = matrix2.get(1, 2); + final short s22 = matrix2.get(2, 2); + final short s03 = matrix2.get(0, 3); + final short s13 = matrix2.get(1, 3); + final short s23 = matrix2.get(2, 3); + final short s04 = matrix2.get(0, 4); + final short s14 = matrix2.get(1, 4); + final short s24 = matrix2.get(2, 4); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14)); + output.set(2, 0, (short) (f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24)); + return output; + } + + private static IMatrixSetterShort multiplyMatrix1x5x4(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short f30 = matrix1.get(3, 0); + final short f40 = matrix1.get(4, 0); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + final short s30 = matrix2.get(3, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s21 = matrix2.get(2, 1); + final short s31 = matrix2.get(3, 1); + final short s02 = matrix2.get(0, 2); + final short s12 = matrix2.get(1, 2); + final short s22 = matrix2.get(2, 2); + final short s32 = matrix2.get(3, 2); + final short s03 = matrix2.get(0, 3); + final short s13 = matrix2.get(1, 3); + final short s23 = matrix2.get(2, 3); + final short s33 = matrix2.get(3, 3); + final short s04 = matrix2.get(0, 4); + final short s14 = matrix2.get(1, 4); + final short s24 = matrix2.get(2, 4); + final short s34 = matrix2.get(3, 4); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14)); + output.set(2, 0, (short) (f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24)); + output.set(3, 0, (short) (f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33 + f40 * s34)); + return output; + } + + private static IMatrixSetterShort multiplyMatrix1x5x5(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { + if (output.getRows() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 1 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 1 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short f30 = matrix1.get(3, 0); + final short f40 = matrix1.get(4, 0); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + final short s30 = matrix2.get(3, 0); + final short s40 = matrix2.get(4, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s21 = matrix2.get(2, 1); + final short s31 = matrix2.get(3, 1); + final short s41 = matrix2.get(4, 1); + final short s02 = matrix2.get(0, 2); + final short s12 = matrix2.get(1, 2); + final short s22 = matrix2.get(2, 2); + final short s32 = matrix2.get(3, 2); + final short s42 = matrix2.get(4, 2); + final short s03 = matrix2.get(0, 3); + final short s13 = matrix2.get(1, 3); + final short s23 = matrix2.get(2, 3); + final short s33 = matrix2.get(3, 3); + final short s43 = matrix2.get(4, 3); + final short s04 = matrix2.get(0, 4); + final short s14 = matrix2.get(1, 4); + final short s24 = matrix2.get(2, 4); + final short s34 = matrix2.get(3, 4); + final short s44 = matrix2.get(4, 4); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14)); + output.set(2, 0, (short) (f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24)); + output.set(3, 0, (short) (f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33 + f40 * s34)); + output.set(4, 0, (short) (f00 * s40 + f10 * s41 + f20 * s42 + f30 * s43 + f40 * s44)); + return output; + } + + private static IMatrixSetterShort multiplyMatrix2x5x1(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short f30 = matrix1.get(3, 0); + final short f40 = matrix1.get(4, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f21 = matrix1.get(2, 1); + final short f31 = matrix1.get(3, 1); + final short f41 = matrix1.get(4, 1); + final short s00 = matrix2.get(0, 0); + final short s01 = matrix2.get(0, 1); + final short s02 = matrix2.get(0, 2); + final short s03 = matrix2.get(0, 3); + final short s04 = matrix2.get(0, 4); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04)); return output; } private static IMatrixSetterShort multiplyMatrix2x5x2(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final short f_c00 = matrix1.get(0, 0); - final short f_c10 = matrix1.get(1, 0); - final short f_c20 = matrix1.get(2, 0); - final short f_c30 = matrix1.get(3, 0); - final short f_c40 = matrix1.get(4, 0); - final short f_c01 = matrix1.get(0, 1); - final short f_c11 = matrix1.get(1, 1); - final short f_c21 = matrix1.get(2, 1); - final short f_c31 = matrix1.get(3, 1); - final short f_c41 = matrix1.get(4, 1); - final short s_c00 = matrix2.get(0, 0); - final short s_c10 = matrix2.get(1, 0); - final short s_c01 = matrix2.get(0, 1); - final short s_c11 = matrix2.get(1, 1); - final short s_c02 = matrix2.get(0, 2); - final short s_c12 = matrix2.get(1, 2); - final short s_c03 = matrix2.get(0, 3); - final short s_c13 = matrix2.get(1, 3); - final short s_c04 = matrix2.get(0, 4); - final short s_c14 = matrix2.get(1, 4); - output.set(0, 0, (short) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04)); - output.set(0, 1, (short) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04)); - output.set(1, 0, (short) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14)); - output.set(1, 1, (short) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14)); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short f30 = matrix1.get(3, 0); + final short f40 = matrix1.get(4, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f21 = matrix1.get(2, 1); + final short f31 = matrix1.get(3, 1); + final short f41 = matrix1.get(4, 1); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s02 = matrix2.get(0, 2); + final short s12 = matrix2.get(1, 2); + final short s03 = matrix2.get(0, 3); + final short s13 = matrix2.get(1, 3); + final short s04 = matrix2.get(0, 4); + final short s14 = matrix2.get(1, 4); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04)); + output.set(1, 1, (short) (f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14)); return output; } private static IMatrixSetterShort multiplyMatrix2x5x3(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final short f_c00 = matrix1.get(0, 0); - final short f_c10 = matrix1.get(1, 0); - final short f_c20 = matrix1.get(2, 0); - final short f_c30 = matrix1.get(3, 0); - final short f_c40 = matrix1.get(4, 0); - final short f_c01 = matrix1.get(0, 1); - final short f_c11 = matrix1.get(1, 1); - final short f_c21 = matrix1.get(2, 1); - final short f_c31 = matrix1.get(3, 1); - final short f_c41 = matrix1.get(4, 1); - final short s_c00 = matrix2.get(0, 0); - final short s_c10 = matrix2.get(1, 0); - final short s_c20 = matrix2.get(2, 0); - final short s_c01 = matrix2.get(0, 1); - final short s_c11 = matrix2.get(1, 1); - final short s_c21 = matrix2.get(2, 1); - final short s_c02 = matrix2.get(0, 2); - final short s_c12 = matrix2.get(1, 2); - final short s_c22 = matrix2.get(2, 2); - final short s_c03 = matrix2.get(0, 3); - final short s_c13 = matrix2.get(1, 3); - final short s_c23 = matrix2.get(2, 3); - final short s_c04 = matrix2.get(0, 4); - final short s_c14 = matrix2.get(1, 4); - final short s_c24 = matrix2.get(2, 4); - output.set(0, 0, (short) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04)); - output.set(0, 1, (short) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04)); - output.set(1, 0, (short) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14)); - output.set(1, 1, (short) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14)); - output.set(2, 0, (short) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24)); - output.set(2, 1, (short) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24)); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short f30 = matrix1.get(3, 0); + final short f40 = matrix1.get(4, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f21 = matrix1.get(2, 1); + final short f31 = matrix1.get(3, 1); + final short f41 = matrix1.get(4, 1); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s21 = matrix2.get(2, 1); + final short s02 = matrix2.get(0, 2); + final short s12 = matrix2.get(1, 2); + final short s22 = matrix2.get(2, 2); + final short s03 = matrix2.get(0, 3); + final short s13 = matrix2.get(1, 3); + final short s23 = matrix2.get(2, 3); + final short s04 = matrix2.get(0, 4); + final short s14 = matrix2.get(1, 4); + final short s24 = matrix2.get(2, 4); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14)); + output.set(2, 0, (short) (f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04)); + output.set(1, 1, (short) (f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14)); + output.set(2, 1, (short) (f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24)); return output; } private static IMatrixSetterShort multiplyMatrix2x5x4(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final short f_c00 = matrix1.get(0, 0); - final short f_c10 = matrix1.get(1, 0); - final short f_c20 = matrix1.get(2, 0); - final short f_c30 = matrix1.get(3, 0); - final short f_c40 = matrix1.get(4, 0); - final short f_c01 = matrix1.get(0, 1); - final short f_c11 = matrix1.get(1, 1); - final short f_c21 = matrix1.get(2, 1); - final short f_c31 = matrix1.get(3, 1); - final short f_c41 = matrix1.get(4, 1); - final short s_c00 = matrix2.get(0, 0); - final short s_c10 = matrix2.get(1, 0); - final short s_c20 = matrix2.get(2, 0); - final short s_c30 = matrix2.get(3, 0); - final short s_c01 = matrix2.get(0, 1); - final short s_c11 = matrix2.get(1, 1); - final short s_c21 = matrix2.get(2, 1); - final short s_c31 = matrix2.get(3, 1); - final short s_c02 = matrix2.get(0, 2); - final short s_c12 = matrix2.get(1, 2); - final short s_c22 = matrix2.get(2, 2); - final short s_c32 = matrix2.get(3, 2); - final short s_c03 = matrix2.get(0, 3); - final short s_c13 = matrix2.get(1, 3); - final short s_c23 = matrix2.get(2, 3); - final short s_c33 = matrix2.get(3, 3); - final short s_c04 = matrix2.get(0, 4); - final short s_c14 = matrix2.get(1, 4); - final short s_c24 = matrix2.get(2, 4); - final short s_c34 = matrix2.get(3, 4); - output.set(0, 0, (short) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04)); - output.set(0, 1, (short) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04)); - output.set(1, 0, (short) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14)); - output.set(1, 1, (short) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14)); - output.set(2, 0, (short) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24)); - output.set(2, 1, (short) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24)); - output.set(3, 0, (short) (f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33 + f_c40*s_c34)); - output.set(3, 1, (short) (f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33 + f_c41*s_c34)); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short f30 = matrix1.get(3, 0); + final short f40 = matrix1.get(4, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f21 = matrix1.get(2, 1); + final short f31 = matrix1.get(3, 1); + final short f41 = matrix1.get(4, 1); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + final short s30 = matrix2.get(3, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s21 = matrix2.get(2, 1); + final short s31 = matrix2.get(3, 1); + final short s02 = matrix2.get(0, 2); + final short s12 = matrix2.get(1, 2); + final short s22 = matrix2.get(2, 2); + final short s32 = matrix2.get(3, 2); + final short s03 = matrix2.get(0, 3); + final short s13 = matrix2.get(1, 3); + final short s23 = matrix2.get(2, 3); + final short s33 = matrix2.get(3, 3); + final short s04 = matrix2.get(0, 4); + final short s14 = matrix2.get(1, 4); + final short s24 = matrix2.get(2, 4); + final short s34 = matrix2.get(3, 4); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14)); + output.set(2, 0, (short) (f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24)); + output.set(3, 0, (short) (f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33 + f40 * s34)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04)); + output.set(1, 1, (short) (f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14)); + output.set(2, 1, (short) (f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24)); + output.set(3, 1, (short) (f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33 + f41 * s34)); return output; } private static IMatrixSetterShort multiplyMatrix2x5x5(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { - if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 2 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final short f_c00 = matrix1.get(0, 0); - final short f_c10 = matrix1.get(1, 0); - final short f_c20 = matrix1.get(2, 0); - final short f_c30 = matrix1.get(3, 0); - final short f_c40 = matrix1.get(4, 0); - final short f_c01 = matrix1.get(0, 1); - final short f_c11 = matrix1.get(1, 1); - final short f_c21 = matrix1.get(2, 1); - final short f_c31 = matrix1.get(3, 1); - final short f_c41 = matrix1.get(4, 1); - final short s_c00 = matrix2.get(0, 0); - final short s_c10 = matrix2.get(1, 0); - final short s_c20 = matrix2.get(2, 0); - final short s_c30 = matrix2.get(3, 0); - final short s_c40 = matrix2.get(4, 0); - final short s_c01 = matrix2.get(0, 1); - final short s_c11 = matrix2.get(1, 1); - final short s_c21 = matrix2.get(2, 1); - final short s_c31 = matrix2.get(3, 1); - final short s_c41 = matrix2.get(4, 1); - final short s_c02 = matrix2.get(0, 2); - final short s_c12 = matrix2.get(1, 2); - final short s_c22 = matrix2.get(2, 2); - final short s_c32 = matrix2.get(3, 2); - final short s_c42 = matrix2.get(4, 2); - final short s_c03 = matrix2.get(0, 3); - final short s_c13 = matrix2.get(1, 3); - final short s_c23 = matrix2.get(2, 3); - final short s_c33 = matrix2.get(3, 3); - final short s_c43 = matrix2.get(4, 3); - final short s_c04 = matrix2.get(0, 4); - final short s_c14 = matrix2.get(1, 4); - final short s_c24 = matrix2.get(2, 4); - final short s_c34 = matrix2.get(3, 4); - final short s_c44 = matrix2.get(4, 4); - output.set(0, 0, (short) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04)); - output.set(0, 1, (short) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04)); - output.set(1, 0, (short) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14)); - output.set(1, 1, (short) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14)); - output.set(2, 0, (short) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24)); - output.set(2, 1, (short) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24)); - output.set(3, 0, (short) (f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33 + f_c40*s_c34)); - output.set(3, 1, (short) (f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33 + f_c41*s_c34)); - output.set(4, 0, (short) (f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42 + f_c30*s_c43 + f_c40*s_c44)); - output.set(4, 1, (short) (f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42 + f_c31*s_c43 + f_c41*s_c44)); + if (output.getRows() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 2 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 2 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short f30 = matrix1.get(3, 0); + final short f40 = matrix1.get(4, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f21 = matrix1.get(2, 1); + final short f31 = matrix1.get(3, 1); + final short f41 = matrix1.get(4, 1); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + final short s30 = matrix2.get(3, 0); + final short s40 = matrix2.get(4, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s21 = matrix2.get(2, 1); + final short s31 = matrix2.get(3, 1); + final short s41 = matrix2.get(4, 1); + final short s02 = matrix2.get(0, 2); + final short s12 = matrix2.get(1, 2); + final short s22 = matrix2.get(2, 2); + final short s32 = matrix2.get(3, 2); + final short s42 = matrix2.get(4, 2); + final short s03 = matrix2.get(0, 3); + final short s13 = matrix2.get(1, 3); + final short s23 = matrix2.get(2, 3); + final short s33 = matrix2.get(3, 3); + final short s43 = matrix2.get(4, 3); + final short s04 = matrix2.get(0, 4); + final short s14 = matrix2.get(1, 4); + final short s24 = matrix2.get(2, 4); + final short s34 = matrix2.get(3, 4); + final short s44 = matrix2.get(4, 4); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14)); + output.set(2, 0, (short) (f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24)); + output.set(3, 0, (short) (f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33 + f40 * s34)); + output.set(4, 0, (short) (f00 * s40 + f10 * s41 + f20 * s42 + f30 * s43 + f40 * s44)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04)); + output.set(1, 1, (short) (f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14)); + output.set(2, 1, (short) (f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24)); + output.set(3, 1, (short) (f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33 + f41 * s34)); + output.set(4, 1, (short) (f01 * s40 + f11 * s41 + f21 * s42 + f31 * s43 + f41 * s44)); + return output; + } + + private static IMatrixSetterShort multiplyMatrix3x5x1(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short f30 = matrix1.get(3, 0); + final short f40 = matrix1.get(4, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f21 = matrix1.get(2, 1); + final short f31 = matrix1.get(3, 1); + final short f41 = matrix1.get(4, 1); + final short f02 = matrix1.get(0, 2); + final short f12 = matrix1.get(1, 2); + final short f22 = matrix1.get(2, 2); + final short f32 = matrix1.get(3, 2); + final short f42 = matrix1.get(4, 2); + final short s00 = matrix2.get(0, 0); + final short s01 = matrix2.get(0, 1); + final short s02 = matrix2.get(0, 2); + final short s03 = matrix2.get(0, 3); + final short s04 = matrix2.get(0, 4); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04)); + output.set(0, 2, (short) (f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04)); return output; } private static IMatrixSetterShort multiplyMatrix3x5x2(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final short f_c00 = matrix1.get(0, 0); - final short f_c10 = matrix1.get(1, 0); - final short f_c20 = matrix1.get(2, 0); - final short f_c30 = matrix1.get(3, 0); - final short f_c40 = matrix1.get(4, 0); - final short f_c01 = matrix1.get(0, 1); - final short f_c11 = matrix1.get(1, 1); - final short f_c21 = matrix1.get(2, 1); - final short f_c31 = matrix1.get(3, 1); - final short f_c41 = matrix1.get(4, 1); - final short f_c02 = matrix1.get(0, 2); - final short f_c12 = matrix1.get(1, 2); - final short f_c22 = matrix1.get(2, 2); - final short f_c32 = matrix1.get(3, 2); - final short f_c42 = matrix1.get(4, 2); - final short s_c00 = matrix2.get(0, 0); - final short s_c10 = matrix2.get(1, 0); - final short s_c01 = matrix2.get(0, 1); - final short s_c11 = matrix2.get(1, 1); - final short s_c02 = matrix2.get(0, 2); - final short s_c12 = matrix2.get(1, 2); - final short s_c03 = matrix2.get(0, 3); - final short s_c13 = matrix2.get(1, 3); - final short s_c04 = matrix2.get(0, 4); - final short s_c14 = matrix2.get(1, 4); - output.set(0, 0, (short) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04)); - output.set(0, 1, (short) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04)); - output.set(0, 2, (short) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04)); - output.set(1, 0, (short) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14)); - output.set(1, 1, (short) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14)); - output.set(1, 2, (short) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14)); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short f30 = matrix1.get(3, 0); + final short f40 = matrix1.get(4, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f21 = matrix1.get(2, 1); + final short f31 = matrix1.get(3, 1); + final short f41 = matrix1.get(4, 1); + final short f02 = matrix1.get(0, 2); + final short f12 = matrix1.get(1, 2); + final short f22 = matrix1.get(2, 2); + final short f32 = matrix1.get(3, 2); + final short f42 = matrix1.get(4, 2); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s02 = matrix2.get(0, 2); + final short s12 = matrix2.get(1, 2); + final short s03 = matrix2.get(0, 3); + final short s13 = matrix2.get(1, 3); + final short s04 = matrix2.get(0, 4); + final short s14 = matrix2.get(1, 4); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04)); + output.set(1, 1, (short) (f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14)); + output.set(0, 2, (short) (f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04)); + output.set(1, 2, (short) (f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14)); return output; } private static IMatrixSetterShort multiplyMatrix3x5x3(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final short f_c00 = matrix1.get(0, 0); - final short f_c10 = matrix1.get(1, 0); - final short f_c20 = matrix1.get(2, 0); - final short f_c30 = matrix1.get(3, 0); - final short f_c40 = matrix1.get(4, 0); - final short f_c01 = matrix1.get(0, 1); - final short f_c11 = matrix1.get(1, 1); - final short f_c21 = matrix1.get(2, 1); - final short f_c31 = matrix1.get(3, 1); - final short f_c41 = matrix1.get(4, 1); - final short f_c02 = matrix1.get(0, 2); - final short f_c12 = matrix1.get(1, 2); - final short f_c22 = matrix1.get(2, 2); - final short f_c32 = matrix1.get(3, 2); - final short f_c42 = matrix1.get(4, 2); - final short s_c00 = matrix2.get(0, 0); - final short s_c10 = matrix2.get(1, 0); - final short s_c20 = matrix2.get(2, 0); - final short s_c01 = matrix2.get(0, 1); - final short s_c11 = matrix2.get(1, 1); - final short s_c21 = matrix2.get(2, 1); - final short s_c02 = matrix2.get(0, 2); - final short s_c12 = matrix2.get(1, 2); - final short s_c22 = matrix2.get(2, 2); - final short s_c03 = matrix2.get(0, 3); - final short s_c13 = matrix2.get(1, 3); - final short s_c23 = matrix2.get(2, 3); - final short s_c04 = matrix2.get(0, 4); - final short s_c14 = matrix2.get(1, 4); - final short s_c24 = matrix2.get(2, 4); - output.set(0, 0, (short) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04)); - output.set(0, 1, (short) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04)); - output.set(0, 2, (short) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04)); - output.set(1, 0, (short) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14)); - output.set(1, 1, (short) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14)); - output.set(1, 2, (short) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14)); - output.set(2, 0, (short) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24)); - output.set(2, 1, (short) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24)); - output.set(2, 2, (short) (f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23 + f_c42*s_c24)); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short f30 = matrix1.get(3, 0); + final short f40 = matrix1.get(4, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f21 = matrix1.get(2, 1); + final short f31 = matrix1.get(3, 1); + final short f41 = matrix1.get(4, 1); + final short f02 = matrix1.get(0, 2); + final short f12 = matrix1.get(1, 2); + final short f22 = matrix1.get(2, 2); + final short f32 = matrix1.get(3, 2); + final short f42 = matrix1.get(4, 2); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s21 = matrix2.get(2, 1); + final short s02 = matrix2.get(0, 2); + final short s12 = matrix2.get(1, 2); + final short s22 = matrix2.get(2, 2); + final short s03 = matrix2.get(0, 3); + final short s13 = matrix2.get(1, 3); + final short s23 = matrix2.get(2, 3); + final short s04 = matrix2.get(0, 4); + final short s14 = matrix2.get(1, 4); + final short s24 = matrix2.get(2, 4); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14)); + output.set(2, 0, (short) (f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04)); + output.set(1, 1, (short) (f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14)); + output.set(2, 1, (short) (f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24)); + output.set(0, 2, (short) (f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04)); + output.set(1, 2, (short) (f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14)); + output.set(2, 2, (short) (f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23 + f42 * s24)); return output; } private static IMatrixSetterShort multiplyMatrix3x5x4(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final short f_c00 = matrix1.get(0, 0); - final short f_c10 = matrix1.get(1, 0); - final short f_c20 = matrix1.get(2, 0); - final short f_c30 = matrix1.get(3, 0); - final short f_c40 = matrix1.get(4, 0); - final short f_c01 = matrix1.get(0, 1); - final short f_c11 = matrix1.get(1, 1); - final short f_c21 = matrix1.get(2, 1); - final short f_c31 = matrix1.get(3, 1); - final short f_c41 = matrix1.get(4, 1); - final short f_c02 = matrix1.get(0, 2); - final short f_c12 = matrix1.get(1, 2); - final short f_c22 = matrix1.get(2, 2); - final short f_c32 = matrix1.get(3, 2); - final short f_c42 = matrix1.get(4, 2); - final short s_c00 = matrix2.get(0, 0); - final short s_c10 = matrix2.get(1, 0); - final short s_c20 = matrix2.get(2, 0); - final short s_c30 = matrix2.get(3, 0); - final short s_c01 = matrix2.get(0, 1); - final short s_c11 = matrix2.get(1, 1); - final short s_c21 = matrix2.get(2, 1); - final short s_c31 = matrix2.get(3, 1); - final short s_c02 = matrix2.get(0, 2); - final short s_c12 = matrix2.get(1, 2); - final short s_c22 = matrix2.get(2, 2); - final short s_c32 = matrix2.get(3, 2); - final short s_c03 = matrix2.get(0, 3); - final short s_c13 = matrix2.get(1, 3); - final short s_c23 = matrix2.get(2, 3); - final short s_c33 = matrix2.get(3, 3); - final short s_c04 = matrix2.get(0, 4); - final short s_c14 = matrix2.get(1, 4); - final short s_c24 = matrix2.get(2, 4); - final short s_c34 = matrix2.get(3, 4); - output.set(0, 0, (short) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04)); - output.set(0, 1, (short) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04)); - output.set(0, 2, (short) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04)); - output.set(1, 0, (short) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14)); - output.set(1, 1, (short) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14)); - output.set(1, 2, (short) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14)); - output.set(2, 0, (short) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24)); - output.set(2, 1, (short) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24)); - output.set(2, 2, (short) (f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23 + f_c42*s_c24)); - output.set(3, 0, (short) (f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33 + f_c40*s_c34)); - output.set(3, 1, (short) (f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33 + f_c41*s_c34)); - output.set(3, 2, (short) (f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33 + f_c42*s_c34)); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short f30 = matrix1.get(3, 0); + final short f40 = matrix1.get(4, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f21 = matrix1.get(2, 1); + final short f31 = matrix1.get(3, 1); + final short f41 = matrix1.get(4, 1); + final short f02 = matrix1.get(0, 2); + final short f12 = matrix1.get(1, 2); + final short f22 = matrix1.get(2, 2); + final short f32 = matrix1.get(3, 2); + final short f42 = matrix1.get(4, 2); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + final short s30 = matrix2.get(3, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s21 = matrix2.get(2, 1); + final short s31 = matrix2.get(3, 1); + final short s02 = matrix2.get(0, 2); + final short s12 = matrix2.get(1, 2); + final short s22 = matrix2.get(2, 2); + final short s32 = matrix2.get(3, 2); + final short s03 = matrix2.get(0, 3); + final short s13 = matrix2.get(1, 3); + final short s23 = matrix2.get(2, 3); + final short s33 = matrix2.get(3, 3); + final short s04 = matrix2.get(0, 4); + final short s14 = matrix2.get(1, 4); + final short s24 = matrix2.get(2, 4); + final short s34 = matrix2.get(3, 4); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14)); + output.set(2, 0, (short) (f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24)); + output.set(3, 0, (short) (f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33 + f40 * s34)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04)); + output.set(1, 1, (short) (f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14)); + output.set(2, 1, (short) (f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24)); + output.set(3, 1, (short) (f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33 + f41 * s34)); + output.set(0, 2, (short) (f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04)); + output.set(1, 2, (short) (f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14)); + output.set(2, 2, (short) (f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23 + f42 * s24)); + output.set(3, 2, (short) (f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33 + f42 * s34)); return output; } private static IMatrixSetterShort multiplyMatrix3x5x5(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { - if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 3 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final short f_c00 = matrix1.get(0, 0); - final short f_c10 = matrix1.get(1, 0); - final short f_c20 = matrix1.get(2, 0); - final short f_c30 = matrix1.get(3, 0); - final short f_c40 = matrix1.get(4, 0); - final short f_c01 = matrix1.get(0, 1); - final short f_c11 = matrix1.get(1, 1); - final short f_c21 = matrix1.get(2, 1); - final short f_c31 = matrix1.get(3, 1); - final short f_c41 = matrix1.get(4, 1); - final short f_c02 = matrix1.get(0, 2); - final short f_c12 = matrix1.get(1, 2); - final short f_c22 = matrix1.get(2, 2); - final short f_c32 = matrix1.get(3, 2); - final short f_c42 = matrix1.get(4, 2); - final short s_c00 = matrix2.get(0, 0); - final short s_c10 = matrix2.get(1, 0); - final short s_c20 = matrix2.get(2, 0); - final short s_c30 = matrix2.get(3, 0); - final short s_c40 = matrix2.get(4, 0); - final short s_c01 = matrix2.get(0, 1); - final short s_c11 = matrix2.get(1, 1); - final short s_c21 = matrix2.get(2, 1); - final short s_c31 = matrix2.get(3, 1); - final short s_c41 = matrix2.get(4, 1); - final short s_c02 = matrix2.get(0, 2); - final short s_c12 = matrix2.get(1, 2); - final short s_c22 = matrix2.get(2, 2); - final short s_c32 = matrix2.get(3, 2); - final short s_c42 = matrix2.get(4, 2); - final short s_c03 = matrix2.get(0, 3); - final short s_c13 = matrix2.get(1, 3); - final short s_c23 = matrix2.get(2, 3); - final short s_c33 = matrix2.get(3, 3); - final short s_c43 = matrix2.get(4, 3); - final short s_c04 = matrix2.get(0, 4); - final short s_c14 = matrix2.get(1, 4); - final short s_c24 = matrix2.get(2, 4); - final short s_c34 = matrix2.get(3, 4); - final short s_c44 = matrix2.get(4, 4); - output.set(0, 0, (short) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04)); - output.set(0, 1, (short) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04)); - output.set(0, 2, (short) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04)); - output.set(1, 0, (short) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14)); - output.set(1, 1, (short) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14)); - output.set(1, 2, (short) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14)); - output.set(2, 0, (short) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24)); - output.set(2, 1, (short) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24)); - output.set(2, 2, (short) (f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23 + f_c42*s_c24)); - output.set(3, 0, (short) (f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33 + f_c40*s_c34)); - output.set(3, 1, (short) (f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33 + f_c41*s_c34)); - output.set(3, 2, (short) (f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33 + f_c42*s_c34)); - output.set(4, 0, (short) (f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42 + f_c30*s_c43 + f_c40*s_c44)); - output.set(4, 1, (short) (f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42 + f_c31*s_c43 + f_c41*s_c44)); - output.set(4, 2, (short) (f_c02*s_c40 + f_c12*s_c41 + f_c22*s_c42 + f_c32*s_c43 + f_c42*s_c44)); + if (output.getRows() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 3 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 3 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short f30 = matrix1.get(3, 0); + final short f40 = matrix1.get(4, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f21 = matrix1.get(2, 1); + final short f31 = matrix1.get(3, 1); + final short f41 = matrix1.get(4, 1); + final short f02 = matrix1.get(0, 2); + final short f12 = matrix1.get(1, 2); + final short f22 = matrix1.get(2, 2); + final short f32 = matrix1.get(3, 2); + final short f42 = matrix1.get(4, 2); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + final short s30 = matrix2.get(3, 0); + final short s40 = matrix2.get(4, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s21 = matrix2.get(2, 1); + final short s31 = matrix2.get(3, 1); + final short s41 = matrix2.get(4, 1); + final short s02 = matrix2.get(0, 2); + final short s12 = matrix2.get(1, 2); + final short s22 = matrix2.get(2, 2); + final short s32 = matrix2.get(3, 2); + final short s42 = matrix2.get(4, 2); + final short s03 = matrix2.get(0, 3); + final short s13 = matrix2.get(1, 3); + final short s23 = matrix2.get(2, 3); + final short s33 = matrix2.get(3, 3); + final short s43 = matrix2.get(4, 3); + final short s04 = matrix2.get(0, 4); + final short s14 = matrix2.get(1, 4); + final short s24 = matrix2.get(2, 4); + final short s34 = matrix2.get(3, 4); + final short s44 = matrix2.get(4, 4); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14)); + output.set(2, 0, (short) (f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24)); + output.set(3, 0, (short) (f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33 + f40 * s34)); + output.set(4, 0, (short) (f00 * s40 + f10 * s41 + f20 * s42 + f30 * s43 + f40 * s44)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04)); + output.set(1, 1, (short) (f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14)); + output.set(2, 1, (short) (f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24)); + output.set(3, 1, (short) (f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33 + f41 * s34)); + output.set(4, 1, (short) (f01 * s40 + f11 * s41 + f21 * s42 + f31 * s43 + f41 * s44)); + output.set(0, 2, (short) (f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04)); + output.set(1, 2, (short) (f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14)); + output.set(2, 2, (short) (f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23 + f42 * s24)); + output.set(3, 2, (short) (f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33 + f42 * s34)); + output.set(4, 2, (short) (f02 * s40 + f12 * s41 + f22 * s42 + f32 * s43 + f42 * s44)); + return output; + } + + private static IMatrixSetterShort multiplyMatrix4x5x1(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short f30 = matrix1.get(3, 0); + final short f40 = matrix1.get(4, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f21 = matrix1.get(2, 1); + final short f31 = matrix1.get(3, 1); + final short f41 = matrix1.get(4, 1); + final short f02 = matrix1.get(0, 2); + final short f12 = matrix1.get(1, 2); + final short f22 = matrix1.get(2, 2); + final short f32 = matrix1.get(3, 2); + final short f42 = matrix1.get(4, 2); + final short f03 = matrix1.get(0, 3); + final short f13 = matrix1.get(1, 3); + final short f23 = matrix1.get(2, 3); + final short f33 = matrix1.get(3, 3); + final short f43 = matrix1.get(4, 3); + final short s00 = matrix2.get(0, 0); + final short s01 = matrix2.get(0, 1); + final short s02 = matrix2.get(0, 2); + final short s03 = matrix2.get(0, 3); + final short s04 = matrix2.get(0, 4); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04)); + output.set(0, 2, (short) (f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04)); + output.set(0, 3, (short) (f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03 + f43 * s04)); return output; } private static IMatrixSetterShort multiplyMatrix4x5x2(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final short f_c00 = matrix1.get(0, 0); - final short f_c10 = matrix1.get(1, 0); - final short f_c20 = matrix1.get(2, 0); - final short f_c30 = matrix1.get(3, 0); - final short f_c40 = matrix1.get(4, 0); - final short f_c01 = matrix1.get(0, 1); - final short f_c11 = matrix1.get(1, 1); - final short f_c21 = matrix1.get(2, 1); - final short f_c31 = matrix1.get(3, 1); - final short f_c41 = matrix1.get(4, 1); - final short f_c02 = matrix1.get(0, 2); - final short f_c12 = matrix1.get(1, 2); - final short f_c22 = matrix1.get(2, 2); - final short f_c32 = matrix1.get(3, 2); - final short f_c42 = matrix1.get(4, 2); - final short f_c03 = matrix1.get(0, 3); - final short f_c13 = matrix1.get(1, 3); - final short f_c23 = matrix1.get(2, 3); - final short f_c33 = matrix1.get(3, 3); - final short f_c43 = matrix1.get(4, 3); - final short s_c00 = matrix2.get(0, 0); - final short s_c10 = matrix2.get(1, 0); - final short s_c01 = matrix2.get(0, 1); - final short s_c11 = matrix2.get(1, 1); - final short s_c02 = matrix2.get(0, 2); - final short s_c12 = matrix2.get(1, 2); - final short s_c03 = matrix2.get(0, 3); - final short s_c13 = matrix2.get(1, 3); - final short s_c04 = matrix2.get(0, 4); - final short s_c14 = matrix2.get(1, 4); - output.set(0, 0, (short) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04)); - output.set(0, 1, (short) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04)); - output.set(0, 2, (short) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04)); - output.set(0, 3, (short) (f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03 + f_c43*s_c04)); - output.set(1, 0, (short) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14)); - output.set(1, 1, (short) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14)); - output.set(1, 2, (short) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14)); - output.set(1, 3, (short) (f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13 + f_c43*s_c14)); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short f30 = matrix1.get(3, 0); + final short f40 = matrix1.get(4, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f21 = matrix1.get(2, 1); + final short f31 = matrix1.get(3, 1); + final short f41 = matrix1.get(4, 1); + final short f02 = matrix1.get(0, 2); + final short f12 = matrix1.get(1, 2); + final short f22 = matrix1.get(2, 2); + final short f32 = matrix1.get(3, 2); + final short f42 = matrix1.get(4, 2); + final short f03 = matrix1.get(0, 3); + final short f13 = matrix1.get(1, 3); + final short f23 = matrix1.get(2, 3); + final short f33 = matrix1.get(3, 3); + final short f43 = matrix1.get(4, 3); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s02 = matrix2.get(0, 2); + final short s12 = matrix2.get(1, 2); + final short s03 = matrix2.get(0, 3); + final short s13 = matrix2.get(1, 3); + final short s04 = matrix2.get(0, 4); + final short s14 = matrix2.get(1, 4); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04)); + output.set(1, 1, (short) (f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14)); + output.set(0, 2, (short) (f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04)); + output.set(1, 2, (short) (f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14)); + output.set(0, 3, (short) (f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03 + f43 * s04)); + output.set(1, 3, (short) (f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13 + f43 * s14)); return output; } private static IMatrixSetterShort multiplyMatrix4x5x3(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final short f_c00 = matrix1.get(0, 0); - final short f_c10 = matrix1.get(1, 0); - final short f_c20 = matrix1.get(2, 0); - final short f_c30 = matrix1.get(3, 0); - final short f_c40 = matrix1.get(4, 0); - final short f_c01 = matrix1.get(0, 1); - final short f_c11 = matrix1.get(1, 1); - final short f_c21 = matrix1.get(2, 1); - final short f_c31 = matrix1.get(3, 1); - final short f_c41 = matrix1.get(4, 1); - final short f_c02 = matrix1.get(0, 2); - final short f_c12 = matrix1.get(1, 2); - final short f_c22 = matrix1.get(2, 2); - final short f_c32 = matrix1.get(3, 2); - final short f_c42 = matrix1.get(4, 2); - final short f_c03 = matrix1.get(0, 3); - final short f_c13 = matrix1.get(1, 3); - final short f_c23 = matrix1.get(2, 3); - final short f_c33 = matrix1.get(3, 3); - final short f_c43 = matrix1.get(4, 3); - final short s_c00 = matrix2.get(0, 0); - final short s_c10 = matrix2.get(1, 0); - final short s_c20 = matrix2.get(2, 0); - final short s_c01 = matrix2.get(0, 1); - final short s_c11 = matrix2.get(1, 1); - final short s_c21 = matrix2.get(2, 1); - final short s_c02 = matrix2.get(0, 2); - final short s_c12 = matrix2.get(1, 2); - final short s_c22 = matrix2.get(2, 2); - final short s_c03 = matrix2.get(0, 3); - final short s_c13 = matrix2.get(1, 3); - final short s_c23 = matrix2.get(2, 3); - final short s_c04 = matrix2.get(0, 4); - final short s_c14 = matrix2.get(1, 4); - final short s_c24 = matrix2.get(2, 4); - output.set(0, 0, (short) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04)); - output.set(0, 1, (short) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04)); - output.set(0, 2, (short) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04)); - output.set(0, 3, (short) (f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03 + f_c43*s_c04)); - output.set(1, 0, (short) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14)); - output.set(1, 1, (short) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14)); - output.set(1, 2, (short) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14)); - output.set(1, 3, (short) (f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13 + f_c43*s_c14)); - output.set(2, 0, (short) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24)); - output.set(2, 1, (short) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24)); - output.set(2, 2, (short) (f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23 + f_c42*s_c24)); - output.set(2, 3, (short) (f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23 + f_c43*s_c24)); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short f30 = matrix1.get(3, 0); + final short f40 = matrix1.get(4, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f21 = matrix1.get(2, 1); + final short f31 = matrix1.get(3, 1); + final short f41 = matrix1.get(4, 1); + final short f02 = matrix1.get(0, 2); + final short f12 = matrix1.get(1, 2); + final short f22 = matrix1.get(2, 2); + final short f32 = matrix1.get(3, 2); + final short f42 = matrix1.get(4, 2); + final short f03 = matrix1.get(0, 3); + final short f13 = matrix1.get(1, 3); + final short f23 = matrix1.get(2, 3); + final short f33 = matrix1.get(3, 3); + final short f43 = matrix1.get(4, 3); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s21 = matrix2.get(2, 1); + final short s02 = matrix2.get(0, 2); + final short s12 = matrix2.get(1, 2); + final short s22 = matrix2.get(2, 2); + final short s03 = matrix2.get(0, 3); + final short s13 = matrix2.get(1, 3); + final short s23 = matrix2.get(2, 3); + final short s04 = matrix2.get(0, 4); + final short s14 = matrix2.get(1, 4); + final short s24 = matrix2.get(2, 4); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14)); + output.set(2, 0, (short) (f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04)); + output.set(1, 1, (short) (f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14)); + output.set(2, 1, (short) (f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24)); + output.set(0, 2, (short) (f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04)); + output.set(1, 2, (short) (f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14)); + output.set(2, 2, (short) (f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23 + f42 * s24)); + output.set(0, 3, (short) (f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03 + f43 * s04)); + output.set(1, 3, (short) (f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13 + f43 * s14)); + output.set(2, 3, (short) (f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23 + f43 * s24)); return output; } private static IMatrixSetterShort multiplyMatrix4x5x4(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final short f_c00 = matrix1.get(0, 0); - final short f_c10 = matrix1.get(1, 0); - final short f_c20 = matrix1.get(2, 0); - final short f_c30 = matrix1.get(3, 0); - final short f_c40 = matrix1.get(4, 0); - final short f_c01 = matrix1.get(0, 1); - final short f_c11 = matrix1.get(1, 1); - final short f_c21 = matrix1.get(2, 1); - final short f_c31 = matrix1.get(3, 1); - final short f_c41 = matrix1.get(4, 1); - final short f_c02 = matrix1.get(0, 2); - final short f_c12 = matrix1.get(1, 2); - final short f_c22 = matrix1.get(2, 2); - final short f_c32 = matrix1.get(3, 2); - final short f_c42 = matrix1.get(4, 2); - final short f_c03 = matrix1.get(0, 3); - final short f_c13 = matrix1.get(1, 3); - final short f_c23 = matrix1.get(2, 3); - final short f_c33 = matrix1.get(3, 3); - final short f_c43 = matrix1.get(4, 3); - final short s_c00 = matrix2.get(0, 0); - final short s_c10 = matrix2.get(1, 0); - final short s_c20 = matrix2.get(2, 0); - final short s_c30 = matrix2.get(3, 0); - final short s_c01 = matrix2.get(0, 1); - final short s_c11 = matrix2.get(1, 1); - final short s_c21 = matrix2.get(2, 1); - final short s_c31 = matrix2.get(3, 1); - final short s_c02 = matrix2.get(0, 2); - final short s_c12 = matrix2.get(1, 2); - final short s_c22 = matrix2.get(2, 2); - final short s_c32 = matrix2.get(3, 2); - final short s_c03 = matrix2.get(0, 3); - final short s_c13 = matrix2.get(1, 3); - final short s_c23 = matrix2.get(2, 3); - final short s_c33 = matrix2.get(3, 3); - final short s_c04 = matrix2.get(0, 4); - final short s_c14 = matrix2.get(1, 4); - final short s_c24 = matrix2.get(2, 4); - final short s_c34 = matrix2.get(3, 4); - output.set(0, 0, (short) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04)); - output.set(0, 1, (short) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04)); - output.set(0, 2, (short) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04)); - output.set(0, 3, (short) (f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03 + f_c43*s_c04)); - output.set(1, 0, (short) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14)); - output.set(1, 1, (short) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14)); - output.set(1, 2, (short) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14)); - output.set(1, 3, (short) (f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13 + f_c43*s_c14)); - output.set(2, 0, (short) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24)); - output.set(2, 1, (short) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24)); - output.set(2, 2, (short) (f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23 + f_c42*s_c24)); - output.set(2, 3, (short) (f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23 + f_c43*s_c24)); - output.set(3, 0, (short) (f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33 + f_c40*s_c34)); - output.set(3, 1, (short) (f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33 + f_c41*s_c34)); - output.set(3, 2, (short) (f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33 + f_c42*s_c34)); - output.set(3, 3, (short) (f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32 + f_c33*s_c33 + f_c43*s_c34)); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short f30 = matrix1.get(3, 0); + final short f40 = matrix1.get(4, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f21 = matrix1.get(2, 1); + final short f31 = matrix1.get(3, 1); + final short f41 = matrix1.get(4, 1); + final short f02 = matrix1.get(0, 2); + final short f12 = matrix1.get(1, 2); + final short f22 = matrix1.get(2, 2); + final short f32 = matrix1.get(3, 2); + final short f42 = matrix1.get(4, 2); + final short f03 = matrix1.get(0, 3); + final short f13 = matrix1.get(1, 3); + final short f23 = matrix1.get(2, 3); + final short f33 = matrix1.get(3, 3); + final short f43 = matrix1.get(4, 3); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + final short s30 = matrix2.get(3, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s21 = matrix2.get(2, 1); + final short s31 = matrix2.get(3, 1); + final short s02 = matrix2.get(0, 2); + final short s12 = matrix2.get(1, 2); + final short s22 = matrix2.get(2, 2); + final short s32 = matrix2.get(3, 2); + final short s03 = matrix2.get(0, 3); + final short s13 = matrix2.get(1, 3); + final short s23 = matrix2.get(2, 3); + final short s33 = matrix2.get(3, 3); + final short s04 = matrix2.get(0, 4); + final short s14 = matrix2.get(1, 4); + final short s24 = matrix2.get(2, 4); + final short s34 = matrix2.get(3, 4); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14)); + output.set(2, 0, (short) (f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24)); + output.set(3, 0, (short) (f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33 + f40 * s34)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04)); + output.set(1, 1, (short) (f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14)); + output.set(2, 1, (short) (f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24)); + output.set(3, 1, (short) (f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33 + f41 * s34)); + output.set(0, 2, (short) (f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04)); + output.set(1, 2, (short) (f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14)); + output.set(2, 2, (short) (f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23 + f42 * s24)); + output.set(3, 2, (short) (f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33 + f42 * s34)); + output.set(0, 3, (short) (f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03 + f43 * s04)); + output.set(1, 3, (short) (f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13 + f43 * s14)); + output.set(2, 3, (short) (f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23 + f43 * s24)); + output.set(3, 3, (short) (f03 * s30 + f13 * s31 + f23 * s32 + f33 * s33 + f43 * s34)); return output; } private static IMatrixSetterShort multiplyMatrix4x5x5(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { - if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 4 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final short f_c00 = matrix1.get(0, 0); - final short f_c10 = matrix1.get(1, 0); - final short f_c20 = matrix1.get(2, 0); - final short f_c30 = matrix1.get(3, 0); - final short f_c40 = matrix1.get(4, 0); - final short f_c01 = matrix1.get(0, 1); - final short f_c11 = matrix1.get(1, 1); - final short f_c21 = matrix1.get(2, 1); - final short f_c31 = matrix1.get(3, 1); - final short f_c41 = matrix1.get(4, 1); - final short f_c02 = matrix1.get(0, 2); - final short f_c12 = matrix1.get(1, 2); - final short f_c22 = matrix1.get(2, 2); - final short f_c32 = matrix1.get(3, 2); - final short f_c42 = matrix1.get(4, 2); - final short f_c03 = matrix1.get(0, 3); - final short f_c13 = matrix1.get(1, 3); - final short f_c23 = matrix1.get(2, 3); - final short f_c33 = matrix1.get(3, 3); - final short f_c43 = matrix1.get(4, 3); - final short s_c00 = matrix2.get(0, 0); - final short s_c10 = matrix2.get(1, 0); - final short s_c20 = matrix2.get(2, 0); - final short s_c30 = matrix2.get(3, 0); - final short s_c40 = matrix2.get(4, 0); - final short s_c01 = matrix2.get(0, 1); - final short s_c11 = matrix2.get(1, 1); - final short s_c21 = matrix2.get(2, 1); - final short s_c31 = matrix2.get(3, 1); - final short s_c41 = matrix2.get(4, 1); - final short s_c02 = matrix2.get(0, 2); - final short s_c12 = matrix2.get(1, 2); - final short s_c22 = matrix2.get(2, 2); - final short s_c32 = matrix2.get(3, 2); - final short s_c42 = matrix2.get(4, 2); - final short s_c03 = matrix2.get(0, 3); - final short s_c13 = matrix2.get(1, 3); - final short s_c23 = matrix2.get(2, 3); - final short s_c33 = matrix2.get(3, 3); - final short s_c43 = matrix2.get(4, 3); - final short s_c04 = matrix2.get(0, 4); - final short s_c14 = matrix2.get(1, 4); - final short s_c24 = matrix2.get(2, 4); - final short s_c34 = matrix2.get(3, 4); - final short s_c44 = matrix2.get(4, 4); - output.set(0, 0, (short) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04)); - output.set(0, 1, (short) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04)); - output.set(0, 2, (short) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04)); - output.set(0, 3, (short) (f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03 + f_c43*s_c04)); - output.set(1, 0, (short) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14)); - output.set(1, 1, (short) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14)); - output.set(1, 2, (short) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14)); - output.set(1, 3, (short) (f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13 + f_c43*s_c14)); - output.set(2, 0, (short) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24)); - output.set(2, 1, (short) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24)); - output.set(2, 2, (short) (f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23 + f_c42*s_c24)); - output.set(2, 3, (short) (f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23 + f_c43*s_c24)); - output.set(3, 0, (short) (f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33 + f_c40*s_c34)); - output.set(3, 1, (short) (f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33 + f_c41*s_c34)); - output.set(3, 2, (short) (f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33 + f_c42*s_c34)); - output.set(3, 3, (short) (f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32 + f_c33*s_c33 + f_c43*s_c34)); - output.set(4, 0, (short) (f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42 + f_c30*s_c43 + f_c40*s_c44)); - output.set(4, 1, (short) (f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42 + f_c31*s_c43 + f_c41*s_c44)); - output.set(4, 2, (short) (f_c02*s_c40 + f_c12*s_c41 + f_c22*s_c42 + f_c32*s_c43 + f_c42*s_c44)); - output.set(4, 3, (short) (f_c03*s_c40 + f_c13*s_c41 + f_c23*s_c42 + f_c33*s_c43 + f_c43*s_c44)); + if (output.getRows() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 4 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 4 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short f30 = matrix1.get(3, 0); + final short f40 = matrix1.get(4, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f21 = matrix1.get(2, 1); + final short f31 = matrix1.get(3, 1); + final short f41 = matrix1.get(4, 1); + final short f02 = matrix1.get(0, 2); + final short f12 = matrix1.get(1, 2); + final short f22 = matrix1.get(2, 2); + final short f32 = matrix1.get(3, 2); + final short f42 = matrix1.get(4, 2); + final short f03 = matrix1.get(0, 3); + final short f13 = matrix1.get(1, 3); + final short f23 = matrix1.get(2, 3); + final short f33 = matrix1.get(3, 3); + final short f43 = matrix1.get(4, 3); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + final short s30 = matrix2.get(3, 0); + final short s40 = matrix2.get(4, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s21 = matrix2.get(2, 1); + final short s31 = matrix2.get(3, 1); + final short s41 = matrix2.get(4, 1); + final short s02 = matrix2.get(0, 2); + final short s12 = matrix2.get(1, 2); + final short s22 = matrix2.get(2, 2); + final short s32 = matrix2.get(3, 2); + final short s42 = matrix2.get(4, 2); + final short s03 = matrix2.get(0, 3); + final short s13 = matrix2.get(1, 3); + final short s23 = matrix2.get(2, 3); + final short s33 = matrix2.get(3, 3); + final short s43 = matrix2.get(4, 3); + final short s04 = matrix2.get(0, 4); + final short s14 = matrix2.get(1, 4); + final short s24 = matrix2.get(2, 4); + final short s34 = matrix2.get(3, 4); + final short s44 = matrix2.get(4, 4); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14)); + output.set(2, 0, (short) (f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24)); + output.set(3, 0, (short) (f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33 + f40 * s34)); + output.set(4, 0, (short) (f00 * s40 + f10 * s41 + f20 * s42 + f30 * s43 + f40 * s44)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04)); + output.set(1, 1, (short) (f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14)); + output.set(2, 1, (short) (f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24)); + output.set(3, 1, (short) (f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33 + f41 * s34)); + output.set(4, 1, (short) (f01 * s40 + f11 * s41 + f21 * s42 + f31 * s43 + f41 * s44)); + output.set(0, 2, (short) (f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04)); + output.set(1, 2, (short) (f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14)); + output.set(2, 2, (short) (f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23 + f42 * s24)); + output.set(3, 2, (short) (f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33 + f42 * s34)); + output.set(4, 2, (short) (f02 * s40 + f12 * s41 + f22 * s42 + f32 * s43 + f42 * s44)); + output.set(0, 3, (short) (f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03 + f43 * s04)); + output.set(1, 3, (short) (f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13 + f43 * s14)); + output.set(2, 3, (short) (f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23 + f43 * s24)); + output.set(3, 3, (short) (f03 * s30 + f13 * s31 + f23 * s32 + f33 * s33 + f43 * s34)); + output.set(4, 3, (short) (f03 * s40 + f13 * s41 + f23 * s42 + f33 * s43 + f43 * s44)); + return output; + } + + private static IMatrixSetterShort multiplyMatrix5x5x1(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 1) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short f30 = matrix1.get(3, 0); + final short f40 = matrix1.get(4, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f21 = matrix1.get(2, 1); + final short f31 = matrix1.get(3, 1); + final short f41 = matrix1.get(4, 1); + final short f02 = matrix1.get(0, 2); + final short f12 = matrix1.get(1, 2); + final short f22 = matrix1.get(2, 2); + final short f32 = matrix1.get(3, 2); + final short f42 = matrix1.get(4, 2); + final short f03 = matrix1.get(0, 3); + final short f13 = matrix1.get(1, 3); + final short f23 = matrix1.get(2, 3); + final short f33 = matrix1.get(3, 3); + final short f43 = matrix1.get(4, 3); + final short f04 = matrix1.get(0, 4); + final short f14 = matrix1.get(1, 4); + final short f24 = matrix1.get(2, 4); + final short f34 = matrix1.get(3, 4); + final short f44 = matrix1.get(4, 4); + final short s00 = matrix2.get(0, 0); + final short s01 = matrix2.get(0, 1); + final short s02 = matrix2.get(0, 2); + final short s03 = matrix2.get(0, 3); + final short s04 = matrix2.get(0, 4); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04)); + output.set(0, 2, (short) (f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04)); + output.set(0, 3, (short) (f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03 + f43 * s04)); + output.set(0, 4, (short) (f04 * s00 + f14 * s01 + f24 * s02 + f34 * s03 + f44 * s04)); return output; } private static IMatrixSetterShort multiplyMatrix5x5x2(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 2 required"); - final short f_c00 = matrix1.get(0, 0); - final short f_c10 = matrix1.get(1, 0); - final short f_c20 = matrix1.get(2, 0); - final short f_c30 = matrix1.get(3, 0); - final short f_c40 = matrix1.get(4, 0); - final short f_c01 = matrix1.get(0, 1); - final short f_c11 = matrix1.get(1, 1); - final short f_c21 = matrix1.get(2, 1); - final short f_c31 = matrix1.get(3, 1); - final short f_c41 = matrix1.get(4, 1); - final short f_c02 = matrix1.get(0, 2); - final short f_c12 = matrix1.get(1, 2); - final short f_c22 = matrix1.get(2, 2); - final short f_c32 = matrix1.get(3, 2); - final short f_c42 = matrix1.get(4, 2); - final short f_c03 = matrix1.get(0, 3); - final short f_c13 = matrix1.get(1, 3); - final short f_c23 = matrix1.get(2, 3); - final short f_c33 = matrix1.get(3, 3); - final short f_c43 = matrix1.get(4, 3); - final short f_c04 = matrix1.get(0, 4); - final short f_c14 = matrix1.get(1, 4); - final short f_c24 = matrix1.get(2, 4); - final short f_c34 = matrix1.get(3, 4); - final short f_c44 = matrix1.get(4, 4); - final short s_c00 = matrix2.get(0, 0); - final short s_c10 = matrix2.get(1, 0); - final short s_c01 = matrix2.get(0, 1); - final short s_c11 = matrix2.get(1, 1); - final short s_c02 = matrix2.get(0, 2); - final short s_c12 = matrix2.get(1, 2); - final short s_c03 = matrix2.get(0, 3); - final short s_c13 = matrix2.get(1, 3); - final short s_c04 = matrix2.get(0, 4); - final short s_c14 = matrix2.get(1, 4); - output.set(0, 0, (short) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04)); - output.set(0, 1, (short) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04)); - output.set(0, 2, (short) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04)); - output.set(0, 3, (short) (f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03 + f_c43*s_c04)); - output.set(0, 4, (short) (f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02 + f_c34*s_c03 + f_c44*s_c04)); - output.set(1, 0, (short) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14)); - output.set(1, 1, (short) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14)); - output.set(1, 2, (short) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14)); - output.set(1, 3, (short) (f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13 + f_c43*s_c14)); - output.set(1, 4, (short) (f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12 + f_c34*s_c13 + f_c44*s_c14)); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 2) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short f30 = matrix1.get(3, 0); + final short f40 = matrix1.get(4, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f21 = matrix1.get(2, 1); + final short f31 = matrix1.get(3, 1); + final short f41 = matrix1.get(4, 1); + final short f02 = matrix1.get(0, 2); + final short f12 = matrix1.get(1, 2); + final short f22 = matrix1.get(2, 2); + final short f32 = matrix1.get(3, 2); + final short f42 = matrix1.get(4, 2); + final short f03 = matrix1.get(0, 3); + final short f13 = matrix1.get(1, 3); + final short f23 = matrix1.get(2, 3); + final short f33 = matrix1.get(3, 3); + final short f43 = matrix1.get(4, 3); + final short f04 = matrix1.get(0, 4); + final short f14 = matrix1.get(1, 4); + final short f24 = matrix1.get(2, 4); + final short f34 = matrix1.get(3, 4); + final short f44 = matrix1.get(4, 4); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s02 = matrix2.get(0, 2); + final short s12 = matrix2.get(1, 2); + final short s03 = matrix2.get(0, 3); + final short s13 = matrix2.get(1, 3); + final short s04 = matrix2.get(0, 4); + final short s14 = matrix2.get(1, 4); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04)); + output.set(1, 1, (short) (f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14)); + output.set(0, 2, (short) (f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04)); + output.set(1, 2, (short) (f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14)); + output.set(0, 3, (short) (f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03 + f43 * s04)); + output.set(1, 3, (short) (f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13 + f43 * s14)); + output.set(0, 4, (short) (f04 * s00 + f14 * s01 + f24 * s02 + f34 * s03 + f44 * s04)); + output.set(1, 4, (short) (f04 * s10 + f14 * s11 + f24 * s12 + f34 * s13 + f44 * s14)); return output; } private static IMatrixSetterShort multiplyMatrix5x5x3(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 3 required"); - final short f_c00 = matrix1.get(0, 0); - final short f_c10 = matrix1.get(1, 0); - final short f_c20 = matrix1.get(2, 0); - final short f_c30 = matrix1.get(3, 0); - final short f_c40 = matrix1.get(4, 0); - final short f_c01 = matrix1.get(0, 1); - final short f_c11 = matrix1.get(1, 1); - final short f_c21 = matrix1.get(2, 1); - final short f_c31 = matrix1.get(3, 1); - final short f_c41 = matrix1.get(4, 1); - final short f_c02 = matrix1.get(0, 2); - final short f_c12 = matrix1.get(1, 2); - final short f_c22 = matrix1.get(2, 2); - final short f_c32 = matrix1.get(3, 2); - final short f_c42 = matrix1.get(4, 2); - final short f_c03 = matrix1.get(0, 3); - final short f_c13 = matrix1.get(1, 3); - final short f_c23 = matrix1.get(2, 3); - final short f_c33 = matrix1.get(3, 3); - final short f_c43 = matrix1.get(4, 3); - final short f_c04 = matrix1.get(0, 4); - final short f_c14 = matrix1.get(1, 4); - final short f_c24 = matrix1.get(2, 4); - final short f_c34 = matrix1.get(3, 4); - final short f_c44 = matrix1.get(4, 4); - final short s_c00 = matrix2.get(0, 0); - final short s_c10 = matrix2.get(1, 0); - final short s_c20 = matrix2.get(2, 0); - final short s_c01 = matrix2.get(0, 1); - final short s_c11 = matrix2.get(1, 1); - final short s_c21 = matrix2.get(2, 1); - final short s_c02 = matrix2.get(0, 2); - final short s_c12 = matrix2.get(1, 2); - final short s_c22 = matrix2.get(2, 2); - final short s_c03 = matrix2.get(0, 3); - final short s_c13 = matrix2.get(1, 3); - final short s_c23 = matrix2.get(2, 3); - final short s_c04 = matrix2.get(0, 4); - final short s_c14 = matrix2.get(1, 4); - final short s_c24 = matrix2.get(2, 4); - output.set(0, 0, (short) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04)); - output.set(0, 1, (short) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04)); - output.set(0, 2, (short) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04)); - output.set(0, 3, (short) (f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03 + f_c43*s_c04)); - output.set(0, 4, (short) (f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02 + f_c34*s_c03 + f_c44*s_c04)); - output.set(1, 0, (short) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14)); - output.set(1, 1, (short) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14)); - output.set(1, 2, (short) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14)); - output.set(1, 3, (short) (f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13 + f_c43*s_c14)); - output.set(1, 4, (short) (f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12 + f_c34*s_c13 + f_c44*s_c14)); - output.set(2, 0, (short) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24)); - output.set(2, 1, (short) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24)); - output.set(2, 2, (short) (f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23 + f_c42*s_c24)); - output.set(2, 3, (short) (f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23 + f_c43*s_c24)); - output.set(2, 4, (short) (f_c04*s_c20 + f_c14*s_c21 + f_c24*s_c22 + f_c34*s_c23 + f_c44*s_c24)); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 3) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short f30 = matrix1.get(3, 0); + final short f40 = matrix1.get(4, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f21 = matrix1.get(2, 1); + final short f31 = matrix1.get(3, 1); + final short f41 = matrix1.get(4, 1); + final short f02 = matrix1.get(0, 2); + final short f12 = matrix1.get(1, 2); + final short f22 = matrix1.get(2, 2); + final short f32 = matrix1.get(3, 2); + final short f42 = matrix1.get(4, 2); + final short f03 = matrix1.get(0, 3); + final short f13 = matrix1.get(1, 3); + final short f23 = matrix1.get(2, 3); + final short f33 = matrix1.get(3, 3); + final short f43 = matrix1.get(4, 3); + final short f04 = matrix1.get(0, 4); + final short f14 = matrix1.get(1, 4); + final short f24 = matrix1.get(2, 4); + final short f34 = matrix1.get(3, 4); + final short f44 = matrix1.get(4, 4); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s21 = matrix2.get(2, 1); + final short s02 = matrix2.get(0, 2); + final short s12 = matrix2.get(1, 2); + final short s22 = matrix2.get(2, 2); + final short s03 = matrix2.get(0, 3); + final short s13 = matrix2.get(1, 3); + final short s23 = matrix2.get(2, 3); + final short s04 = matrix2.get(0, 4); + final short s14 = matrix2.get(1, 4); + final short s24 = matrix2.get(2, 4); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14)); + output.set(2, 0, (short) (f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04)); + output.set(1, 1, (short) (f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14)); + output.set(2, 1, (short) (f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24)); + output.set(0, 2, (short) (f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04)); + output.set(1, 2, (short) (f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14)); + output.set(2, 2, (short) (f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23 + f42 * s24)); + output.set(0, 3, (short) (f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03 + f43 * s04)); + output.set(1, 3, (short) (f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13 + f43 * s14)); + output.set(2, 3, (short) (f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23 + f43 * s24)); + output.set(0, 4, (short) (f04 * s00 + f14 * s01 + f24 * s02 + f34 * s03 + f44 * s04)); + output.set(1, 4, (short) (f04 * s10 + f14 * s11 + f24 * s12 + f34 * s13 + f44 * s14)); + output.set(2, 4, (short) (f04 * s20 + f14 * s21 + f24 * s22 + f34 * s23 + f44 * s24)); return output; } private static IMatrixSetterShort multiplyMatrix5x5x4(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 4 required"); - final short f_c00 = matrix1.get(0, 0); - final short f_c10 = matrix1.get(1, 0); - final short f_c20 = matrix1.get(2, 0); - final short f_c30 = matrix1.get(3, 0); - final short f_c40 = matrix1.get(4, 0); - final short f_c01 = matrix1.get(0, 1); - final short f_c11 = matrix1.get(1, 1); - final short f_c21 = matrix1.get(2, 1); - final short f_c31 = matrix1.get(3, 1); - final short f_c41 = matrix1.get(4, 1); - final short f_c02 = matrix1.get(0, 2); - final short f_c12 = matrix1.get(1, 2); - final short f_c22 = matrix1.get(2, 2); - final short f_c32 = matrix1.get(3, 2); - final short f_c42 = matrix1.get(4, 2); - final short f_c03 = matrix1.get(0, 3); - final short f_c13 = matrix1.get(1, 3); - final short f_c23 = matrix1.get(2, 3); - final short f_c33 = matrix1.get(3, 3); - final short f_c43 = matrix1.get(4, 3); - final short f_c04 = matrix1.get(0, 4); - final short f_c14 = matrix1.get(1, 4); - final short f_c24 = matrix1.get(2, 4); - final short f_c34 = matrix1.get(3, 4); - final short f_c44 = matrix1.get(4, 4); - final short s_c00 = matrix2.get(0, 0); - final short s_c10 = matrix2.get(1, 0); - final short s_c20 = matrix2.get(2, 0); - final short s_c30 = matrix2.get(3, 0); - final short s_c01 = matrix2.get(0, 1); - final short s_c11 = matrix2.get(1, 1); - final short s_c21 = matrix2.get(2, 1); - final short s_c31 = matrix2.get(3, 1); - final short s_c02 = matrix2.get(0, 2); - final short s_c12 = matrix2.get(1, 2); - final short s_c22 = matrix2.get(2, 2); - final short s_c32 = matrix2.get(3, 2); - final short s_c03 = matrix2.get(0, 3); - final short s_c13 = matrix2.get(1, 3); - final short s_c23 = matrix2.get(2, 3); - final short s_c33 = matrix2.get(3, 3); - final short s_c04 = matrix2.get(0, 4); - final short s_c14 = matrix2.get(1, 4); - final short s_c24 = matrix2.get(2, 4); - final short s_c34 = matrix2.get(3, 4); - output.set(0, 0, (short) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04)); - output.set(0, 1, (short) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04)); - output.set(0, 2, (short) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04)); - output.set(0, 3, (short) (f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03 + f_c43*s_c04)); - output.set(0, 4, (short) (f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02 + f_c34*s_c03 + f_c44*s_c04)); - output.set(1, 0, (short) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14)); - output.set(1, 1, (short) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14)); - output.set(1, 2, (short) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14)); - output.set(1, 3, (short) (f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13 + f_c43*s_c14)); - output.set(1, 4, (short) (f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12 + f_c34*s_c13 + f_c44*s_c14)); - output.set(2, 0, (short) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24)); - output.set(2, 1, (short) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24)); - output.set(2, 2, (short) (f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23 + f_c42*s_c24)); - output.set(2, 3, (short) (f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23 + f_c43*s_c24)); - output.set(2, 4, (short) (f_c04*s_c20 + f_c14*s_c21 + f_c24*s_c22 + f_c34*s_c23 + f_c44*s_c24)); - output.set(3, 0, (short) (f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33 + f_c40*s_c34)); - output.set(3, 1, (short) (f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33 + f_c41*s_c34)); - output.set(3, 2, (short) (f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33 + f_c42*s_c34)); - output.set(3, 3, (short) (f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32 + f_c33*s_c33 + f_c43*s_c34)); - output.set(3, 4, (short) (f_c04*s_c30 + f_c14*s_c31 + f_c24*s_c32 + f_c34*s_c33 + f_c44*s_c34)); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 4) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short f30 = matrix1.get(3, 0); + final short f40 = matrix1.get(4, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f21 = matrix1.get(2, 1); + final short f31 = matrix1.get(3, 1); + final short f41 = matrix1.get(4, 1); + final short f02 = matrix1.get(0, 2); + final short f12 = matrix1.get(1, 2); + final short f22 = matrix1.get(2, 2); + final short f32 = matrix1.get(3, 2); + final short f42 = matrix1.get(4, 2); + final short f03 = matrix1.get(0, 3); + final short f13 = matrix1.get(1, 3); + final short f23 = matrix1.get(2, 3); + final short f33 = matrix1.get(3, 3); + final short f43 = matrix1.get(4, 3); + final short f04 = matrix1.get(0, 4); + final short f14 = matrix1.get(1, 4); + final short f24 = matrix1.get(2, 4); + final short f34 = matrix1.get(3, 4); + final short f44 = matrix1.get(4, 4); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + final short s30 = matrix2.get(3, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s21 = matrix2.get(2, 1); + final short s31 = matrix2.get(3, 1); + final short s02 = matrix2.get(0, 2); + final short s12 = matrix2.get(1, 2); + final short s22 = matrix2.get(2, 2); + final short s32 = matrix2.get(3, 2); + final short s03 = matrix2.get(0, 3); + final short s13 = matrix2.get(1, 3); + final short s23 = matrix2.get(2, 3); + final short s33 = matrix2.get(3, 3); + final short s04 = matrix2.get(0, 4); + final short s14 = matrix2.get(1, 4); + final short s24 = matrix2.get(2, 4); + final short s34 = matrix2.get(3, 4); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14)); + output.set(2, 0, (short) (f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24)); + output.set(3, 0, (short) (f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33 + f40 * s34)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04)); + output.set(1, 1, (short) (f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14)); + output.set(2, 1, (short) (f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24)); + output.set(3, 1, (short) (f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33 + f41 * s34)); + output.set(0, 2, (short) (f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04)); + output.set(1, 2, (short) (f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14)); + output.set(2, 2, (short) (f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23 + f42 * s24)); + output.set(3, 2, (short) (f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33 + f42 * s34)); + output.set(0, 3, (short) (f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03 + f43 * s04)); + output.set(1, 3, (short) (f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13 + f43 * s14)); + output.set(2, 3, (short) (f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23 + f43 * s24)); + output.set(3, 3, (short) (f03 * s30 + f13 * s31 + f23 * s32 + f33 * s33 + f43 * s34)); + output.set(0, 4, (short) (f04 * s00 + f14 * s01 + f24 * s02 + f34 * s03 + f44 * s04)); + output.set(1, 4, (short) (f04 * s10 + f14 * s11 + f24 * s12 + f34 * s13 + f44 * s14)); + output.set(2, 4, (short) (f04 * s20 + f14 * s21 + f24 * s22 + f34 * s23 + f44 * s24)); + output.set(3, 4, (short) (f04 * s30 + f14 * s31 + f24 * s32 + f34 * s33 + f44 * s34)); return output; } private static IMatrixSetterShort multiplyMatrix5x5x5(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { - if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, but 5 required"); - if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, but 5 required"); - final short f_c00 = matrix1.get(0, 0); - final short f_c10 = matrix1.get(1, 0); - final short f_c20 = matrix1.get(2, 0); - final short f_c30 = matrix1.get(3, 0); - final short f_c40 = matrix1.get(4, 0); - final short f_c01 = matrix1.get(0, 1); - final short f_c11 = matrix1.get(1, 1); - final short f_c21 = matrix1.get(2, 1); - final short f_c31 = matrix1.get(3, 1); - final short f_c41 = matrix1.get(4, 1); - final short f_c02 = matrix1.get(0, 2); - final short f_c12 = matrix1.get(1, 2); - final short f_c22 = matrix1.get(2, 2); - final short f_c32 = matrix1.get(3, 2); - final short f_c42 = matrix1.get(4, 2); - final short f_c03 = matrix1.get(0, 3); - final short f_c13 = matrix1.get(1, 3); - final short f_c23 = matrix1.get(2, 3); - final short f_c33 = matrix1.get(3, 3); - final short f_c43 = matrix1.get(4, 3); - final short f_c04 = matrix1.get(0, 4); - final short f_c14 = matrix1.get(1, 4); - final short f_c24 = matrix1.get(2, 4); - final short f_c34 = matrix1.get(3, 4); - final short f_c44 = matrix1.get(4, 4); - final short s_c00 = matrix2.get(0, 0); - final short s_c10 = matrix2.get(1, 0); - final short s_c20 = matrix2.get(2, 0); - final short s_c30 = matrix2.get(3, 0); - final short s_c40 = matrix2.get(4, 0); - final short s_c01 = matrix2.get(0, 1); - final short s_c11 = matrix2.get(1, 1); - final short s_c21 = matrix2.get(2, 1); - final short s_c31 = matrix2.get(3, 1); - final short s_c41 = matrix2.get(4, 1); - final short s_c02 = matrix2.get(0, 2); - final short s_c12 = matrix2.get(1, 2); - final short s_c22 = matrix2.get(2, 2); - final short s_c32 = matrix2.get(3, 2); - final short s_c42 = matrix2.get(4, 2); - final short s_c03 = matrix2.get(0, 3); - final short s_c13 = matrix2.get(1, 3); - final short s_c23 = matrix2.get(2, 3); - final short s_c33 = matrix2.get(3, 3); - final short s_c43 = matrix2.get(4, 3); - final short s_c04 = matrix2.get(0, 4); - final short s_c14 = matrix2.get(1, 4); - final short s_c24 = matrix2.get(2, 4); - final short s_c34 = matrix2.get(3, 4); - final short s_c44 = matrix2.get(4, 4); - output.set(0, 0, (short) (f_c00*s_c00 + f_c10*s_c01 + f_c20*s_c02 + f_c30*s_c03 + f_c40*s_c04)); - output.set(0, 1, (short) (f_c01*s_c00 + f_c11*s_c01 + f_c21*s_c02 + f_c31*s_c03 + f_c41*s_c04)); - output.set(0, 2, (short) (f_c02*s_c00 + f_c12*s_c01 + f_c22*s_c02 + f_c32*s_c03 + f_c42*s_c04)); - output.set(0, 3, (short) (f_c03*s_c00 + f_c13*s_c01 + f_c23*s_c02 + f_c33*s_c03 + f_c43*s_c04)); - output.set(0, 4, (short) (f_c04*s_c00 + f_c14*s_c01 + f_c24*s_c02 + f_c34*s_c03 + f_c44*s_c04)); - output.set(1, 0, (short) (f_c00*s_c10 + f_c10*s_c11 + f_c20*s_c12 + f_c30*s_c13 + f_c40*s_c14)); - output.set(1, 1, (short) (f_c01*s_c10 + f_c11*s_c11 + f_c21*s_c12 + f_c31*s_c13 + f_c41*s_c14)); - output.set(1, 2, (short) (f_c02*s_c10 + f_c12*s_c11 + f_c22*s_c12 + f_c32*s_c13 + f_c42*s_c14)); - output.set(1, 3, (short) (f_c03*s_c10 + f_c13*s_c11 + f_c23*s_c12 + f_c33*s_c13 + f_c43*s_c14)); - output.set(1, 4, (short) (f_c04*s_c10 + f_c14*s_c11 + f_c24*s_c12 + f_c34*s_c13 + f_c44*s_c14)); - output.set(2, 0, (short) (f_c00*s_c20 + f_c10*s_c21 + f_c20*s_c22 + f_c30*s_c23 + f_c40*s_c24)); - output.set(2, 1, (short) (f_c01*s_c20 + f_c11*s_c21 + f_c21*s_c22 + f_c31*s_c23 + f_c41*s_c24)); - output.set(2, 2, (short) (f_c02*s_c20 + f_c12*s_c21 + f_c22*s_c22 + f_c32*s_c23 + f_c42*s_c24)); - output.set(2, 3, (short) (f_c03*s_c20 + f_c13*s_c21 + f_c23*s_c22 + f_c33*s_c23 + f_c43*s_c24)); - output.set(2, 4, (short) (f_c04*s_c20 + f_c14*s_c21 + f_c24*s_c22 + f_c34*s_c23 + f_c44*s_c24)); - output.set(3, 0, (short) (f_c00*s_c30 + f_c10*s_c31 + f_c20*s_c32 + f_c30*s_c33 + f_c40*s_c34)); - output.set(3, 1, (short) (f_c01*s_c30 + f_c11*s_c31 + f_c21*s_c32 + f_c31*s_c33 + f_c41*s_c34)); - output.set(3, 2, (short) (f_c02*s_c30 + f_c12*s_c31 + f_c22*s_c32 + f_c32*s_c33 + f_c42*s_c34)); - output.set(3, 3, (short) (f_c03*s_c30 + f_c13*s_c31 + f_c23*s_c32 + f_c33*s_c33 + f_c43*s_c34)); - output.set(3, 4, (short) (f_c04*s_c30 + f_c14*s_c31 + f_c24*s_c32 + f_c34*s_c33 + f_c44*s_c34)); - output.set(4, 0, (short) (f_c00*s_c40 + f_c10*s_c41 + f_c20*s_c42 + f_c30*s_c43 + f_c40*s_c44)); - output.set(4, 1, (short) (f_c01*s_c40 + f_c11*s_c41 + f_c21*s_c42 + f_c31*s_c43 + f_c41*s_c44)); - output.set(4, 2, (short) (f_c02*s_c40 + f_c12*s_c41 + f_c22*s_c42 + f_c32*s_c43 + f_c42*s_c44)); - output.set(4, 3, (short) (f_c03*s_c40 + f_c13*s_c41 + f_c23*s_c42 + f_c33*s_c43 + f_c43*s_c44)); - output.set(4, 4, (short) (f_c04*s_c40 + f_c14*s_c41 + f_c24*s_c42 + f_c34*s_c43 + f_c44*s_c44)); + if (output.getRows() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getRows() + " rows, when 5 were expected"); + if (output.getColumns() != 5) throw new IllegalArgumentException("Provided output matrix has " + output.getColumns() + " columns, when 5 were expected"); + final short f00 = matrix1.get(0, 0); + final short f10 = matrix1.get(1, 0); + final short f20 = matrix1.get(2, 0); + final short f30 = matrix1.get(3, 0); + final short f40 = matrix1.get(4, 0); + final short f01 = matrix1.get(0, 1); + final short f11 = matrix1.get(1, 1); + final short f21 = matrix1.get(2, 1); + final short f31 = matrix1.get(3, 1); + final short f41 = matrix1.get(4, 1); + final short f02 = matrix1.get(0, 2); + final short f12 = matrix1.get(1, 2); + final short f22 = matrix1.get(2, 2); + final short f32 = matrix1.get(3, 2); + final short f42 = matrix1.get(4, 2); + final short f03 = matrix1.get(0, 3); + final short f13 = matrix1.get(1, 3); + final short f23 = matrix1.get(2, 3); + final short f33 = matrix1.get(3, 3); + final short f43 = matrix1.get(4, 3); + final short f04 = matrix1.get(0, 4); + final short f14 = matrix1.get(1, 4); + final short f24 = matrix1.get(2, 4); + final short f34 = matrix1.get(3, 4); + final short f44 = matrix1.get(4, 4); + final short s00 = matrix2.get(0, 0); + final short s10 = matrix2.get(1, 0); + final short s20 = matrix2.get(2, 0); + final short s30 = matrix2.get(3, 0); + final short s40 = matrix2.get(4, 0); + final short s01 = matrix2.get(0, 1); + final short s11 = matrix2.get(1, 1); + final short s21 = matrix2.get(2, 1); + final short s31 = matrix2.get(3, 1); + final short s41 = matrix2.get(4, 1); + final short s02 = matrix2.get(0, 2); + final short s12 = matrix2.get(1, 2); + final short s22 = matrix2.get(2, 2); + final short s32 = matrix2.get(3, 2); + final short s42 = matrix2.get(4, 2); + final short s03 = matrix2.get(0, 3); + final short s13 = matrix2.get(1, 3); + final short s23 = matrix2.get(2, 3); + final short s33 = matrix2.get(3, 3); + final short s43 = matrix2.get(4, 3); + final short s04 = matrix2.get(0, 4); + final short s14 = matrix2.get(1, 4); + final short s24 = matrix2.get(2, 4); + final short s34 = matrix2.get(3, 4); + final short s44 = matrix2.get(4, 4); + output.set(0, 0, (short) (f00 * s00 + f10 * s01 + f20 * s02 + f30 * s03 + f40 * s04)); + output.set(1, 0, (short) (f00 * s10 + f10 * s11 + f20 * s12 + f30 * s13 + f40 * s14)); + output.set(2, 0, (short) (f00 * s20 + f10 * s21 + f20 * s22 + f30 * s23 + f40 * s24)); + output.set(3, 0, (short) (f00 * s30 + f10 * s31 + f20 * s32 + f30 * s33 + f40 * s34)); + output.set(4, 0, (short) (f00 * s40 + f10 * s41 + f20 * s42 + f30 * s43 + f40 * s44)); + output.set(0, 1, (short) (f01 * s00 + f11 * s01 + f21 * s02 + f31 * s03 + f41 * s04)); + output.set(1, 1, (short) (f01 * s10 + f11 * s11 + f21 * s12 + f31 * s13 + f41 * s14)); + output.set(2, 1, (short) (f01 * s20 + f11 * s21 + f21 * s22 + f31 * s23 + f41 * s24)); + output.set(3, 1, (short) (f01 * s30 + f11 * s31 + f21 * s32 + f31 * s33 + f41 * s34)); + output.set(4, 1, (short) (f01 * s40 + f11 * s41 + f21 * s42 + f31 * s43 + f41 * s44)); + output.set(0, 2, (short) (f02 * s00 + f12 * s01 + f22 * s02 + f32 * s03 + f42 * s04)); + output.set(1, 2, (short) (f02 * s10 + f12 * s11 + f22 * s12 + f32 * s13 + f42 * s14)); + output.set(2, 2, (short) (f02 * s20 + f12 * s21 + f22 * s22 + f32 * s23 + f42 * s24)); + output.set(3, 2, (short) (f02 * s30 + f12 * s31 + f22 * s32 + f32 * s33 + f42 * s34)); + output.set(4, 2, (short) (f02 * s40 + f12 * s41 + f22 * s42 + f32 * s43 + f42 * s44)); + output.set(0, 3, (short) (f03 * s00 + f13 * s01 + f23 * s02 + f33 * s03 + f43 * s04)); + output.set(1, 3, (short) (f03 * s10 + f13 * s11 + f23 * s12 + f33 * s13 + f43 * s14)); + output.set(2, 3, (short) (f03 * s20 + f13 * s21 + f23 * s22 + f33 * s23 + f43 * s24)); + output.set(3, 3, (short) (f03 * s30 + f13 * s31 + f23 * s32 + f33 * s33 + f43 * s34)); + output.set(4, 3, (short) (f03 * s40 + f13 * s41 + f23 * s42 + f33 * s43 + f43 * s44)); + output.set(0, 4, (short) (f04 * s00 + f14 * s01 + f24 * s02 + f34 * s03 + f44 * s04)); + output.set(1, 4, (short) (f04 * s10 + f14 * s11 + f24 * s12 + f34 * s13 + f44 * s14)); + output.set(2, 4, (short) (f04 * s20 + f14 * s21 + f24 * s22 + f34 * s23 + f44 * s24)); + output.set(3, 4, (short) (f04 * s30 + f14 * s31 + f24 * s32 + f34 * s33 + f44 * s34)); + output.set(4, 4, (short) (f04 * s40 + f14 * s41 + f24 * s42 + f34 * s43 + f44 * s44)); return output; } /** * Automatically generated concrete matrix multiplication. If no mapping exist, this method returns null. * - * @return new Short2Dimensional + * @return new Short2Dimensional */ - @org.jetbrains.annotations.Nullable - public static Short2Dimensional multiplyMatrix(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2) { + @org.jetbrains.annotations.Nullable + public static Short2Dimensional multiplyMatrix(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2) { if (matrix1.getColumns() != matrix2.getRows()) return null; - switch (matrix1.getColumns()) { - case 2: switch (matrix1.getRows()) { - case 2: switch (matrix2.getColumns()) { + switch(matrix1.getColumns()) { + case 1: switch(matrix1.getRows()) { + case 1: switch(matrix2.getColumns()) { + case 1: return (Short2Dimensional) multiplyMatrix1x1x1(matrix1, matrix2, new Short2Dimensional(1, 1)); + case 2: return (Short2Dimensional) multiplyMatrix1x1x2(matrix1, matrix2, new Short2Dimensional(2, 1)); + case 3: return (Short2Dimensional) multiplyMatrix1x1x3(matrix1, matrix2, new Short2Dimensional(3, 1)); + case 4: return (Short2Dimensional) multiplyMatrix1x1x4(matrix1, matrix2, new Short2Dimensional(4, 1)); + case 5: return (Short2Dimensional) multiplyMatrix1x1x5(matrix1, matrix2, new Short2Dimensional(5, 1)); + default: return null; + } + case 2: switch(matrix2.getColumns()) { + case 1: return (Short2Dimensional) multiplyMatrix2x1x1(matrix1, matrix2, new Short2Dimensional(1, 2)); + case 2: return (Short2Dimensional) multiplyMatrix2x1x2(matrix1, matrix2, new Short2Dimensional(2, 2)); + case 3: return (Short2Dimensional) multiplyMatrix2x1x3(matrix1, matrix2, new Short2Dimensional(3, 2)); + case 4: return (Short2Dimensional) multiplyMatrix2x1x4(matrix1, matrix2, new Short2Dimensional(4, 2)); + case 5: return (Short2Dimensional) multiplyMatrix2x1x5(matrix1, matrix2, new Short2Dimensional(5, 2)); + default: return null; + } + case 3: switch(matrix2.getColumns()) { + case 1: return (Short2Dimensional) multiplyMatrix3x1x1(matrix1, matrix2, new Short2Dimensional(1, 3)); + case 2: return (Short2Dimensional) multiplyMatrix3x1x2(matrix1, matrix2, new Short2Dimensional(2, 3)); + case 3: return (Short2Dimensional) multiplyMatrix3x1x3(matrix1, matrix2, new Short2Dimensional(3, 3)); + case 4: return (Short2Dimensional) multiplyMatrix3x1x4(matrix1, matrix2, new Short2Dimensional(4, 3)); + case 5: return (Short2Dimensional) multiplyMatrix3x1x5(matrix1, matrix2, new Short2Dimensional(5, 3)); + default: return null; + } + case 4: switch(matrix2.getColumns()) { + case 1: return (Short2Dimensional) multiplyMatrix4x1x1(matrix1, matrix2, new Short2Dimensional(1, 4)); + case 2: return (Short2Dimensional) multiplyMatrix4x1x2(matrix1, matrix2, new Short2Dimensional(2, 4)); + case 3: return (Short2Dimensional) multiplyMatrix4x1x3(matrix1, matrix2, new Short2Dimensional(3, 4)); + case 4: return (Short2Dimensional) multiplyMatrix4x1x4(matrix1, matrix2, new Short2Dimensional(4, 4)); + case 5: return (Short2Dimensional) multiplyMatrix4x1x5(matrix1, matrix2, new Short2Dimensional(5, 4)); + default: return null; + } + case 5: switch(matrix2.getColumns()) { + case 1: return (Short2Dimensional) multiplyMatrix5x1x1(matrix1, matrix2, new Short2Dimensional(1, 5)); + case 2: return (Short2Dimensional) multiplyMatrix5x1x2(matrix1, matrix2, new Short2Dimensional(2, 5)); + case 3: return (Short2Dimensional) multiplyMatrix5x1x3(matrix1, matrix2, new Short2Dimensional(3, 5)); + case 4: return (Short2Dimensional) multiplyMatrix5x1x4(matrix1, matrix2, new Short2Dimensional(4, 5)); + case 5: return (Short2Dimensional) multiplyMatrix5x1x5(matrix1, matrix2, new Short2Dimensional(5, 5)); + default: return null; + } + default: return null; + } + case 2: switch(matrix1.getRows()) { + case 1: switch(matrix2.getColumns()) { + case 1: return (Short2Dimensional) multiplyMatrix1x2x1(matrix1, matrix2, new Short2Dimensional(1, 1)); + case 2: return (Short2Dimensional) multiplyMatrix1x2x2(matrix1, matrix2, new Short2Dimensional(2, 1)); + case 3: return (Short2Dimensional) multiplyMatrix1x2x3(matrix1, matrix2, new Short2Dimensional(3, 1)); + case 4: return (Short2Dimensional) multiplyMatrix1x2x4(matrix1, matrix2, new Short2Dimensional(4, 1)); + case 5: return (Short2Dimensional) multiplyMatrix1x2x5(matrix1, matrix2, new Short2Dimensional(5, 1)); + default: return null; + } + case 2: switch(matrix2.getColumns()) { + case 1: return (Short2Dimensional) multiplyMatrix2x2x1(matrix1, matrix2, new Short2Dimensional(1, 2)); case 2: return (Short2Dimensional) multiplyMatrix2x2x2(matrix1, matrix2, new Short2Dimensional(2, 2)); case 3: return (Short2Dimensional) multiplyMatrix2x2x3(matrix1, matrix2, new Short2Dimensional(3, 2)); case 4: return (Short2Dimensional) multiplyMatrix2x2x4(matrix1, matrix2, new Short2Dimensional(4, 2)); case 5: return (Short2Dimensional) multiplyMatrix2x2x5(matrix1, matrix2, new Short2Dimensional(5, 2)); default: return null; } - case 3: switch (matrix2.getColumns()) { + case 3: switch(matrix2.getColumns()) { + case 1: return (Short2Dimensional) multiplyMatrix3x2x1(matrix1, matrix2, new Short2Dimensional(1, 3)); case 2: return (Short2Dimensional) multiplyMatrix3x2x2(matrix1, matrix2, new Short2Dimensional(2, 3)); case 3: return (Short2Dimensional) multiplyMatrix3x2x3(matrix1, matrix2, new Short2Dimensional(3, 3)); case 4: return (Short2Dimensional) multiplyMatrix3x2x4(matrix1, matrix2, new Short2Dimensional(4, 3)); case 5: return (Short2Dimensional) multiplyMatrix3x2x5(matrix1, matrix2, new Short2Dimensional(5, 3)); default: return null; } - case 4: switch (matrix2.getColumns()) { + case 4: switch(matrix2.getColumns()) { + case 1: return (Short2Dimensional) multiplyMatrix4x2x1(matrix1, matrix2, new Short2Dimensional(1, 4)); case 2: return (Short2Dimensional) multiplyMatrix4x2x2(matrix1, matrix2, new Short2Dimensional(2, 4)); case 3: return (Short2Dimensional) multiplyMatrix4x2x3(matrix1, matrix2, new Short2Dimensional(3, 4)); case 4: return (Short2Dimensional) multiplyMatrix4x2x4(matrix1, matrix2, new Short2Dimensional(4, 4)); case 5: return (Short2Dimensional) multiplyMatrix4x2x5(matrix1, matrix2, new Short2Dimensional(5, 4)); default: return null; } - case 5: switch (matrix2.getColumns()) { + case 5: switch(matrix2.getColumns()) { + case 1: return (Short2Dimensional) multiplyMatrix5x2x1(matrix1, matrix2, new Short2Dimensional(1, 5)); case 2: return (Short2Dimensional) multiplyMatrix5x2x2(matrix1, matrix2, new Short2Dimensional(2, 5)); case 3: return (Short2Dimensional) multiplyMatrix5x2x3(matrix1, matrix2, new Short2Dimensional(3, 5)); case 4: return (Short2Dimensional) multiplyMatrix5x2x4(matrix1, matrix2, new Short2Dimensional(4, 5)); @@ -2788,29 +4230,41 @@ public final class MultiplicationsShort { } default: return null; } - case 3: switch (matrix1.getRows()) { - case 2: switch (matrix2.getColumns()) { + case 3: switch(matrix1.getRows()) { + case 1: switch(matrix2.getColumns()) { + case 1: return (Short2Dimensional) multiplyMatrix1x3x1(matrix1, matrix2, new Short2Dimensional(1, 1)); + case 2: return (Short2Dimensional) multiplyMatrix1x3x2(matrix1, matrix2, new Short2Dimensional(2, 1)); + case 3: return (Short2Dimensional) multiplyMatrix1x3x3(matrix1, matrix2, new Short2Dimensional(3, 1)); + case 4: return (Short2Dimensional) multiplyMatrix1x3x4(matrix1, matrix2, new Short2Dimensional(4, 1)); + case 5: return (Short2Dimensional) multiplyMatrix1x3x5(matrix1, matrix2, new Short2Dimensional(5, 1)); + default: return null; + } + case 2: switch(matrix2.getColumns()) { + case 1: return (Short2Dimensional) multiplyMatrix2x3x1(matrix1, matrix2, new Short2Dimensional(1, 2)); case 2: return (Short2Dimensional) multiplyMatrix2x3x2(matrix1, matrix2, new Short2Dimensional(2, 2)); case 3: return (Short2Dimensional) multiplyMatrix2x3x3(matrix1, matrix2, new Short2Dimensional(3, 2)); case 4: return (Short2Dimensional) multiplyMatrix2x3x4(matrix1, matrix2, new Short2Dimensional(4, 2)); case 5: return (Short2Dimensional) multiplyMatrix2x3x5(matrix1, matrix2, new Short2Dimensional(5, 2)); default: return null; } - case 3: switch (matrix2.getColumns()) { + case 3: switch(matrix2.getColumns()) { + case 1: return (Short2Dimensional) multiplyMatrix3x3x1(matrix1, matrix2, new Short2Dimensional(1, 3)); case 2: return (Short2Dimensional) multiplyMatrix3x3x2(matrix1, matrix2, new Short2Dimensional(2, 3)); case 3: return (Short2Dimensional) multiplyMatrix3x3x3(matrix1, matrix2, new Short2Dimensional(3, 3)); case 4: return (Short2Dimensional) multiplyMatrix3x3x4(matrix1, matrix2, new Short2Dimensional(4, 3)); case 5: return (Short2Dimensional) multiplyMatrix3x3x5(matrix1, matrix2, new Short2Dimensional(5, 3)); default: return null; } - case 4: switch (matrix2.getColumns()) { + case 4: switch(matrix2.getColumns()) { + case 1: return (Short2Dimensional) multiplyMatrix4x3x1(matrix1, matrix2, new Short2Dimensional(1, 4)); case 2: return (Short2Dimensional) multiplyMatrix4x3x2(matrix1, matrix2, new Short2Dimensional(2, 4)); case 3: return (Short2Dimensional) multiplyMatrix4x3x3(matrix1, matrix2, new Short2Dimensional(3, 4)); case 4: return (Short2Dimensional) multiplyMatrix4x3x4(matrix1, matrix2, new Short2Dimensional(4, 4)); case 5: return (Short2Dimensional) multiplyMatrix4x3x5(matrix1, matrix2, new Short2Dimensional(5, 4)); default: return null; } - case 5: switch (matrix2.getColumns()) { + case 5: switch(matrix2.getColumns()) { + case 1: return (Short2Dimensional) multiplyMatrix5x3x1(matrix1, matrix2, new Short2Dimensional(1, 5)); case 2: return (Short2Dimensional) multiplyMatrix5x3x2(matrix1, matrix2, new Short2Dimensional(2, 5)); case 3: return (Short2Dimensional) multiplyMatrix5x3x3(matrix1, matrix2, new Short2Dimensional(3, 5)); case 4: return (Short2Dimensional) multiplyMatrix5x3x4(matrix1, matrix2, new Short2Dimensional(4, 5)); @@ -2819,29 +4273,41 @@ public final class MultiplicationsShort { } default: return null; } - case 4: switch (matrix1.getRows()) { - case 2: switch (matrix2.getColumns()) { + case 4: switch(matrix1.getRows()) { + case 1: switch(matrix2.getColumns()) { + case 1: return (Short2Dimensional) multiplyMatrix1x4x1(matrix1, matrix2, new Short2Dimensional(1, 1)); + case 2: return (Short2Dimensional) multiplyMatrix1x4x2(matrix1, matrix2, new Short2Dimensional(2, 1)); + case 3: return (Short2Dimensional) multiplyMatrix1x4x3(matrix1, matrix2, new Short2Dimensional(3, 1)); + case 4: return (Short2Dimensional) multiplyMatrix1x4x4(matrix1, matrix2, new Short2Dimensional(4, 1)); + case 5: return (Short2Dimensional) multiplyMatrix1x4x5(matrix1, matrix2, new Short2Dimensional(5, 1)); + default: return null; + } + case 2: switch(matrix2.getColumns()) { + case 1: return (Short2Dimensional) multiplyMatrix2x4x1(matrix1, matrix2, new Short2Dimensional(1, 2)); case 2: return (Short2Dimensional) multiplyMatrix2x4x2(matrix1, matrix2, new Short2Dimensional(2, 2)); case 3: return (Short2Dimensional) multiplyMatrix2x4x3(matrix1, matrix2, new Short2Dimensional(3, 2)); case 4: return (Short2Dimensional) multiplyMatrix2x4x4(matrix1, matrix2, new Short2Dimensional(4, 2)); case 5: return (Short2Dimensional) multiplyMatrix2x4x5(matrix1, matrix2, new Short2Dimensional(5, 2)); default: return null; } - case 3: switch (matrix2.getColumns()) { + case 3: switch(matrix2.getColumns()) { + case 1: return (Short2Dimensional) multiplyMatrix3x4x1(matrix1, matrix2, new Short2Dimensional(1, 3)); case 2: return (Short2Dimensional) multiplyMatrix3x4x2(matrix1, matrix2, new Short2Dimensional(2, 3)); case 3: return (Short2Dimensional) multiplyMatrix3x4x3(matrix1, matrix2, new Short2Dimensional(3, 3)); case 4: return (Short2Dimensional) multiplyMatrix3x4x4(matrix1, matrix2, new Short2Dimensional(4, 3)); case 5: return (Short2Dimensional) multiplyMatrix3x4x5(matrix1, matrix2, new Short2Dimensional(5, 3)); default: return null; } - case 4: switch (matrix2.getColumns()) { + case 4: switch(matrix2.getColumns()) { + case 1: return (Short2Dimensional) multiplyMatrix4x4x1(matrix1, matrix2, new Short2Dimensional(1, 4)); case 2: return (Short2Dimensional) multiplyMatrix4x4x2(matrix1, matrix2, new Short2Dimensional(2, 4)); case 3: return (Short2Dimensional) multiplyMatrix4x4x3(matrix1, matrix2, new Short2Dimensional(3, 4)); case 4: return (Short2Dimensional) multiplyMatrix4x4x4(matrix1, matrix2, new Short2Dimensional(4, 4)); case 5: return (Short2Dimensional) multiplyMatrix4x4x5(matrix1, matrix2, new Short2Dimensional(5, 4)); default: return null; } - case 5: switch (matrix2.getColumns()) { + case 5: switch(matrix2.getColumns()) { + case 1: return (Short2Dimensional) multiplyMatrix5x4x1(matrix1, matrix2, new Short2Dimensional(1, 5)); case 2: return (Short2Dimensional) multiplyMatrix5x4x2(matrix1, matrix2, new Short2Dimensional(2, 5)); case 3: return (Short2Dimensional) multiplyMatrix5x4x3(matrix1, matrix2, new Short2Dimensional(3, 5)); case 4: return (Short2Dimensional) multiplyMatrix5x4x4(matrix1, matrix2, new Short2Dimensional(4, 5)); @@ -2850,29 +4316,41 @@ public final class MultiplicationsShort { } default: return null; } - case 5: switch (matrix1.getRows()) { - case 2: switch (matrix2.getColumns()) { + case 5: switch(matrix1.getRows()) { + case 1: switch(matrix2.getColumns()) { + case 1: return (Short2Dimensional) multiplyMatrix1x5x1(matrix1, matrix2, new Short2Dimensional(1, 1)); + case 2: return (Short2Dimensional) multiplyMatrix1x5x2(matrix1, matrix2, new Short2Dimensional(2, 1)); + case 3: return (Short2Dimensional) multiplyMatrix1x5x3(matrix1, matrix2, new Short2Dimensional(3, 1)); + case 4: return (Short2Dimensional) multiplyMatrix1x5x4(matrix1, matrix2, new Short2Dimensional(4, 1)); + case 5: return (Short2Dimensional) multiplyMatrix1x5x5(matrix1, matrix2, new Short2Dimensional(5, 1)); + default: return null; + } + case 2: switch(matrix2.getColumns()) { + case 1: return (Short2Dimensional) multiplyMatrix2x5x1(matrix1, matrix2, new Short2Dimensional(1, 2)); case 2: return (Short2Dimensional) multiplyMatrix2x5x2(matrix1, matrix2, new Short2Dimensional(2, 2)); case 3: return (Short2Dimensional) multiplyMatrix2x5x3(matrix1, matrix2, new Short2Dimensional(3, 2)); case 4: return (Short2Dimensional) multiplyMatrix2x5x4(matrix1, matrix2, new Short2Dimensional(4, 2)); case 5: return (Short2Dimensional) multiplyMatrix2x5x5(matrix1, matrix2, new Short2Dimensional(5, 2)); default: return null; } - case 3: switch (matrix2.getColumns()) { + case 3: switch(matrix2.getColumns()) { + case 1: return (Short2Dimensional) multiplyMatrix3x5x1(matrix1, matrix2, new Short2Dimensional(1, 3)); case 2: return (Short2Dimensional) multiplyMatrix3x5x2(matrix1, matrix2, new Short2Dimensional(2, 3)); case 3: return (Short2Dimensional) multiplyMatrix3x5x3(matrix1, matrix2, new Short2Dimensional(3, 3)); case 4: return (Short2Dimensional) multiplyMatrix3x5x4(matrix1, matrix2, new Short2Dimensional(4, 3)); case 5: return (Short2Dimensional) multiplyMatrix3x5x5(matrix1, matrix2, new Short2Dimensional(5, 3)); default: return null; } - case 4: switch (matrix2.getColumns()) { + case 4: switch(matrix2.getColumns()) { + case 1: return (Short2Dimensional) multiplyMatrix4x5x1(matrix1, matrix2, new Short2Dimensional(1, 4)); case 2: return (Short2Dimensional) multiplyMatrix4x5x2(matrix1, matrix2, new Short2Dimensional(2, 4)); case 3: return (Short2Dimensional) multiplyMatrix4x5x3(matrix1, matrix2, new Short2Dimensional(3, 4)); case 4: return (Short2Dimensional) multiplyMatrix4x5x4(matrix1, matrix2, new Short2Dimensional(4, 4)); case 5: return (Short2Dimensional) multiplyMatrix4x5x5(matrix1, matrix2, new Short2Dimensional(5, 4)); default: return null; } - case 5: switch (matrix2.getColumns()) { + case 5: switch(matrix2.getColumns()) { + case 1: return (Short2Dimensional) multiplyMatrix5x5x1(matrix1, matrix2, new Short2Dimensional(1, 5)); case 2: return (Short2Dimensional) multiplyMatrix5x5x2(matrix1, matrix2, new Short2Dimensional(2, 5)); case 3: return (Short2Dimensional) multiplyMatrix5x5x3(matrix1, matrix2, new Short2Dimensional(3, 5)); case 4: return (Short2Dimensional) multiplyMatrix5x5x4(matrix1, matrix2, new Short2Dimensional(4, 5)); @@ -2884,39 +4362,94 @@ public final class MultiplicationsShort { default: return null; } } - /** - * Automatically generated concrete matrix multiplication. If no mapping exist, this method returns null. - * This method writes the result to specified [output] - * @return provided IMatrixSetterShort if mapping exists and computed, or null if mapping does not exist + * Automatically generated concrete matrix multiplication. + * This function writes the result onto specified output, and returns it, if mapping exists and computed, otherwise returns null. + * + * @return provided output, or null if mapping does not exist */ - @org.jetbrains.annotations.Nullable - public static IMatrixSetterShort multiplyMatrix(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { + @org.jetbrains.annotations.Nullable + public static IMatrixSetterShort multiplyMatrix(final IMatrixGetterShort matrix1, final IMatrixGetterShort matrix2, final IMatrixSetterShort output) { if (matrix1.getColumns() != matrix2.getRows()) return null; - switch (matrix1.getColumns()) { - case 2: switch (matrix1.getRows()) { - case 2: switch (matrix2.getColumns()) { + switch(matrix1.getColumns()) { + case 1: switch(matrix1.getRows()) { + case 1: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix1x1x1(matrix1, matrix2, output); + case 2: return multiplyMatrix1x1x2(matrix1, matrix2, output); + case 3: return multiplyMatrix1x1x3(matrix1, matrix2, output); + case 4: return multiplyMatrix1x1x4(matrix1, matrix2, output); + case 5: return multiplyMatrix1x1x5(matrix1, matrix2, output); + default: return null; + } + case 2: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix2x1x1(matrix1, matrix2, output); + case 2: return multiplyMatrix2x1x2(matrix1, matrix2, output); + case 3: return multiplyMatrix2x1x3(matrix1, matrix2, output); + case 4: return multiplyMatrix2x1x4(matrix1, matrix2, output); + case 5: return multiplyMatrix2x1x5(matrix1, matrix2, output); + default: return null; + } + case 3: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix3x1x1(matrix1, matrix2, output); + case 2: return multiplyMatrix3x1x2(matrix1, matrix2, output); + case 3: return multiplyMatrix3x1x3(matrix1, matrix2, output); + case 4: return multiplyMatrix3x1x4(matrix1, matrix2, output); + case 5: return multiplyMatrix3x1x5(matrix1, matrix2, output); + default: return null; + } + case 4: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix4x1x1(matrix1, matrix2, output); + case 2: return multiplyMatrix4x1x2(matrix1, matrix2, output); + case 3: return multiplyMatrix4x1x3(matrix1, matrix2, output); + case 4: return multiplyMatrix4x1x4(matrix1, matrix2, output); + case 5: return multiplyMatrix4x1x5(matrix1, matrix2, output); + default: return null; + } + case 5: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix5x1x1(matrix1, matrix2, output); + case 2: return multiplyMatrix5x1x2(matrix1, matrix2, output); + case 3: return multiplyMatrix5x1x3(matrix1, matrix2, output); + case 4: return multiplyMatrix5x1x4(matrix1, matrix2, output); + case 5: return multiplyMatrix5x1x5(matrix1, matrix2, output); + default: return null; + } + default: return null; + } + case 2: switch(matrix1.getRows()) { + case 1: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix1x2x1(matrix1, matrix2, output); + case 2: return multiplyMatrix1x2x2(matrix1, matrix2, output); + case 3: return multiplyMatrix1x2x3(matrix1, matrix2, output); + case 4: return multiplyMatrix1x2x4(matrix1, matrix2, output); + case 5: return multiplyMatrix1x2x5(matrix1, matrix2, output); + default: return null; + } + case 2: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix2x2x1(matrix1, matrix2, output); case 2: return multiplyMatrix2x2x2(matrix1, matrix2, output); case 3: return multiplyMatrix2x2x3(matrix1, matrix2, output); case 4: return multiplyMatrix2x2x4(matrix1, matrix2, output); case 5: return multiplyMatrix2x2x5(matrix1, matrix2, output); default: return null; } - case 3: switch (matrix2.getColumns()) { + case 3: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix3x2x1(matrix1, matrix2, output); case 2: return multiplyMatrix3x2x2(matrix1, matrix2, output); case 3: return multiplyMatrix3x2x3(matrix1, matrix2, output); case 4: return multiplyMatrix3x2x4(matrix1, matrix2, output); case 5: return multiplyMatrix3x2x5(matrix1, matrix2, output); default: return null; } - case 4: switch (matrix2.getColumns()) { + case 4: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix4x2x1(matrix1, matrix2, output); case 2: return multiplyMatrix4x2x2(matrix1, matrix2, output); case 3: return multiplyMatrix4x2x3(matrix1, matrix2, output); case 4: return multiplyMatrix4x2x4(matrix1, matrix2, output); case 5: return multiplyMatrix4x2x5(matrix1, matrix2, output); default: return null; } - case 5: switch (matrix2.getColumns()) { + case 5: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix5x2x1(matrix1, matrix2, output); case 2: return multiplyMatrix5x2x2(matrix1, matrix2, output); case 3: return multiplyMatrix5x2x3(matrix1, matrix2, output); case 4: return multiplyMatrix5x2x4(matrix1, matrix2, output); @@ -2925,29 +4458,41 @@ public final class MultiplicationsShort { } default: return null; } - case 3: switch (matrix1.getRows()) { - case 2: switch (matrix2.getColumns()) { + case 3: switch(matrix1.getRows()) { + case 1: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix1x3x1(matrix1, matrix2, output); + case 2: return multiplyMatrix1x3x2(matrix1, matrix2, output); + case 3: return multiplyMatrix1x3x3(matrix1, matrix2, output); + case 4: return multiplyMatrix1x3x4(matrix1, matrix2, output); + case 5: return multiplyMatrix1x3x5(matrix1, matrix2, output); + default: return null; + } + case 2: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix2x3x1(matrix1, matrix2, output); case 2: return multiplyMatrix2x3x2(matrix1, matrix2, output); case 3: return multiplyMatrix2x3x3(matrix1, matrix2, output); case 4: return multiplyMatrix2x3x4(matrix1, matrix2, output); case 5: return multiplyMatrix2x3x5(matrix1, matrix2, output); default: return null; } - case 3: switch (matrix2.getColumns()) { + case 3: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix3x3x1(matrix1, matrix2, output); case 2: return multiplyMatrix3x3x2(matrix1, matrix2, output); case 3: return multiplyMatrix3x3x3(matrix1, matrix2, output); case 4: return multiplyMatrix3x3x4(matrix1, matrix2, output); case 5: return multiplyMatrix3x3x5(matrix1, matrix2, output); default: return null; } - case 4: switch (matrix2.getColumns()) { + case 4: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix4x3x1(matrix1, matrix2, output); case 2: return multiplyMatrix4x3x2(matrix1, matrix2, output); case 3: return multiplyMatrix4x3x3(matrix1, matrix2, output); case 4: return multiplyMatrix4x3x4(matrix1, matrix2, output); case 5: return multiplyMatrix4x3x5(matrix1, matrix2, output); default: return null; } - case 5: switch (matrix2.getColumns()) { + case 5: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix5x3x1(matrix1, matrix2, output); case 2: return multiplyMatrix5x3x2(matrix1, matrix2, output); case 3: return multiplyMatrix5x3x3(matrix1, matrix2, output); case 4: return multiplyMatrix5x3x4(matrix1, matrix2, output); @@ -2956,29 +4501,41 @@ public final class MultiplicationsShort { } default: return null; } - case 4: switch (matrix1.getRows()) { - case 2: switch (matrix2.getColumns()) { + case 4: switch(matrix1.getRows()) { + case 1: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix1x4x1(matrix1, matrix2, output); + case 2: return multiplyMatrix1x4x2(matrix1, matrix2, output); + case 3: return multiplyMatrix1x4x3(matrix1, matrix2, output); + case 4: return multiplyMatrix1x4x4(matrix1, matrix2, output); + case 5: return multiplyMatrix1x4x5(matrix1, matrix2, output); + default: return null; + } + case 2: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix2x4x1(matrix1, matrix2, output); case 2: return multiplyMatrix2x4x2(matrix1, matrix2, output); case 3: return multiplyMatrix2x4x3(matrix1, matrix2, output); case 4: return multiplyMatrix2x4x4(matrix1, matrix2, output); case 5: return multiplyMatrix2x4x5(matrix1, matrix2, output); default: return null; } - case 3: switch (matrix2.getColumns()) { + case 3: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix3x4x1(matrix1, matrix2, output); case 2: return multiplyMatrix3x4x2(matrix1, matrix2, output); case 3: return multiplyMatrix3x4x3(matrix1, matrix2, output); case 4: return multiplyMatrix3x4x4(matrix1, matrix2, output); case 5: return multiplyMatrix3x4x5(matrix1, matrix2, output); default: return null; } - case 4: switch (matrix2.getColumns()) { + case 4: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix4x4x1(matrix1, matrix2, output); case 2: return multiplyMatrix4x4x2(matrix1, matrix2, output); case 3: return multiplyMatrix4x4x3(matrix1, matrix2, output); case 4: return multiplyMatrix4x4x4(matrix1, matrix2, output); case 5: return multiplyMatrix4x4x5(matrix1, matrix2, output); default: return null; } - case 5: switch (matrix2.getColumns()) { + case 5: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix5x4x1(matrix1, matrix2, output); case 2: return multiplyMatrix5x4x2(matrix1, matrix2, output); case 3: return multiplyMatrix5x4x3(matrix1, matrix2, output); case 4: return multiplyMatrix5x4x4(matrix1, matrix2, output); @@ -2987,29 +4544,41 @@ public final class MultiplicationsShort { } default: return null; } - case 5: switch (matrix1.getRows()) { - case 2: switch (matrix2.getColumns()) { + case 5: switch(matrix1.getRows()) { + case 1: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix1x5x1(matrix1, matrix2, output); + case 2: return multiplyMatrix1x5x2(matrix1, matrix2, output); + case 3: return multiplyMatrix1x5x3(matrix1, matrix2, output); + case 4: return multiplyMatrix1x5x4(matrix1, matrix2, output); + case 5: return multiplyMatrix1x5x5(matrix1, matrix2, output); + default: return null; + } + case 2: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix2x5x1(matrix1, matrix2, output); case 2: return multiplyMatrix2x5x2(matrix1, matrix2, output); case 3: return multiplyMatrix2x5x3(matrix1, matrix2, output); case 4: return multiplyMatrix2x5x4(matrix1, matrix2, output); case 5: return multiplyMatrix2x5x5(matrix1, matrix2, output); default: return null; } - case 3: switch (matrix2.getColumns()) { + case 3: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix3x5x1(matrix1, matrix2, output); case 2: return multiplyMatrix3x5x2(matrix1, matrix2, output); case 3: return multiplyMatrix3x5x3(matrix1, matrix2, output); case 4: return multiplyMatrix3x5x4(matrix1, matrix2, output); case 5: return multiplyMatrix3x5x5(matrix1, matrix2, output); default: return null; } - case 4: switch (matrix2.getColumns()) { + case 4: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix4x5x1(matrix1, matrix2, output); case 2: return multiplyMatrix4x5x2(matrix1, matrix2, output); case 3: return multiplyMatrix4x5x3(matrix1, matrix2, output); case 4: return multiplyMatrix4x5x4(matrix1, matrix2, output); case 5: return multiplyMatrix4x5x5(matrix1, matrix2, output); default: return null; } - case 5: switch (matrix2.getColumns()) { + case 5: switch(matrix2.getColumns()) { + case 1: return multiplyMatrix5x5x1(matrix1, matrix2, output); case 2: return multiplyMatrix5x5x2(matrix1, matrix2, output); case 3: return multiplyMatrix5x5x3(matrix1, matrix2, output); case 4: return multiplyMatrix5x5x4(matrix1, matrix2, output); diff --git a/src/kvector/kotlin/ru/dbotthepony/kvector/api/DoubleMatrix.kt b/src/kvector/kotlin/ru/dbotthepony/kvector/api/DoubleMatrix.kt index e00104a2..0104f614 100644 --- a/src/kvector/kotlin/ru/dbotthepony/kvector/api/DoubleMatrix.kt +++ b/src/kvector/kotlin/ru/dbotthepony/kvector/api/DoubleMatrix.kt @@ -3,6 +3,11 @@ package ru.dbotthepony.kvector.api +import ru.dbotthepony.kvector.api.concrete.IMatrix2d +import java.nio.ByteBuffer +import java.nio.DoubleBuffer +import java.nio.FloatBuffer + interface IMatrixGetterDouble : IMatrixLike { /** * @return component of this matrix, as double @@ -17,6 +22,9 @@ interface IMatrixSetterDouble : IMatrixLike { operator fun set(column: Int, row: Int, value: Double) } +/** + * Defines methods applicable to matrices working with [Double]s + */ interface IDoubleMatrix> : IMatrixGetterDouble { /** * Multiplies all matrix components by [other], returning new matrix as result @@ -58,12 +66,12 @@ interface IDoubleMatrix> : IMatrixGetterDouble { operator fun minus(other: IMatrixGetterDouble): T /** - * This matrix trace. If matrix is not square matrix, null is returned. + * This matrix' trace. If matrix is not square matrix, null is returned. */ val trace: Double? /** - * This matrix determinant. If matrix is not square matrix, null is returned. + * This matrix' determinant. If matrix is not square matrix, null is returned. */ val determinant: Double? @@ -71,6 +79,7 @@ interface IDoubleMatrix> : IMatrixGetterDouble { * This matrix' inverse matrix (this * I = identity). * * This operation is computation intense, do cache its result. + * It is not recommended computing inverse matrix of matrices with order of 6 or bigger. * * If this matrix is not square matrix, or determinant is zero, null is returned. */ @@ -93,6 +102,73 @@ interface IDoubleMatrix> : IMatrixGetterDouble { * If this matrix is not square matrix, null is returned. */ val adjugate: T? + + /** + * Copies memory of this matrix to new [DoubleArray] in either [rowMajor] or column-major + * order. + * + * @return newly constructed [DoubleArray] + */ + fun toDoubleArray(rowMajor: Boolean = false): DoubleArray { + val memory = DoubleArray(columns * rows) + var i = 0 + + if (rowMajor) { + for (row in 0 until rows) { + for (column in 0 until columns) { + memory[i++] = this[column, row] + } + } + } else { + for (column in 0 until columns) { + for (row in 0 until rows) { + memory[i++] = this[column, row] + } + } + } + + return memory + } + + /** + * Writes this matrix to specified [output] at its current position + * in either [rowMajor] or column-major order. + */ + fun write(output: ByteBuffer, rowMajor: Boolean = false) { + if (rowMajor) { + for (row in 0 until rows) { + for (column in 0 until columns) { + output.putDouble(this[column, row]) + } + } + } else { + for (column in 0 until columns) { + for (row in 0 until rows) { + output.putDouble(this[column, row]) + } + } + } + } + + /** + * Writes this matrix to specified [output] at its current position + * in either [rowMajor] or column-major order. + */ + fun write(output: DoubleBuffer, rowMajor: Boolean = false) { + if (rowMajor) { + for (row in 0 until rows) { + for (column in 0 until columns) { + output.put(this[column, row]) + } + } + } else { + for (column in 0 until columns) { + for (row in 0 until rows) { + output.put(this[column, row]) + } + } + } + } } interface IMutableDoubleMatrix> : IMatrixSetterDouble { diff --git a/src/kvector/kotlin/ru/dbotthepony/kvector/api/FloatMatrix.kt b/src/kvector/kotlin/ru/dbotthepony/kvector/api/FloatMatrix.kt index 5778d01e..a574ad59 100644 --- a/src/kvector/kotlin/ru/dbotthepony/kvector/api/FloatMatrix.kt +++ b/src/kvector/kotlin/ru/dbotthepony/kvector/api/FloatMatrix.kt @@ -3,6 +3,9 @@ package ru.dbotthepony.kvector.api +import java.nio.ByteBuffer +import java.nio.FloatBuffer + interface IMatrixGetterFloat : IMatrixLike { /** * @return component of this matrix, as float @@ -17,6 +20,9 @@ interface IMatrixSetterFloat : IMatrixLike { operator fun set(column: Int, row: Int, value: Float) } +/** + * Defines methods applicable to matrices working with [Float]s + */ interface IFloatMatrix> : IMatrixGetterFloat { /** * Multiplies all matrix components by [other], returning new matrix as result @@ -93,6 +99,73 @@ interface IFloatMatrix> : IMatrixGetterFloat { * If this matrix is not square matrix, null is returned. */ val adjugate: T? + + /** + * Copies memory of this matrix to new [FloatArray] in either [rowMajor] or column-major + * order. + * + * @return newly constructed [FloatArray] + */ + fun toFloatArray(rowMajor: Boolean = false): FloatArray { + val memory = FloatArray(columns * rows) + var i = 0 + + if (rowMajor) { + for (row in 0 until rows) { + for (column in 0 until columns) { + memory[i++] = this[column, row] + } + } + } else { + for (column in 0 until columns) { + for (row in 0 until rows) { + memory[i++] = this[column, row] + } + } + } + + return memory + } + + /** + * Writes this matrix to specified [output] at its current position + * in either [rowMajor] or column-major order. + */ + fun write(output: ByteBuffer, rowMajor: Boolean = false) { + if (rowMajor) { + for (row in 0 until rows) { + for (column in 0 until columns) { + output.putFloat(this[column, row]) + } + } + } else { + for (column in 0 until columns) { + for (row in 0 until rows) { + output.putFloat(this[column, row]) + } + } + } + } + + /** + * Writes this matrix to specified [output] at its current position + * in either [rowMajor] or column-major order. + */ + fun write(output: FloatBuffer, rowMajor: Boolean = false) { + if (rowMajor) { + for (row in 0 until rows) { + for (column in 0 until columns) { + output.put(this[column, row]) + } + } + } else { + for (column in 0 until columns) { + for (row in 0 until rows) { + output.put(this[column, row]) + } + } + } + } } interface IMutableFloatMatrix> : IMatrixSetterFloat { diff --git a/src/kvector/kotlin/ru/dbotthepony/kvector/api/Matrix.kt b/src/kvector/kotlin/ru/dbotthepony/kvector/api/Matrix.kt index 50919551..21d845f6 100644 --- a/src/kvector/kotlin/ru/dbotthepony/kvector/api/Matrix.kt +++ b/src/kvector/kotlin/ru/dbotthepony/kvector/api/Matrix.kt @@ -374,7 +374,7 @@ interface IMatrixComplement { /** * Defines common operations with concrete square matrices, such as [translation], [scale]ing, etc */ -interface ISquareMatrix, V> { +interface ISquareMatrix, V, F> { /** * Current translation of this matrix. */ @@ -405,13 +405,13 @@ interface ISquareMatrix, V> { * * @return new matrix */ - fun scale(vector: V): T + fun scale(vector: F): T } /** * Defines common mutable operations with concrete square matrices, such as [translation], [scale]ing, etc */ -interface IMutableSquareMatrix, V> : ISquareMatrix { +interface IMutableSquareMatrix, V, F> : ISquareMatrix { /** * Current translation of this matrix. * @@ -419,6 +419,17 @@ interface IMutableSquareMatrix, V> : ISquareMatri */ override var translation: V + /** + * Does raw translation of this matrix by specified [vector], + * writing result into this matrix. + * + * If you scaled and/or rotated this matrix, and want to move it + * with scale and translation, use [translateWithMultiplication]. + * + * @return this matrix + */ + fun translateMut(vector: V): T + /** * Does translation of this matrix by specified [vector], * with accounting of it's state, writing result into this matrix. @@ -433,5 +444,5 @@ interface IMutableSquareMatrix, V> : ISquareMatri * * @return this matrix */ - fun scaleMut(vector: V): T + fun scaleMut(vector: F): T } diff --git a/src/kvector/kotlin/ru/dbotthepony/kvector/api/concrete/DoubleMatrix.kt b/src/kvector/kotlin/ru/dbotthepony/kvector/api/concrete/DoubleMatrix.kt index 893bead3..9832f247 100644 --- a/src/kvector/kotlin/ru/dbotthepony/kvector/api/concrete/DoubleMatrix.kt +++ b/src/kvector/kotlin/ru/dbotthepony/kvector/api/concrete/DoubleMatrix.kt @@ -187,7 +187,7 @@ interface IMatrix2d> : IMatrix, IDoubleMatrix, ITransposa /** * [Matrix3d] and [MutableMatrix3d] implement this */ -interface IMatrix3d> : IMatrix, IDoubleMatrix, ITransposable, ISquareMatrix { +interface IMatrix3d> : IMatrix, IDoubleMatrix, ITransposable, ISquareMatrix { val c00: Double val c10: Double val c20: Double @@ -383,7 +383,7 @@ interface IMatrix3d> : IMatrix, IDoubleMatrix, ITransposa /** * [Matrix4d] and [MutableMatrix4d] implement this */ -interface IMatrix4d> : IMatrix, IDoubleMatrix, ITransposable, ISquareMatrix { +interface IMatrix4d> : IMatrix, IDoubleMatrix, ITransposable, ISquareMatrix { val c00: Double val c10: Double val c20: Double diff --git a/src/kvector/kotlin/ru/dbotthepony/kvector/api/concrete/FloatMatrix.kt b/src/kvector/kotlin/ru/dbotthepony/kvector/api/concrete/FloatMatrix.kt index 2c7e5e99..e065982d 100644 --- a/src/kvector/kotlin/ru/dbotthepony/kvector/api/concrete/FloatMatrix.kt +++ b/src/kvector/kotlin/ru/dbotthepony/kvector/api/concrete/FloatMatrix.kt @@ -11,6 +11,8 @@ import ru.dbotthepony.kvector.matrix.* import ru.dbotthepony.kvector.matrix.ndouble.* import ru.dbotthepony.kvector.matrix.nfloat.* import ru.dbotthepony.kvector.vector.nfloat.* +import java.nio.ByteBuffer +import java.nio.FloatBuffer /** * [Matrix2f] and [MutableMatrix2f] implement this @@ -191,7 +193,7 @@ interface IMatrix2f> : IMatrix, IFloatMatrix, ITransposab /** * [Matrix3f] and [MutableMatrix3f] implement this */ -interface IMatrix3f> : IMatrix, IFloatMatrix, ITransposable, ISquareMatrix { +interface IMatrix3f> : IMatrix, IFloatMatrix, ITransposable, ISquareMatrix { val c00: Float val c10: Float val c20: Float @@ -387,7 +389,7 @@ interface IMatrix3f> : IMatrix, IFloatMatrix, ITransposab /** * [Matrix4f] and [MutableMatrix4f] implement this */ -interface IMatrix4f> : IMatrix, IFloatMatrix, ITransposable, ISquareMatrix { +interface IMatrix4f> : IMatrix, IFloatMatrix, ITransposable, ISquareMatrix { val c00: Float val c10: Float val c20: Float diff --git a/src/kvector/kotlin/ru/dbotthepony/kvector/matrix/Matrix4fStack.kt b/src/kvector/kotlin/ru/dbotthepony/kvector/matrix/Matrix4fStack.kt new file mode 100644 index 00000000..1e0be0af --- /dev/null +++ b/src/kvector/kotlin/ru/dbotthepony/kvector/matrix/Matrix4fStack.kt @@ -0,0 +1,170 @@ +package ru.dbotthepony.kvector.matrix + +import ru.dbotthepony.kvector.api.IMatrixGetterFloat +import ru.dbotthepony.kvector.matrix.nfloat.MutableMatrix4f +import ru.dbotthepony.kvector.vector.nfloat.Vector3f +import ru.dbotthepony.kvector.vector.nfloat.Vector4f + +/** + * This class represent Matrix stack using [MutableMatrix4f]. It is useful for 3D + * rendering because it allows to create single stack, push new matrix in any + * applicable context, pass stack to all rendering methods which will further push + * transformation matrices, etc. + * + * All operations are mutating last matrix in stack. + */ +class Matrix4fStack { + private val stack = ArrayDeque() + + /** + * Last matrix in stack, you are free to modify it, + * but if you need to do contained modifications, such + * as inside your render subroutine (e.g. inside your entity drawer), + * please do use [push] first with no arguments, perform (render and) matrix operations, + * and then [pop] it. + * + * @return [MutableMatrix4f] + */ + val last get() = stack.last() + + init { + stack.add(MutableMatrix4f()) + } + + /** + * Pops last matrix from stack. + * + * @return this stack + */ + fun pop(): Matrix4fStack { + stack.removeLast() + return this + } + + /** + * Pushes matrix to stack. + * By default, pushes a copy of last matrix, which is desirable in most cases. + * + * @return this stack + */ + fun push(matrix: MutableMatrix4f = last.toMutableMatrix4f()): Matrix4fStack { + stack.add(matrix) + return this + } + + /** + * Clears stack and pushes specified [matrix4f] into it as first element. + * By default, pushes identity matrix. + * + * @return this stack + */ + fun clear(matrix4f: MutableMatrix4f = MutableMatrix4f()): Matrix4fStack { + stack.clear() + stack.add(matrix4f) + return this + } + + /** + * Calls [MutableMatrix4f.plusMut] on last matrix. + * + * @return this stack + */ + operator fun plus(other: IMatrixGetterFloat): Matrix4fStack { + last.plusMut(other) + return this + } + + /** + * Calls [MutableMatrix4f.minusMut] on last matrix. + * + * @return this stack + */ + operator fun minus(other: IMatrixGetterFloat): Matrix4fStack { + last.minusMut(other) + return this + } + + /** + * Calls [MutableMatrix4f.timesMut] on last matrix. + * + * @return this stack + */ + operator fun times(other: IMatrixGetterFloat): Matrix4fStack { + last.timesMut(other) + return this + } + + /** + * Calls [MutableMatrix4f.scaleMut] on last matrix. + * + * @return this stack + */ + fun scale(vector: Vector4f): Matrix4fStack { + last.scaleMut(vector) + return this + } + + /** + * Calls [MutableMatrix4f.scaleMut] on last matrix. + * This is a convenience function, as it just create new [Vector4f]. + * + * @return this stack + */ + fun scale(x: Float = 1f, y: Float = 1f, z: Float = 1f, w: Float = 1f): Matrix4fStack { + last.scaleMut(Vector4f(x, y, z, w)) + return this + } + + /** + * Calls [MutableMatrix4f.translate] on last matrix. + * + * @return this stack + */ + fun translate(vector: Vector3f): Matrix4fStack { + last.translateMut(vector) + return this + } + + /** + * Sets [MutableMatrix4f.translation] on last matrix. + * This is a convenience function, as it just create new [Vector3f]. + * + * @return this stack + */ + fun translate(x: Float = 0f, y: Float = 0f, z: Float = 0f): Matrix4fStack { + last.translateMut(Vector3f(x, y, z)) + return this + } + + /** + * Calls [MutableMatrix4f.translateWithMultiplicationMut] on last matrix. + * + * @return this stack + */ + fun translateWithMultiplication(vector: Vector3f): Matrix4fStack { + last.translateWithMultiplicationMut(vector) + return this + } + + /** + * Calls [MutableMatrix4f.translateWithMultiplicationMut] on last matrix. + * This is a convenience function, as it just create new [Vector3f]. + * + * @return this stack + */ + fun translateWithMultiplication(x: Float = 0f, y: Float = 0f, z: Float = 0f): Matrix4fStack { + last.translateWithMultiplicationMut(Vector3f(x, y, z)) + return this + } + + /** + * Removes last matrix from stack, and pushes [matrix] to stack. + * + * @return this stack + */ + fun replace(matrix: MutableMatrix4f): Matrix4fStack { + stack.removeLast() + stack.add(matrix) + return this + } +} diff --git a/src/kvector/kotlin/ru/dbotthepony/kvector/matrix/functions.kt b/src/kvector/kotlin/ru/dbotthepony/kvector/matrix/functions.kt index 8bf8599e..56df0de6 100644 --- a/src/kvector/kotlin/ru/dbotthepony/kvector/matrix/functions.kt +++ b/src/kvector/kotlin/ru/dbotthepony/kvector/matrix/functions.kt @@ -37,10 +37,10 @@ fun multiplyMatrix(matrix1: IMatrixGetterDouble, matrix2: IMatrixGetterDouble): var sum = 0.0 for (rowColumn in 0 until vectorized) { - sum += matrix1[row, rowColumn] * matrix2[rowColumn, column] + sum += matrix1[rowColumn, row] * matrix2[column, rowColumn] } - output[row, column] = sum + output[column, row] = sum } } @@ -75,10 +75,10 @@ fun multiplyMatrix(matrix1: IMatrixGetterFloat, matrix2: IMatrixGetterFloat): Fl var sum = 0f for (rowColumn in 0 until vectorized) { - sum += matrix1[row, rowColumn] * matrix2[rowColumn, column] + sum += matrix1[rowColumn, row] * matrix2[column, rowColumn] } - output[row, column] = sum + output[column, row] = sum } } @@ -113,10 +113,10 @@ fun multiplyMatrix(matrix1: IMatrixGetterInt, matrix2: IMatrixGetterInt): Int2Di var sum = 0 for (rowColumn in 0 until vectorized) { - sum += matrix1[row, rowColumn] * matrix2[rowColumn, column] + sum += matrix1[rowColumn, row] * matrix2[column, rowColumn] } - output[row, column] = sum + output[column, row] = sum } } @@ -151,10 +151,10 @@ fun multiplyMatrix(matrix1: IMatrixGetterLong, matrix2: IMatrixGetterLong): Long var sum = 0L for (rowColumn in 0 until vectorized) { - sum += matrix1[row, rowColumn] * matrix2[rowColumn, column] + sum += matrix1[rowColumn, row] * matrix2[column, rowColumn] } - output[row, column] = sum + output[column, row] = sum } } @@ -189,10 +189,10 @@ fun multiplyMatrix(matrix1: IMatrixGetterShort, matrix2: IMatrixGetterShort): Sh var sum = 0 for (rowColumn in 0 until vectorized) { - sum += matrix1[row, rowColumn] * matrix2[rowColumn, column] + sum += matrix1[rowColumn, row] * matrix2[column, rowColumn] } - output[row, column] = sum.toShort() + output[column, row] = sum.toShort() } } @@ -227,10 +227,10 @@ fun multiplyMatrix(matrix1: IMatrixGetterByte, matrix2: IMatrixGetterByte): Byte var sum = 0L for (rowColumn in 0 until vectorized) { - sum += matrix1[row, rowColumn] * matrix2[rowColumn, column] + sum += matrix1[rowColumn, row] * matrix2[column, rowColumn] } - output[row, column] = sum.toByte() + output[column, row] = sum.toByte() } } diff --git a/src/kvector/kotlin/ru/dbotthepony/kvector/matrix/ndouble/Matrix3d.kt b/src/kvector/kotlin/ru/dbotthepony/kvector/matrix/ndouble/Matrix3d.kt index e42ef346..8f4d992f 100644 --- a/src/kvector/kotlin/ru/dbotthepony/kvector/matrix/ndouble/Matrix3d.kt +++ b/src/kvector/kotlin/ru/dbotthepony/kvector/matrix/ndouble/Matrix3d.kt @@ -107,11 +107,11 @@ class Matrix3d : AbstractMatrixVd, IMatrix3d { ) } - override fun scale(vector: Vector2d): Matrix3d { + override fun scale(vector: Vector3d): Matrix3d { return rm( r00 * vector.x, r01, r02, r10, r11 * vector.y, r12, - r20, r21, r22 + r20, r21, r22 * vector.z ) } @@ -164,7 +164,7 @@ class Matrix3d : AbstractMatrixVd, IMatrix3d { * * Vectorized access use [MutableVector3d], generic interface is represented by [IMatrix3d]. */ -class MutableMatrix3d : AbstractMutableMatrixVd, IMatrix3d, IMutableSquareMatrix { +class MutableMatrix3d : AbstractMutableMatrixVd, IMatrix3d, IMutableSquareMatrix { constructor( c00: Double = 1.0, c01: Double = 0.0, c02: Double = 0.0, c10: Double = 0.0, c11: Double = 1.0, c12: Double = 0.0, @@ -198,9 +198,10 @@ class MutableMatrix3d : AbstractMutableMatrixVd, IMatrix3d, IMatrix3d, IMatrix3d, IMatrix4d { ) } - override fun scale(vector: Vector3d): Matrix4d { + override fun scale(vector: Vector4d): Matrix4d { return rm( r00 * vector.x, r01, r02, r03, r10, r11 * vector.y, r12, r13, r20, r21, r22 * vector.z, r23, - r30, r31, r32, r33, + r30, r31, r32, r33 * vector.w, ) } @@ -238,7 +238,7 @@ class Matrix4d : AbstractMatrixVd, IMatrix4d { * - Vectorized access has setter, and when writing [Vector4d] to it, it will update associated column/row values * */ -class MutableMatrix4d : AbstractMutableMatrixVd, IMatrix4d, IMutableSquareMatrix { +class MutableMatrix4d : AbstractMutableMatrixVd, IMatrix4d, IMutableSquareMatrix { constructor( c00: Double = 1.0, c01: Double = 0.0, c02: Double = 0.0, c03: Double = 0.0, c10: Double = 0.0, c11: Double = 1.0, c12: Double = 0.0, c13: Double = 0.0, @@ -292,12 +292,12 @@ class MutableMatrix4d : AbstractMutableMatrixVd, IMatrix4d, IMatrix4d, IMatrix4d> protected constructor( return factorize(adjugateMatrix(memory)) } + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + other as AbstractMatrixVd<*> + + if (other.columns != columns || other.rows != rows) { + return false + } + + for (column in 0 until columns) { + for (row in 0 until rows) { + if (memory[column, row] != other.memory[column, row]) { + return false + } + } + } + + return true + } + + override fun hashCode(): Int { + if (columns == 0 || rows == 0) { + return 0 + } + + var result = 0 + + for (column in 0 until columns) { + for (row in 0 until rows) { + result = 31 * result + memory[column, row].hashCode() + } + } + + return result + } + + override fun toString(): String { + val builder = StringBuilder("[\n") + + val strings = arrayOfNulls(columns * rows) + + var width = 0 + val columnWidths = IntArray(columns) + + for (column in 0 until columns) { + var columnWidth = 0 + + for (row in 0 until rows) { + strings[column + row * columns] = memory[row, column].toString() + columnWidth = columnWidth.coerceAtLeast(strings[column + row * columns]!!.length) + } + + columnWidths[column] = columnWidth + 1 + width += columnWidth + 1 + } + + for (row in 0 until rows) { + builder.append(" ") + + for (column in 0 until columns) { + builder.append(strings[column + row * columns]!!) + + if (column == columns - 1) { + builder.append(";") + } else { + builder.append(",") + } + + builder.append(" ".repeat(columnWidths[column] - strings[column + row * columns]!!.length)) + } + + builder.append("\n") + } + + builder.append("]") + + return builder.toString() + } } /** diff --git a/src/kvector/kotlin/ru/dbotthepony/kvector/matrix/nfloat/Matrix3f.kt b/src/kvector/kotlin/ru/dbotthepony/kvector/matrix/nfloat/Matrix3f.kt index 3b39c746..ec761399 100644 --- a/src/kvector/kotlin/ru/dbotthepony/kvector/matrix/nfloat/Matrix3f.kt +++ b/src/kvector/kotlin/ru/dbotthepony/kvector/matrix/nfloat/Matrix3f.kt @@ -109,11 +109,11 @@ class Matrix3f : AbstractMatrixVf, IMatrix3f { ) } - override fun scale(vector: Vector2f): Matrix3f { + override fun scale(vector: Vector3f): Matrix3f { return rm( r00 * vector.x, r01, r02, r10, r11 * vector.y, r12, - r20, r21, r22 + r20, r21, r22 * vector.z ) } @@ -166,7 +166,7 @@ class Matrix3f : AbstractMatrixVf, IMatrix3f { * * Vectorized access use [MutableVector3f], generic interface is represented by [IMatrix3f]. */ -class MutableMatrix3f : AbstractMutableMatrixVf, IMutableSquareMatrix, IMatrix3f { +class MutableMatrix3f : AbstractMutableMatrixVf, IMutableSquareMatrix, IMatrix3f { constructor( c00: Float = 1f, c01: Float = 0f, c02: Float = 0f, c10: Float = 0f, c11: Float = 1f, c12: Float = 0f, @@ -200,9 +200,16 @@ class MutableMatrix3f : AbstractMutableMatrixVf, IMutableSquare return this } - override fun scaleMut(vector: Vector2f): MutableMatrix3f { + override fun scaleMut(vector: Vector3f): MutableMatrix3f { r00 *= vector.x r11 *= vector.y + r22 *= vector.z + return this + } + + override fun translateMut(vector: Vector2f): MutableMatrix3f { + r02 += vector.x + r12 += vector.y return this } @@ -355,11 +362,11 @@ class MutableMatrix3f : AbstractMutableMatrixVf, IMutableSquare ) } - override fun scale(vector: Vector2f): MutableMatrix3f { + override fun scale(vector: Vector3f): MutableMatrix3f { return rm( r00 * vector.x, r01, r02, r10, r11 * vector.y, r12, - r20, r21, r22 + r20, r21, r22 * vector.z ) } diff --git a/src/kvector/kotlin/ru/dbotthepony/kvector/matrix/nfloat/Matrix4f.kt b/src/kvector/kotlin/ru/dbotthepony/kvector/matrix/nfloat/Matrix4f.kt index 25566e7f..b9a2b665 100644 --- a/src/kvector/kotlin/ru/dbotthepony/kvector/matrix/nfloat/Matrix4f.kt +++ b/src/kvector/kotlin/ru/dbotthepony/kvector/matrix/nfloat/Matrix4f.kt @@ -9,6 +9,7 @@ import ru.dbotthepony.kvector.matrix.ndouble.Matrix4d import ru.dbotthepony.kvector.matrix.ndouble.MutableMatrix4d import ru.dbotthepony.kvector.narray.Float2Dimensional import ru.dbotthepony.kvector.vector.nfloat.* +import kotlin.math.tan /** * Represents immutable concrete matrix with 4x4 dimensions, storing values as [Float]s. @@ -150,12 +151,12 @@ class Matrix4f : AbstractMatrixVf, IMatrix4f { ) } - override fun scale(vector: Vector3f): Matrix4f { + override fun scale(vector: Vector4f): Matrix4f { return rm( r00 * vector.x, r01, r02, r03, r10, r11 * vector.y, r12, r13, r20, r21, r22 * vector.z, r23, - r30, r31, r32, r33, + r30, r31, r32, r33 * vector.w, ) } @@ -201,6 +202,52 @@ class Matrix4f : AbstractMatrixVf, IMatrix4f { * Main diagonal of this matrix is 1s */ @JvmField val IDENTITY = Matrix4f() + + /** + * Returns new ortho projection matrix, with Y coordinate inverted (useful for OpenGL GUI drawing). + * + * Inversion of Y means that X 0 Y 0 will be top left position on screen (in OpenGL), not bottom left. + */ + fun ortho(left: Float, right: Float, bottom: Float, top: Float, zNear: Float, zFar: Float): Matrix4f { + return rm( + r00 = 2f / (right - left), + r11 = -2f / (top - bottom), + r22 = 2f / (zFar - zNear), + r03 = -(right + left) / (right - left), + r13 = -(top + bottom) / (top - bottom) + 2f, + r23 = -(zFar + zNear) / (zFar - zNear) + ) + } + + /** + * Returns new ortho projection matrix. + */ + fun orthoDirect(left: Float, right: Float, bottom: Float, top: Float, zNear: Float, zFar: Float): Matrix4f { + return rm( + r00 = 2f / (right - left), + r11 = 2f / (top - bottom), + r22 = 2f / (zFar - zNear), + r03 = -(right + left) / (right - left), + r13 = -(top + bottom) / (top - bottom), + r23 = -(zFar + zNear) / (zFar - zNear) + ) + } + + /** + * Returns new perspective matrix + */ + fun perspective(fov: Float, zFar: Float, zNear: Float): Matrix4f { + val scale = (1.0 / (tan(Math.toRadians(fov.toDouble()) / 2.0))).toFloat() + val r = zFar - zNear + + return rm( + r00 = scale, + r11 = scale, + r22 = -zFar / r, + r23 = -1f, + r32 = -zFar * zNear / r, + ) + } } } @@ -211,7 +258,7 @@ class Matrix4f : AbstractMatrixVf, IMatrix4f { * * Vectorized access use [MutableVector4f], generic interface is represented by [IMatrix4f]. */ -class MutableMatrix4f : AbstractMutableMatrixVf, IMatrix4f, IMutableSquareMatrix { +class MutableMatrix4f : AbstractMutableMatrixVf, IMatrix4f, IMutableSquareMatrix { constructor( c00: Float = 1f, c01: Float = 0f, c02: Float = 0f, c03: Float = 0f, c10: Float = 0f, c11: Float = 1f, c12: Float = 0f, c13: Float = 0f, @@ -257,6 +304,13 @@ class MutableMatrix4f : AbstractMutableMatrixVf, IMatrix4f, IMatrix4f, IMatrix4f, IMatrix4f> protected constructor( return factorize(adjugateMatrix(memory)) } + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + other as AbstractMatrixVf<*> + + if (other.columns != columns || other.rows != rows) { + return false + } + + for (column in 0 until columns) { + for (row in 0 until rows) { + if (memory[column, row] != other.memory[column, row]) { + return false + } + } + } + + return true + } + + override fun hashCode(): Int { + if (columns == 0 || rows == 0) { + return 0 + } + + var result = 0 + + for (column in 0 until columns) { + for (row in 0 until rows) { + result = 31 * result + memory[column, row].hashCode() + } + } + + return result + } + + override fun toString(): String { + val builder = StringBuilder("[\n") + + val strings = arrayOfNulls(columns * rows) + + var width = 0 + val columnWidths = IntArray(columns) + + for (column in 0 until columns) { + var columnWidth = 0 + + for (row in 0 until rows) { + strings[column + row * columns] = memory[row, column].toString() + columnWidth = columnWidth.coerceAtLeast(strings[column + row * columns]!!.length) + } + + columnWidths[column] = columnWidth + 1 + width += columnWidth + 1 + } + + for (row in 0 until rows) { + builder.append(" ") + + for (column in 0 until columns) { + builder.append(strings[column + row * columns]!!) + + if (column == columns - 1) { + builder.append(";") + } else { + builder.append(",") + } + + builder.append(" ".repeat(columnWidths[column] - strings[column + row * columns]!!.length)) + } + + builder.append("\n") + } + + builder.append("]") + + return builder.toString() + } } /** diff --git a/src/kvector/kotlin/ru/dbotthepony/kvector/util2d/AABB.kt b/src/kvector/kotlin/ru/dbotthepony/kvector/util2d/AABB.kt new file mode 100644 index 00000000..c690b5d1 --- /dev/null +++ b/src/kvector/kotlin/ru/dbotthepony/kvector/util2d/AABB.kt @@ -0,0 +1,475 @@ + +@file:Suppress("unused") + +package ru.dbotthepony.kvector.util2d + +import ru.dbotthepony.kvector.api.IStruct2d +import ru.dbotthepony.kvector.vector.ndouble.Vector2d +import ru.dbotthepony.kvector.vector.nint.Vector2i +import kotlin.math.absoluteValue + +data class IntersectionTime( + val invEntry: Vector2d, + val invExit: Vector2d, + val entry: Vector2d, + val exit: Vector2d, +) { + companion object { + val ZERO = IntersectionTime(Vector2d.ZERO, Vector2d.ZERO, Vector2d.ZERO, Vector2d.ZERO) + } +} + +data class SweepResult( + val normal: Vector2d, + val collisionTime: Double, + val intersectionTime: IntersectionTime +) { + companion object { + val ZERO = SweepResult(Vector2d.ZERO, 1.0, IntersectionTime.ZERO) + val INTERSECT = SweepResult(Vector2d.ZERO, 0.0, IntersectionTime.ZERO) + } +} + +/** + * Axis Aligned Bounding Box, represented by two points, [mins] as lowermost corner of BB, + * and [maxs] as uppermost corner of BB + */ +data class AABB(val mins: Vector2d, val maxs: Vector2d) { + init { + require(mins.x <= maxs.x) { "mins.x ${mins.x} is more than maxs.x ${maxs.x}" } + require(mins.y <= maxs.y) { "mins.y ${mins.y} is more than maxs.y ${maxs.y}" } + } + + operator fun plus(other: AABB) = AABB(mins + other.mins, maxs + other.maxs) + operator fun minus(other: AABB) = AABB(mins - other.mins, maxs - other.maxs) + operator fun times(other: AABB) = AABB(mins * other.mins, maxs * other.maxs) + operator fun div(other: AABB) = AABB(mins / other.mins, maxs / other.maxs) + + operator fun plus(other: Vector2d) = AABB(mins + other, maxs + other) + operator fun minus(other: Vector2d) = AABB(mins - other, maxs - other) + operator fun times(other: Vector2d) = AABB(mins * other, maxs * other) + operator fun div(other: Vector2d) = AABB(mins / other, maxs / other) + + operator fun times(other: Double) = AABB(mins * other, maxs * other) + operator fun div(other: Double) = AABB(mins / other, maxs / other) + + val xSpan get() = maxs.x - mins.x + val ySpan get() = maxs.y - mins.y + val centre get() = (mins + maxs) * 0.5 + + val A get() = mins + val B get() = Vector2d(mins.x, maxs.y) + val C get() = maxs + val D get() = Vector2d(maxs.x, mins.y) + + val bottomLeft get() = A + val topLeft get() = B + val topRight get() = C + val bottomRight get() = D + + val width get() = maxs.x - mins.x + val height get() = maxs.y - mins.y + + val extents get() = Vector2d(width * 0.5, height * 0.5) + + val diameter get() = mins.distance(maxs) + val radius get() = diameter / 2.0 + + val perimeter get() = (xSpan + ySpan) * 2.0 + + fun isInside(point: Vector2d): Boolean { + return point.x in mins.x .. maxs.x && point.y in mins.y .. maxs.y + } + + /** + * Checks whenever is this AABB intersect with [other] + * + * This method consider they intersect even if only one of axis are equal + */ + fun intersect(other: AABB): Boolean { + val intersectX: Boolean + + if (xSpan <= other.xSpan) + intersectX = mins.x in other.mins.x .. other.maxs.x || maxs.x in other.mins.x .. other.maxs.x + else + intersectX = other.mins.x in mins.x .. maxs.x || other.maxs.x in mins.x .. maxs.x + + if (!intersectX) + return false + + val intersectY: Boolean + + if (ySpan <= other.ySpan) + intersectY = mins.y in other.mins.y .. other.maxs.y || maxs.y in other.mins.y .. other.maxs.y + else + intersectY = other.mins.y in mins.y .. maxs.y || other.maxs.y in mins.y .. maxs.y + + return intersectY + } + + /** + * Returns whenever [other] is contained (encased) inside this AABB + */ + fun contains(other: AABB): Boolean { + if (xSpan < other.xSpan || ySpan < other.ySpan) + return false + + return other.mins.x in mins.x .. maxs.x && + other.maxs.x in mins.x .. maxs.x && + other.mins.y in mins.y .. maxs.y && + other.maxs.y in mins.y .. maxs.y + } + + /** + * Есть ли пересечение между этим AABB и [other] + * + * Считается, что они НЕ пересекаются, если у них просто равна одна из осей + */ + fun intersectWeak(other: AABB): Boolean { + if (maxs.x == other.mins.x || mins.x == other.maxs.x || maxs.y == other.mins.y || mins.y == other.maxs.y) + return false + + val intersectX: Boolean + + if (xSpan <= other.xSpan) + intersectX = mins.x in other.mins.x .. other.maxs.x || maxs.x in other.mins.x .. other.maxs.x + else + intersectX = other.mins.x in mins.x .. maxs.x || other.maxs.x in mins.x .. maxs.x + + if (!intersectX) + return false + + val intersectY: Boolean + + if (ySpan <= other.ySpan) + intersectY = mins.y in other.mins.y .. other.maxs.y || maxs.y in other.mins.y .. other.maxs.y + else + intersectY = other.mins.y in mins.y .. maxs.y || other.maxs.y in mins.y .. maxs.y + + return intersectY + } + + fun intersectionDepth(other: AABB): Vector2d { + val xDepth: Double + val yDepth: Double + + val thisCentre = centre + val otherCentre = other.centre + + if (thisCentre.x > otherCentre.x) { + // считаем, что мы вошли справа + xDepth = mins.x - other.maxs.x + } else { + // считаем, что мы вошли слева + xDepth = maxs.x - other.mins.x + } + + if (thisCentre.y > otherCentre.y) { + // считаем, что мы вошли сверху + yDepth = mins.y - other.maxs.y + } else { + // считаем, что мы вошли снизу + yDepth = maxs.x - other.mins.x + } + + return Vector2d(xDepth, yDepth) + } + + fun distance(other: AABB): Double { + val intersectX: Boolean + val intersectY: Boolean + + if (ySpan <= other.ySpan) + intersectY = mins.y in other.mins.y .. other.maxs.y || maxs.y in other.mins.y .. other.maxs.y + else + intersectY = other.mins.y in mins.y .. maxs.y || other.maxs.y in mins.y .. maxs.y + + if (xSpan <= other.xSpan) + intersectX = mins.x in other.mins.x .. other.maxs.x || maxs.x in other.mins.x .. other.maxs.x + else + intersectX = other.mins.x in mins.x .. maxs.x || other.maxs.x in mins.x .. maxs.x + + if (intersectY && intersectX) { + return 0.0 + } + + if (intersectX) { + return (mins.y - other.maxs.y).absoluteValue.coerceAtMost((maxs.y - other.mins.y).absoluteValue) + } else { + return (mins.x - other.maxs.x).absoluteValue.coerceAtMost((maxs.x - other.mins.x).absoluteValue) + } + } + + fun pushOutFrom(other: AABB): Vector2d { + if (!intersect(other)) + return Vector2d.ZERO + + val depth = intersectionDepth(other) + + if (depth.x.absoluteValue < depth.y.absoluteValue) { + return Vector2d(x = depth.x) + } else { + return Vector2d(y = depth.y) + } + } + + /** + * Рассчитывает "время" пересечения + * + * https://www.gamedev.net/tutorials/programming/general-and-gameplay-programming/swept-aabb-collision-detection-and-response-r3084/ + * + * Исправленный комментатором той же статьи от hypernewbie + */ + fun intersectionTime(other: AABB, velocity: Vector2d): IntersectionTime { + val xInvEntry: Double + val yInvEntry: Double + val xInvExit: Double + val yInvExit: Double + + if (velocity.x > 0.0) { + xInvEntry = other.mins.x - maxs.x + xInvExit = other.maxs.x - mins.x + } else { + xInvEntry = other.maxs.x - mins.x + xInvExit = other.mins.x - maxs.x + } + + if (velocity.y > 0.0) { + yInvEntry = other.mins.y - maxs.y + yInvExit = other.maxs.y - mins.y + } else { + yInvEntry = other.maxs.y - mins.y + yInvExit = other.mins.y - maxs.y + } + + var xEntry: Double + var yEntry: Double + val xExit: Double + val yExit: Double + + if (velocity.x == 0.0) { + xEntry = Double.NEGATIVE_INFINITY + xExit = Double.POSITIVE_INFINITY + } else { + xEntry = xInvEntry / velocity.x + xExit = xInvExit / velocity.x + } + + if (velocity.y == 0.0) { + yEntry = Double.NEGATIVE_INFINITY + yExit = Double.POSITIVE_INFINITY + } else { + yEntry = yInvEntry / velocity.y + yExit = yInvExit / velocity.y + } + + if (yEntry > 1.0) yEntry = Double.NEGATIVE_INFINITY + if (xEntry > 1.0) xEntry = Double.NEGATIVE_INFINITY + + return IntersectionTime( + Vector2d(xInvEntry, yInvEntry), + Vector2d(xInvExit, yInvExit), + Vector2d(xEntry, yEntry), + Vector2d(xExit, yExit), + ) + } + + /** + * Рассчитывает нормаль пересечения и процент пути ("время"), на котором произошло столкновение. + * + * Если столкновение не произошло, то возвращается [SweepResult.ZERO] + * + * Внимание: Если пересечение уже произошло (т.е. другой AABB пересекается с this), то данный метод + * вернёт заведомо ложный результат (т.е. "нет пересечения") + * + * https://www.gamedev.net/tutorials/programming/general-and-gameplay-programming/swept-aabb-collision-detection-and-response-r3084/ + * + * Исправленный комментатором той же статьи от hypernewbie + */ + fun sweep(other: AABB, velocity: Vector2d): SweepResult { + val time = intersectionTime(other, velocity) + val (near, far, entry, exit) = time + val (xEntry, yEntry) = entry + val (xExit, yExit) = exit + + val entryTime = xEntry.coerceAtLeast(yEntry) + val exitTime = xExit.coerceAtLeast(yExit) + + // гарантированно нет столкновения + if (entryTime > exitTime || xEntry < 0.0 && yEntry < 0.0) { + return SweepResult.ZERO + } + + if (xEntry < 0.0) { + if (maxs.x < other.mins.x || mins.x > other.maxs.x) + return SweepResult.ZERO + } + + if (yEntry < 0.0) { + if (maxs.y < other.mins.y || mins.y > other.maxs.y) + return SweepResult.ZERO + } + + val (xInvEntry, yInvEntry) = near + val normal: Vector2d + + if (xEntry > yEntry) { + if (xInvEntry <= 0.0) { // исправление от меня: <= для тех случаев, когда мы уже на той же оси + normal = Vector2d.POSITIVE_X + } else { + normal = Vector2d.NEGATIVE_X + } + } else { + if (yInvEntry <= 0.0) { // исправление от меня: <= для тех случаев, когда мы уже на той же оси + normal = Vector2d.POSITIVE_Y + } else { + normal = Vector2d.NEGATIVE_Y + } + } + + return SweepResult(normal, entryTime, time) + } + + /** + * Рассчитывает нормаль пересечения и процент пути ("время"), на котором произошло столкновение. + * + * Если столкновение не произошло, то возвращается [SweepResult.ZERO] + * + * Если данный AABB уже столкнулся с [other], возвращается [SweepResult.INTERSECT] + * + * https://www.gamedev.net/tutorials/programming/general-and-gameplay-programming/swept-aabb-collision-detection-and-response-r3084/ + */ + fun safeSweep(other: AABB, velocity: Vector2d): SweepResult { + if (intersect(other)) { + return SweepResult.INTERSECT + } + + return sweep(other, velocity) + } + + /** + * Возвращает AABB, который содержит в себе оба AABB + */ + fun combine(other: AABB): AABB { + val minX = mins.x.coerceAtMost(other.mins.x) + val minY = mins.y.coerceAtMost(other.mins.y) + val maxX = maxs.x.coerceAtLeast(other.maxs.x) + val maxY = maxs.y.coerceAtLeast(other.maxs.y) + + return AABB(Vector2d(minX, minY), Vector2d(maxX, maxY)) + } + + companion object { + fun rectangle(pos: IStruct2d, width: Double, height: Double = width): AABB { + val (x, y) = pos + + return AABB( + Vector2d(x - width / 2.0, y - height / 2.0), + Vector2d(x + width / 2.0, y + height / 2.0), + ) + } + } +} + +data class AABBi(val mins: Vector2i, val maxs: Vector2i) { + init { + require(mins.x <= maxs.x) { "mins.x ${mins.x} is more than maxs.x ${maxs.x}" } + require(mins.y <= maxs.y) { "mins.y ${mins.y} is more than maxs.y ${maxs.y}" } + } + + operator fun plus(other: AABBi) = AABBi(mins + other.mins, maxs + other.maxs) + operator fun minus(other: AABBi) = AABBi(mins - other.mins, maxs - other.maxs) + operator fun times(other: AABBi) = AABBi(mins * other.mins, maxs * other.maxs) + operator fun div(other: AABBi) = AABBi(mins / other.mins, maxs / other.maxs) + + operator fun plus(other: Vector2i) = AABBi(mins + other, maxs + other) + operator fun minus(other: Vector2i) = AABBi(mins - other, maxs - other) + operator fun times(other: Vector2i) = AABBi(mins * other, maxs * other) + operator fun div(other: Vector2i) = AABBi(mins / other, maxs / other) + + operator fun times(other: Int) = AABBi(mins * other, maxs * other) + operator fun div(other: Int) = AABBi(mins / other, maxs / other) + + val xSpan get() = maxs.x - mins.x + val ySpan get() = maxs.y - mins.y + val centre get() = (mins.toDoubleVector() + maxs.toDoubleVector()) * 0.5 + + val A get() = mins + val B get() = Vector2i(mins.x, maxs.y) + val C get() = maxs + val D get() = Vector2i(maxs.x, mins.y) + + val bottomLeft get() = A + val topLeft get() = B + val topRight get() = C + val bottomRight get() = D + + val width get() = (maxs.x - mins.x) / 2 + val height get() = (maxs.y - mins.y) / 2 + + val diameter get() = mins.distance(maxs) + val radius get() = diameter / 2.0 + + val perimeter get() = (xSpan + ySpan) * 2 + + fun isInside(point: Vector2i): Boolean { + return point.x in mins.x .. maxs.x && point.y in mins.y .. maxs.y + } + + /** + * Есть ли пересечение между этим AABB и [other] + * + * Считается, что они пересекаются, даже если у них просто равна одна из осей + */ + fun intersect(other: AABBi): Boolean { + val intersectX: Boolean + + if (xSpan <= other.xSpan) + intersectX = mins.x in other.mins.x .. other.maxs.x || maxs.x in other.mins.x .. other.maxs.x + else + intersectX = other.mins.x in mins.x .. maxs.x || other.maxs.x in mins.x .. maxs.x + + if (!intersectX) + return false + + val intersectY: Boolean + + if (ySpan <= other.ySpan) + intersectY = mins.y in other.mins.y .. other.maxs.y || maxs.y in other.mins.y .. other.maxs.y + else + intersectY = other.mins.y in mins.y .. maxs.y || other.maxs.y in mins.y .. maxs.y + + return intersectY + } + + /** + * Есть ли пересечение между этим AABB и [other] + * + * Считается, что они НЕ пересекаются, если у них просто равна одна из осей + */ + fun intersectWeak(other: AABBi): Boolean { + if (maxs.x == other.mins.x || mins.x == other.maxs.x || maxs.y == other.mins.y || mins.y == other.maxs.y) + return false + + val intersectX: Boolean + + if (xSpan <= other.xSpan) + intersectX = mins.x in other.mins.x .. other.maxs.x || maxs.x in other.mins.x .. other.maxs.x + else + intersectX = other.mins.x in mins.x .. maxs.x || other.maxs.x in mins.x .. maxs.x + + if (!intersectX) + return false + + val intersectY: Boolean + + if (ySpan <= other.ySpan) + intersectY = mins.y in other.mins.y .. other.maxs.y || maxs.y in other.mins.y .. other.maxs.y + else + intersectY = other.mins.y in mins.y .. maxs.y || other.maxs.y in mins.y .. maxs.y + + return intersectY + } + + fun toDoubleAABB() = AABB(mins.toDoubleVector(), maxs.toDoubleVector()) +} diff --git a/src/kvector/kotlin/ru/dbotthepony/kvector/vector/Color.kt b/src/kvector/kotlin/ru/dbotthepony/kvector/vector/Color.kt new file mode 100644 index 00000000..d27ed965 --- /dev/null +++ b/src/kvector/kotlin/ru/dbotthepony/kvector/vector/Color.kt @@ -0,0 +1,46 @@ +package ru.dbotthepony.kvector.vector + +import ru.dbotthepony.kvector.api.IStruct4f +import ru.dbotthepony.kvector.vector.nfloat.Vector4f +import java.util.Collections + +/** + * Represents RGBA color in [0, 1] range using [Float]. + */ +class Color(r: Float, g: Float, b: Float, a: Float = 1f) : Vector4f(r, g, b, a) { + constructor(input: IStruct4f) : this(input.component1(), input.component2(), input.component3(), input.component4()) + + constructor(input: Int) : this( + ((input ushr 16) and 0xFF).toFloat() / 255f, + ((input ushr 8) and 0xFF).toFloat() / 255f, + (input and 0xFF).toFloat() / 255f, + ) + + fun copy(r: Float = this.r, g: Float = this.g, b: Float = this.b, a: Float = this.a): Color { + return Color(r, g, b, a) + } + + companion object { + val WHITE = Color(1f, 1f, 1f) + + val RED = Color(1f, 0f, 0f) + val GREEN = Color(0f, 1f, 0f) + val BLUE = Color(0f, 0f, 1f) + + val SLATE_GREY = Color(0.2f, 0.2f, 0.2f) + + val PRE_DEFINED_MAP = mapOf( + "red" to RED, + "green" to GREEN, + "blue" to BLUE, + ) + + val SHADES_OF_GRAY = ArrayList().let { + for (i in 0 .. 256) { + it.add(Color(i / 256f, i / 256f, i / 256f)) + } + + return@let Collections.unmodifiableList(it) as List + } + } +} diff --git a/src/kvector/kotlin/ru/dbotthepony/kvector/vector/ndouble/Vector2d.kt b/src/kvector/kotlin/ru/dbotthepony/kvector/vector/ndouble/Vector2d.kt index 10c4a3ee..5973184d 100644 --- a/src/kvector/kotlin/ru/dbotthepony/kvector/vector/ndouble/Vector2d.kt +++ b/src/kvector/kotlin/ru/dbotthepony/kvector/vector/ndouble/Vector2d.kt @@ -6,8 +6,6 @@ package ru.dbotthepony.kvector.vector.ndouble import ru.dbotthepony.kvector.api.* import ru.dbotthepony.kvector.vector.nfloat.Vector2f import kotlin.math.absoluteValue -import kotlin.math.pow -import kotlin.math.sqrt /** * 2D Vector, representing two-dimensional coordinates as [Double]s @@ -126,14 +124,14 @@ open class Vector2d( } /** - * Calculates vector vector * vector, returning result as [Double] + * Calculates vector vector * vector, returning result as [Double]. */ fun cross(other: Vector2d): Double { return x * other.y - y * other.x } /** - * Calculates 2D cross product between scalar and vector + * Calculates 2D cross product between scalar and vector. * * @return new vector */ @@ -142,21 +140,31 @@ open class Vector2d( } /** - * Calculates scalar vector * vector, returning result as [Double] + * Calculates scalar vector * vector, returning result as [Double], + * but using sine instead of cosine. + * + * See [dot] and this method code for better explanation. + */ + fun pseudoDot(other: Vector2d): Double { + return other.x * y + other.y * x + } + + /** + * Calculates scalar vector * vector, returning result as [Double]. */ fun dot(other: Vector2d): Double { return other.x * x + other.y * y } /** - * Calculates scalar vector * vector, returning result as [Double] + * Calculates scalar vector * vector, returning result as [Double]. */ fun dot(other: Vector3d): Double { return other.x * x + other.y * y } /** - * Calculates scalar vector * vector, returning result as [Double] + * Calculates scalar vector * vector, returning result as [Double]. */ fun dot(other: Vector4d): Double { return other.x * x + other.y * y @@ -189,6 +197,13 @@ open class Vector2d( return 31 * x.hashCode() + y.hashCode() } + /** + * Returns copy of this vector as [MutableVector2d] + */ + fun toMutableVector(): MutableVector2d { + return MutableVector2d(x, y) + } + inline val xx get() = Vector2d(x, x) inline val xy get() = Vector2d(x, y) inline val yx get() = Vector2d(y, x) @@ -280,14 +295,17 @@ open class Vector2d( @JvmField val NEGATIVE_X = Vector2d(x = -1.0) @JvmField val POSITIVE_Y = Vector2d(y = 1.0) @JvmField val NEGATIVE_Y = Vector2d(y = -1.0) + + @JvmField val POSITIVE_XY = Vector2d(1.0, 1.0) + @JvmField val NEGATIVE_XY = Vector2d(-1.0, -1.0) } } -fun Double.div(other: Vector2d): Vector2d { +operator fun Double.div(other: Vector2d): Vector2d { return Vector2d(this / other.x, this / other.y) } -fun Double.times(other: Vector2d): Vector2d { +operator fun Double.times(other: Vector2d): Vector2d { return Vector2d(this * other.x, this * other.y) } @@ -404,4 +422,11 @@ open class MutableVector2d( this.y = -other * x return this } + + /** + * Returns copy of this vector as [Vector2d] + */ + fun toVector(): Vector2d { + return Vector2d(x, y) + } } diff --git a/src/kvector/kotlin/ru/dbotthepony/kvector/vector/ndouble/Vector3d.kt b/src/kvector/kotlin/ru/dbotthepony/kvector/vector/ndouble/Vector3d.kt index e4b2b535..7192a140 100644 --- a/src/kvector/kotlin/ru/dbotthepony/kvector/vector/ndouble/Vector3d.kt +++ b/src/kvector/kotlin/ru/dbotthepony/kvector/vector/ndouble/Vector3d.kt @@ -549,11 +549,11 @@ open class Vector3d( } } -fun Double.div(other: Vector3d): Vector3d { +operator fun Double.div(other: Vector3d): Vector3d { return Vector3d(this / other.x, this / other.y, this / other.z) } -fun Double.times(other: Vector3d): Vector3d { +operator fun Double.times(other: Vector3d): Vector3d { return Vector3d(this * other.x, this * other.y, this * other.z) } diff --git a/src/kvector/kotlin/ru/dbotthepony/kvector/vector/ndouble/Vector4d.kt b/src/kvector/kotlin/ru/dbotthepony/kvector/vector/ndouble/Vector4d.kt index d1c28fb2..85c9c2a4 100644 --- a/src/kvector/kotlin/ru/dbotthepony/kvector/vector/ndouble/Vector4d.kt +++ b/src/kvector/kotlin/ru/dbotthepony/kvector/vector/ndouble/Vector4d.kt @@ -1242,11 +1242,11 @@ open class Vector4d( } } -fun Double.div(other: Vector4d): Vector4d { +operator fun Double.div(other: Vector4d): Vector4d { return Vector4d(this / other.x, this / other.y, this / other.z, this / other.w) } -fun Double.times(other: Vector4d): Vector4d { +operator fun Double.times(other: Vector4d): Vector4d { return Vector4d(this * other.x, this * other.y, this * other.z, this * other.w) } diff --git a/src/kvector/kotlin/ru/dbotthepony/kvector/vector/nfloat/Vector2f.kt b/src/kvector/kotlin/ru/dbotthepony/kvector/vector/nfloat/Vector2f.kt index c2c5ba5c..cb92d2b0 100644 --- a/src/kvector/kotlin/ru/dbotthepony/kvector/vector/nfloat/Vector2f.kt +++ b/src/kvector/kotlin/ru/dbotthepony/kvector/vector/nfloat/Vector2f.kt @@ -173,24 +173,34 @@ open class Vector2f( } /** - * Calculates scalar vector * vector, returning result as [Double] + * Calculates scalar vector * vector, returning result as [Float], + * but using sine instead of cosine. + * + * See [dot] and this method code for better explanation. */ - fun dot(other: Vector2f): Double { - return other.x.toDouble() * x.toDouble() + other.y.toDouble() * y.toDouble() + fun pseudoDot(other: Vector2f): Float { + return other.x * y + other.y * x } /** - * Calculates scalar vector * vector, returning result as [Double] + * Calculates scalar vector * vector, returning result as [Float] */ - fun dot(other: Vector3f): Double { - return other.x.toDouble() * x.toDouble() + other.y.toDouble() * y.toDouble() + fun dot(other: Vector2f): Float { + return other.x * x + other.y * y } /** - * Calculates scalar vector * vector, returning result as [Double] + * Calculates scalar vector * vector, returning result as [Float] */ - fun dot(other: Vector4f): Double { - return other.x.toDouble() * x.toDouble() + other.y.toDouble() * y.toDouble() + fun dot(other: Vector3f): Float { + return other.x * x + other.y * y + } + + /** + * Calculates scalar vector * vector, returning result as [Float] + */ + fun dot(other: Vector4f): Float { + return other.x * x + other.y * y } /** @@ -291,6 +301,9 @@ open class Vector2f( @JvmField val NEGATIVE_X = Vector2f(x = -1f) @JvmField val POSITIVE_Y = Vector2f(y = 1f) @JvmField val NEGATIVE_Y = Vector2f(y = -1f) + + @JvmField val POSITIVE_XY = Vector2f(1f, 1f) + @JvmField val NEGATIVE_XY = Vector2f(-1f, -1f) } } diff --git a/src/kvector/kotlin/ru/dbotthepony/kvector/vector/nfloat/Vector3f.kt b/src/kvector/kotlin/ru/dbotthepony/kvector/vector/nfloat/Vector3f.kt index a6a51844..2c712869 100644 --- a/src/kvector/kotlin/ru/dbotthepony/kvector/vector/nfloat/Vector3f.kt +++ b/src/kvector/kotlin/ru/dbotthepony/kvector/vector/nfloat/Vector3f.kt @@ -147,24 +147,24 @@ open class Vector3f( } /** - * Calculates scalar vector * vector, returning result as [Double] + * Calculates scalar vector * vector, returning result as [Float] */ - fun dot(other: Vector4f): Double { - return other.x.toDouble() * x.toDouble() + other.y.toDouble() * y.toDouble() + other.z.toDouble() * z.toDouble() + fun dot(other: Vector4f): Float { + return other.x * x + other.y * y + other.z * z } /** - * Calculates scalar vector * vector, returning result as [Double] + * Calculates scalar vector * vector, returning result as [Float] */ - fun dot(other: Vector3f): Double { - return other.x.toDouble() * x.toDouble() + other.y.toDouble() * y.toDouble() + other.z.toDouble() * z.toDouble() + fun dot(other: Vector3f): Float { + return other.x * x + other.y * y + other.z * z } /** - * Calculates scalar vector * vector, returning result as [Double] + * Calculates scalar vector * vector, returning result as [Float] */ - fun dot(other: Vector2f): Double { - return other.x.toDouble() * x.toDouble() + other.y.toDouble() * y.toDouble() + fun dot(other: Vector2f): Float { + return other.x * x + other.y * y } /** diff --git a/src/kvector/kotlin/ru/dbotthepony/kvector/vector/nfloat/Vector4f.kt b/src/kvector/kotlin/ru/dbotthepony/kvector/vector/nfloat/Vector4f.kt index 6c9578d8..6369bb1b 100644 --- a/src/kvector/kotlin/ru/dbotthepony/kvector/vector/nfloat/Vector4f.kt +++ b/src/kvector/kotlin/ru/dbotthepony/kvector/vector/nfloat/Vector4f.kt @@ -165,24 +165,24 @@ open class Vector4f( } /** - * Calculates scalar vector * vector, returning result as [Double] + * Calculates scalar vector * vector, returning result as [Float] */ - fun dot(other: Vector4f): Double { - return other.x.toDouble() * x.toDouble() + other.y.toDouble() * y.toDouble() + other.z.toDouble() * z.toDouble() + other.w.toDouble() * w.toDouble() + fun dot(other: Vector4f): Float { + return other.x * x + other.y * y + other.z * z + other.w * w } /** - * Calculates scalar vector * vector, returning result as [Double] + * Calculates scalar vector * vector, returning result as [Float] */ - fun dot(other: Vector3f): Double { - return other.x.toDouble() * x.toDouble() + other.y.toDouble() * y.toDouble() + other.z.toDouble() * z.toDouble() + fun dot(other: Vector3f): Float { + return other.x * x + other.y * y + other.z * z } /** - * Calculates scalar vector * vector, returning result as [Double] + * Calculates scalar vector * vector, returning result as [Float] */ - fun dot(other: Vector2f): Double { - return other.x.toDouble() * x.toDouble() + other.y.toDouble() * y.toDouble() + fun dot(other: Vector2f): Float { + return other.x * x + other.y * y } override fun equals(other: Any?): Boolean { diff --git a/src/kvector/kotlin/ru/dbotthepony/kvector/vector/nint/Vector2i.kt b/src/kvector/kotlin/ru/dbotthepony/kvector/vector/nint/Vector2i.kt index 3813ed80..e6b0a4c4 100644 --- a/src/kvector/kotlin/ru/dbotthepony/kvector/vector/nint/Vector2i.kt +++ b/src/kvector/kotlin/ru/dbotthepony/kvector/vector/nint/Vector2i.kt @@ -4,6 +4,7 @@ package ru.dbotthepony.kvector.vector.nint import ru.dbotthepony.kvector.api.* +import ru.dbotthepony.kvector.vector.ndouble.Vector2d import kotlin.math.absoluteValue /** @@ -149,6 +150,10 @@ open class Vector2i( return "[${x}i ${y}i]" } + fun toDoubleVector(): Vector2d { + return Vector2d(x.toDouble(), y.toDouble()) + } + inline val xx get() = Vector2i(x, x) inline val xy get() = Vector2i(x, y) inline val yx get() = Vector2i(y, x) @@ -240,6 +245,7 @@ open class Vector2i( @JvmField val NEGATIVE_X = Vector2i(x = -1) @JvmField val POSITIVE_Y = Vector2i(y = 1) @JvmField val NEGATIVE_Y = Vector2i(y = -1) + @JvmField val POSITIVE_XY = Vector2i(1, 1) } } diff --git a/src/main/java/ru/dbotthepony/kstarbound/client/freetype/struct/FT_Vector.java b/src/main/java/ru/dbotthepony/kstarbound/client/freetype/struct/FT_Vector.java index a4ca87a1..c41486a6 100644 --- a/src/main/java/ru/dbotthepony/kstarbound/client/freetype/struct/FT_Vector.java +++ b/src/main/java/ru/dbotthepony/kstarbound/client/freetype/struct/FT_Vector.java @@ -1,7 +1,7 @@ package ru.dbotthepony.kstarbound.client.freetype.struct; import com.sun.jna.Structure; -import ru.dbotthepony.kstarbound.math.Vector2i; +import ru.dbotthepony.kvector.vector.nint.Vector2i; @Structure.FieldOrder({"x", "y"}) public class FT_Vector extends Structure { diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/Main.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/Main.kt index 0fbd1ccc..c6779cb9 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/Main.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/Main.kt @@ -10,10 +10,10 @@ import ru.dbotthepony.kbox2d.collision.shapes.PolygonShape import ru.dbotthepony.kbox2d.dynamics.B2World import ru.dbotthepony.kbox2d.dynamics.joint.MouseJoint import ru.dbotthepony.kstarbound.client.StarboundClient -import ru.dbotthepony.kstarbound.math.Vector2d import ru.dbotthepony.kstarbound.world.Chunk import ru.dbotthepony.kstarbound.world.entities.Move import ru.dbotthepony.kstarbound.world.entities.PlayerEntity +import ru.dbotthepony.kvector.vector.ndouble.Vector2d import java.io.File import java.util.* import kotlin.collections.ArrayList @@ -104,7 +104,7 @@ fun main() { val mouseJoints = ArrayList() run { - val stripes = 0 + val stripes = 4 for (stripe in 0 until stripes) { for (x in 0 .. (stripes - stripe)) { @@ -232,7 +232,7 @@ fun main() { bodyA = base, bodyB = wheel1, anchor = Vector2d(x = -2.0, y = 15.0), - axis = Vector2d.UP, + axis = Vector2d.POSITIVE_Y, enableLimit = true, upperTranslation = 0.25, lowerTranslation = -0.25, @@ -242,7 +242,7 @@ fun main() { bodyA = base, bodyB = wheel2, anchor = Vector2d(x = 2.0, y = 15.0), - axis = Vector2d.UP, + axis = Vector2d.POSITIVE_Y, enableLimit = true, upperTranslation = 0.25, lowerTranslation = -0.25, diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/Starbound.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/Starbound.kt index b66b6507..b4f178cd 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/Starbound.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/Starbound.kt @@ -9,11 +9,15 @@ import ru.dbotthepony.kstarbound.defs.* import ru.dbotthepony.kstarbound.defs.projectile.ConfigurableProjectile import ru.dbotthepony.kstarbound.defs.projectile.ConfiguredProjectile import ru.dbotthepony.kstarbound.defs.projectile.ProjectilePhysics -import ru.dbotthepony.kstarbound.io.StarboundPak +import ru.dbotthepony.kstarbound.io.* import ru.dbotthepony.kstarbound.math.* -import ru.dbotthepony.kstarbound.util.Color -import ru.dbotthepony.kstarbound.util.ColorTypeAdapter import ru.dbotthepony.kstarbound.util.CustomEnumTypeAdapter +import ru.dbotthepony.kvector.util2d.AABB +import ru.dbotthepony.kvector.util2d.AABBi +import ru.dbotthepony.kvector.vector.Color +import ru.dbotthepony.kvector.vector.ndouble.Vector2d +import ru.dbotthepony.kvector.vector.nfloat.Vector2f +import ru.dbotthepony.kvector.vector.nint.Vector2i import java.io.* import java.nio.ByteBuffer import java.text.DateFormat diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/api/Structs.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/api/Structs.kt deleted file mode 100644 index 142ffb07..00000000 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/api/Structs.kt +++ /dev/null @@ -1,40 +0,0 @@ -package ru.dbotthepony.kstarbound.api - -interface IStruct2f { - operator fun component1(): Float - operator fun component2(): Float -} - -interface IStruct3f : IStruct2f { - operator fun component3(): Float -} - -interface IStruct4f : IStruct3f { - operator fun component4(): Float -} - -interface IStruct2d { - operator fun component1(): Double - operator fun component2(): Double -} - -interface IStruct3d : IStruct2d { - operator fun component3(): Double -} - -interface IStruct4d : IStruct3d { - operator fun component4(): Double -} - -interface IStruct2i { - operator fun component1(): Int - operator fun component2(): Int -} - -interface IStruct3i : IStruct2i { - operator fun component3(): Int -} - -interface IStruct4i : IStruct3i { - operator fun component4(): Int -} diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/client/ClientChunk.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/client/ClientChunk.kt index a4aa74b5..5268a223 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/client/ClientChunk.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/client/ClientChunk.kt @@ -5,10 +5,10 @@ import ru.dbotthepony.kstarbound.client.render.BakedStaticMesh import ru.dbotthepony.kstarbound.client.render.EntityRenderer import ru.dbotthepony.kstarbound.client.render.ILayeredRenderer import ru.dbotthepony.kstarbound.client.render.TileLayerList -import ru.dbotthepony.kstarbound.math.Matrix4fStack -import ru.dbotthepony.kstarbound.math.Vector2d import ru.dbotthepony.kstarbound.world.* import ru.dbotthepony.kstarbound.world.entities.Entity +import ru.dbotthepony.kvector.matrix.Matrix4fStack +import ru.dbotthepony.kvector.vector.ndouble.Vector2d import java.io.Closeable /** @@ -227,7 +227,7 @@ class ClientChunk(world: ClientWorld, pos: ChunkPos) : Chunk= zPos) { @@ -272,7 +272,7 @@ class ClientChunk(world: ClientWorld, pos: ChunkPos) : Chunk val relative = renderer.renderPos - posVector2d - it.push().translateWithScale(relative.x.toFloat(), relative.y.toFloat()) + it.push().translateWithMultiplication(relative.x.toFloat(), relative.y.toFloat()) renderer.render(it) it.pop() return@lambda diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/client/ClientWorld.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/client/ClientWorld.kt index 2496a283..c9b95721 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/client/ClientWorld.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/client/ClientWorld.kt @@ -1,8 +1,9 @@ package ru.dbotthepony.kstarbound.client import ru.dbotthepony.kstarbound.client.render.renderLayeredList -import ru.dbotthepony.kstarbound.math.AABB +import ru.dbotthepony.kstarbound.math.encasingChunkPosAABB import ru.dbotthepony.kstarbound.world.* +import ru.dbotthepony.kvector.util2d.AABB class ClientWorld(val client: StarboundClient, seed: Long = 0L) : World(seed) { override fun chunkFactory(pos: ChunkPos): ClientChunk { diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/client/StarboundClient.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/client/StarboundClient.kt index 1b52e138..5f447178 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/client/StarboundClient.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/client/StarboundClient.kt @@ -12,14 +12,14 @@ import ru.dbotthepony.kstarbound.PIXELS_IN_STARBOUND_UNITf import ru.dbotthepony.kstarbound.Starbound import ru.dbotthepony.kstarbound.client.gl.GLStateTracker import ru.dbotthepony.kstarbound.client.input.UserInput -import ru.dbotthepony.kstarbound.math.Matrix4f import ru.dbotthepony.kstarbound.client.render.Camera import ru.dbotthepony.kstarbound.client.render.TextAlignX import ru.dbotthepony.kstarbound.client.render.TextAlignY -import ru.dbotthepony.kstarbound.math.AABB -import ru.dbotthepony.kstarbound.math.Vector2f -import ru.dbotthepony.kstarbound.util.Color import ru.dbotthepony.kstarbound.util.formatBytesShort +import ru.dbotthepony.kvector.matrix.nfloat.Matrix4f +import ru.dbotthepony.kvector.util2d.AABB +import ru.dbotthepony.kvector.vector.Color +import ru.dbotthepony.kvector.vector.nfloat.Vector3f class StarboundClient : AutoCloseable { val window: Long @@ -197,12 +197,12 @@ class StarboundClient : AutoCloseable { world?.think(frameRenderTime) glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT) - gl.matrixStack.clear(viewportMatrixGame.toMutableMatrix()) + gl.matrixStack.clear(viewportMatrixGame.toMutableMatrix4f()) gl.matrixStack.push() - .translateWithScale(viewportWidth / 2f, viewportHeight / 2f, 2f) // центр экрана + координаты отрисовки мира + .translateWithMultiplication(viewportWidth / 2f, viewportHeight / 2f, 2f) // центр экрана + координаты отрисовки мира .scale(x = settings.scale * PIXELS_IN_STARBOUND_UNITf, y = settings.scale * PIXELS_IN_STARBOUND_UNITf) // масштабируем до нужного размера - .translateWithScale(-camera.pos.x, -camera.pos.y) // перемещаем вид к камере + .translateWithMultiplication(-camera.pos.x, -camera.pos.y) // перемещаем вид к камере for (lambda in onPreDrawWorld) { lambda.invoke() @@ -213,7 +213,8 @@ class StarboundClient : AutoCloseable { onPostDrawWorldOnce.removeAt(i) } - world?.render(AABB.rectangle( + world?.render( + AABB.rectangle( camera.pos.toDoubleVector(), viewportWidth / settings.scale / PIXELS_IN_STARBOUND_UNIT, viewportHeight / settings.scale / PIXELS_IN_STARBOUND_UNIT)) @@ -224,7 +225,7 @@ class StarboundClient : AutoCloseable { gl.matrixStack.pop() - gl.matrixStack.clear(viewportMatrixGUI.toMutableMatrix().translate(z = 2f)) + gl.matrixStack.clear(viewportMatrixGUI.toMutableMatrix4f().translate(Vector3f(z = 2f))) val thisTime = System.currentTimeMillis() @@ -236,12 +237,12 @@ class StarboundClient : AutoCloseable { } gl.matrixStack.push() - gl.matrixStack.translateWithScale(y = viewportHeight.toFloat()) + gl.matrixStack.translateWithMultiplication(y = viewportHeight.toFloat()) var shade = 255 for (i in startupTextList.size - 1 downTo 0) { - val size = gl.font.render(startupTextList[i], alignY = TextAlignY.BOTTOM, scale = 0.4f, color = Color.SHADES_OF_GRAY[shade].copy(alpha = alpha)) - gl.matrixStack.translateWithScale(y = -size.height * 1.2f) + val size = gl.font.render(startupTextList[i], alignY = TextAlignY.BOTTOM, scale = 0.4f, color = Color.SHADES_OF_GRAY[shade].copy(a = alpha)) + gl.matrixStack.translateWithMultiplication(y = -size.height * 1.2f) if (shade > 120) { shade -= 10 diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/client/gl/GLShaderProgram.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/client/gl/GLShaderProgram.kt index d0d4117d..a4ab9a4f 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/client/gl/GLShaderProgram.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/client/gl/GLShaderProgram.kt @@ -3,11 +3,11 @@ package ru.dbotthepony.kstarbound.client.gl import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap import it.unimi.dsi.fastutil.objects.Object2ObjectFunction import org.lwjgl.opengl.GL46.* -import ru.dbotthepony.kstarbound.api.IStruct3f -import ru.dbotthepony.kstarbound.api.IStruct4f -import ru.dbotthepony.kstarbound.math.AbstractMatrix3f -import ru.dbotthepony.kstarbound.math.AbstractMatrix4f -import ru.dbotthepony.kstarbound.math.FloatMatrix +import ru.dbotthepony.kvector.api.IFloatMatrix +import ru.dbotthepony.kvector.api.IStruct3f +import ru.dbotthepony.kvector.api.IStruct4f +import java.nio.ByteBuffer +import java.nio.ByteOrder import java.util.* import kotlin.collections.HashSet @@ -37,29 +37,28 @@ class GLUniformLocation(val program: GLShaderProgram, val name: String, val poin return this } - fun set(value: FloatMatrix<*>): GLUniformLocation { + private val buff3x3 by lazy { ByteBuffer.allocateDirect(4 * 3 * 3).also { it.order(ByteOrder.nativeOrder()) }.asFloatBuffer() } + private val buff4x4 by lazy { ByteBuffer.allocateDirect(4 * 4 * 4).also { it.order(ByteOrder.nativeOrder()) }.asFloatBuffer() } + + fun set(value: IFloatMatrix<*>): GLUniformLocation { program.state.ensureSameThread() if (value.rows == 3 && value.columns == 3) { // Матрица 3x3 - if (value is AbstractMatrix3f) { - glProgramUniformMatrix3fv(program.pointer, pointer, false, value.toFloatBuffer()) - } else { - glProgramUniformMatrix3fv(program.pointer, pointer, false, value.toFloatArray()) - } - + buff3x3.position(0) + value.write(buff3x3) + buff3x3.position(0) + glProgramUniformMatrix3fv(program.pointer, pointer, false, buff3x3) checkForGLError() } else if (value.rows == 4 && value.columns == 4) { // Матрица 4x4 - if (value is AbstractMatrix4f) { - glProgramUniformMatrix4fv(program.pointer, pointer, false, value.toFloatBuffer()) - } else { - glProgramUniformMatrix4fv(program.pointer, pointer, false, value.toFloatArray()) - } - + buff4x4.position(0) + value.write(buff4x4) + buff4x4.position(0) + glProgramUniformMatrix4fv(program.pointer, pointer, false, buff4x4) checkForGLError() } else { - throw IllegalArgumentException("Can not use matrix with these dimensions: ${value.rows}x${value.columns}") + throw IllegalArgumentException("Can not use matrix with these dimensions: ${value.columns}x${value.rows}") } return this @@ -101,7 +100,7 @@ open class GLShaderProgram(val state: GLStateTracker, vararg shaders: GLShader) operator fun set(name: String, value: IStruct4f) = this[name]?.set(value) operator fun set(name: String, value: IStruct3f) = this[name]?.set(value) operator fun set(name: String, value: Int) = this[name]?.set(value) - operator fun set(name: String, value: FloatMatrix<*>) = this[name]?.set(value) + operator fun set(name: String, value: IFloatMatrix<*>) = this[name]?.set(value) fun attach(shader: GLShader) { state.ensureSameThread() diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/client/gl/GLStateTracker.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/client/gl/GLStateTracker.kt index 042c50a4..ae0fd7bb 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/client/gl/GLStateTracker.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/client/gl/GLStateTracker.kt @@ -4,16 +4,15 @@ import org.apache.logging.log4j.LogManager import org.lwjgl.opengl.GL import org.lwjgl.opengl.GL46.* import ru.dbotthepony.kstarbound.Starbound -import ru.dbotthepony.kstarbound.api.IStruct4f import ru.dbotthepony.kstarbound.client.freetype.FreeType import ru.dbotthepony.kstarbound.client.render.Box2DRenderer -import ru.dbotthepony.kstarbound.math.Matrix4f -import ru.dbotthepony.kstarbound.math.Matrix4fStack import ru.dbotthepony.kstarbound.client.render.Font import ru.dbotthepony.kstarbound.client.render.TileRenderers -import ru.dbotthepony.kstarbound.math.AABB -import ru.dbotthepony.kstarbound.util.Color -import java.io.File +import ru.dbotthepony.kvector.api.IStruct4f +import ru.dbotthepony.kvector.matrix.Matrix4fStack +import ru.dbotthepony.kvector.matrix.nfloat.Matrix4f +import ru.dbotthepony.kvector.util2d.AABB +import ru.dbotthepony.kvector.vector.Color import java.io.FileNotFoundException import java.lang.ref.Cleaner import java.util.concurrent.ThreadFactory diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/client/gl/GLTexture.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/client/gl/GLTexture.kt index a55a41ff..0adaf522 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/client/gl/GLTexture.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/client/gl/GLTexture.kt @@ -3,7 +3,7 @@ package ru.dbotthepony.kstarbound.client.gl import org.apache.logging.log4j.LogManager import org.lwjgl.opengl.GL46.* import org.lwjgl.stb.STBImage -import ru.dbotthepony.kstarbound.math.Vector2i +import ru.dbotthepony.kvector.vector.nint.Vector2i import java.io.File import java.io.FileNotFoundException import java.nio.ByteBuffer diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/client/gl/VertexBuilder.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/client/gl/VertexBuilder.kt index f8258737..c6b01e6b 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/client/gl/VertexBuilder.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/client/gl/VertexBuilder.kt @@ -1,7 +1,7 @@ package ru.dbotthepony.kstarbound.client.gl import org.lwjgl.opengl.GL46.* -import ru.dbotthepony.kstarbound.math.AABB +import ru.dbotthepony.kvector.util2d.AABB import java.io.Closeable import java.nio.ByteBuffer import java.nio.ByteOrder diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/client/render/BakedProgramState.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/client/render/BakedProgramState.kt index e2252a13..54a2c1cc 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/client/render/BakedProgramState.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/client/render/BakedProgramState.kt @@ -5,8 +5,8 @@ import ru.dbotthepony.kstarbound.client.gl.GLShaderProgram import ru.dbotthepony.kstarbound.client.gl.GLVertexArrayObject import ru.dbotthepony.kstarbound.client.gl.DynamicVertexBuilder import ru.dbotthepony.kstarbound.client.gl.checkForGLError -import ru.dbotthepony.kstarbound.math.FloatMatrix -import ru.dbotthepony.kstarbound.math.Matrix4fStack +import ru.dbotthepony.kvector.api.IFloatMatrix +import ru.dbotthepony.kvector.matrix.Matrix4fStack /** * Служит для быстрой настройки состояния для будущей отрисовки @@ -23,7 +23,7 @@ open class BakedProgramState( ) { private val transformLocation = program["_transform"] - open fun setTransform(value: FloatMatrix<*>) { + open fun setTransform(value: IFloatMatrix<*>) { transformLocation?.set(value) } @@ -71,7 +71,7 @@ class BakedStaticMesh( ebo.unbind() } - fun render(transform: FloatMatrix<*>? = null) { + fun render(transform: IFloatMatrix<*>? = null) { check(isValid) { "$this is no longer valid" } programState.setup() diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/client/render/Box2DRenderer.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/client/render/Box2DRenderer.kt index f7e5b2cc..225751a9 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/client/render/Box2DRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/client/render/Box2DRenderer.kt @@ -5,8 +5,8 @@ import ru.dbotthepony.kbox2d.api.IDebugDraw import ru.dbotthepony.kbox2d.api.Transform import ru.dbotthepony.kstarbound.PIXELS_IN_STARBOUND_UNIT import ru.dbotthepony.kstarbound.client.gl.GLStateTracker -import ru.dbotthepony.kstarbound.math.Vector2d -import ru.dbotthepony.kstarbound.util.Color +import ru.dbotthepony.kvector.vector.Color +import ru.dbotthepony.kvector.vector.ndouble.Vector2d import kotlin.math.cos import kotlin.math.sin @@ -69,7 +69,7 @@ class Box2DRenderer(val state: GLStateTracker) : IDebugDraw { } override fun drawSolidPolygon(vertices: List, color: Color) { - drawSolid(vertices, color.copy(alpha = 0.5f)) + drawSolid(vertices, color.copy(a = 0.5f)) drawPolygon(vertices, color) } @@ -104,7 +104,7 @@ class Box2DRenderer(val state: GLStateTracker) : IDebugDraw { )) } - drawSolidPolygon(vertexList, color.copy(alpha = 0.5f)) + drawSolidPolygon(vertexList, color.copy(a = 0.5f)) drawPolygon(vertexList, color) drawPolygon(listOf(center, center + axis * radius), color) } diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/client/render/Camera.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/client/render/Camera.kt index 9ff28a83..cf25c999 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/client/render/Camera.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/client/render/Camera.kt @@ -2,7 +2,7 @@ package ru.dbotthepony.kstarbound.client.render import org.lwjgl.glfw.GLFW.* import ru.dbotthepony.kstarbound.client.StarboundClient -import ru.dbotthepony.kstarbound.math.* +import ru.dbotthepony.kvector.vector.nfloat.MutableVector2f class Camera(val client: StarboundClient) { /** diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/client/render/EntityRenderer.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/client/render/EntityRenderer.kt index 3e578b96..2b1fd8b3 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/client/render/EntityRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/client/render/EntityRenderer.kt @@ -4,10 +4,10 @@ import org.lwjgl.opengl.GL46.* import ru.dbotthepony.kstarbound.client.ClientChunk import ru.dbotthepony.kstarbound.client.gl.GLStateTracker import ru.dbotthepony.kstarbound.client.gl.VertexTransformers -import ru.dbotthepony.kstarbound.math.Matrix4fStack -import ru.dbotthepony.kstarbound.math.Vector2d import ru.dbotthepony.kstarbound.world.entities.Entity import ru.dbotthepony.kstarbound.world.entities.Projectile +import ru.dbotthepony.kvector.matrix.Matrix4fStack +import ru.dbotthepony.kvector.vector.ndouble.Vector2d import java.io.Closeable /** diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/client/render/Font.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/client/render/Font.kt index cbb5a76c..cd7a24b3 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/client/render/Font.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/client/render/Font.kt @@ -6,8 +6,8 @@ import org.lwjgl.opengl.GL46.* import ru.dbotthepony.kstarbound.client.freetype.LoadFlag import ru.dbotthepony.kstarbound.client.gl.* import ru.dbotthepony.kstarbound.client.freetype.struct.FT_Pixel_Mode -import ru.dbotthepony.kstarbound.math.Matrix4fStack -import ru.dbotthepony.kstarbound.util.Color +import ru.dbotthepony.kvector.matrix.Matrix4fStack +import ru.dbotthepony.kvector.vector.Color private fun breakLines(text: String): List { var nextLineBreak = text.indexOf('\n', 0) @@ -100,9 +100,9 @@ class Font( stack.push() when (alignY) { - TextAlignY.TOP -> stack.translateWithScale(x = x, y = lineHeight * scale + y) - TextAlignY.CENTER -> stack.translateWithScale(x = x, y = lineHeight * scale - totalY * scale / 2f + y) - TextAlignY.BOTTOM -> stack.translateWithScale(x = x, y = lineHeight * scale - totalY * scale + y) + TextAlignY.TOP -> stack.translateWithMultiplication(x = x, y = lineHeight * scale + y) + TextAlignY.CENTER -> stack.translateWithMultiplication(x = x, y = lineHeight * scale - totalY * scale / 2f + y) + TextAlignY.BOTTOM -> stack.translateWithMultiplication(x = x, y = lineHeight * scale - totalY * scale + y) } if (scale != 1f) @@ -118,7 +118,7 @@ class Font( for (line in text) { if (line == "") { - stack.translateWithScale(y = lineHeight) + stack.translateWithMultiplication(y = lineHeight) continue } @@ -129,12 +129,12 @@ class Font( TextAlignX.CENTER -> { movedX = totalX / 2f - lineWidth(line, space) / 2f - stack.translateWithScale(x = movedX) + stack.translateWithMultiplication(x = movedX) } TextAlignX.RIGHT -> { movedX = -lineWidth(line, space) - stack.translateWithScale(x = movedX) + stack.translateWithMultiplication(x = movedX) } } @@ -145,10 +145,10 @@ class Font( if (chr == '\t') { if (lineGlyphs % 4 == 0) { advancedX += space.advanceX * 4 - stack.translateWithScale(x = space.advanceX * 4) + stack.translateWithMultiplication(x = space.advanceX * 4) } else { advancedX += space.advanceX * (lineGlyphs % 4) - stack.translateWithScale(x = space.advanceX * (lineGlyphs % 4)) + stack.translateWithMultiplication(x = space.advanceX * (lineGlyphs % 4)) } lineGlyphs += lineGlyphs % 4 @@ -162,7 +162,7 @@ class Font( } advancedX = advancedX.coerceAtLeast(lineWidth) - stack.translateWithScale(x = -lineWidth - movedX, y = lineHeight) + stack.translateWithMultiplication(x = -lineWidth - movedX, y = lineHeight) } state.VAO = null @@ -205,10 +205,10 @@ class Font( if (chr == '\t') { if (lineGlyphs % 4 == 0) { lineWidth += space.advanceX * 4 - state.matrixStack.translateWithScale(x = space.advanceX * 4) + state.matrixStack.translateWithMultiplication(x = space.advanceX * 4) } else { lineWidth += space.advanceX * (lineGlyphs % 4) - state.matrixStack.translateWithScale(x = space.advanceX * (lineGlyphs % 4)) + state.matrixStack.translateWithMultiplication(x = space.advanceX * (lineGlyphs % 4)) } lineGlyphs += lineGlyphs % 4 @@ -325,20 +325,20 @@ class Font( fun render(stack: Matrix4fStack) { if (isEmpty) { - stack.translateWithScale(advanceX) + stack.translateWithMultiplication(advanceX) return } vao!!.bind() - stack.translateWithScale(bearingX, -bearingY) + stack.translateWithMultiplication(bearingX, -bearingY) texture!!.bind() state.fontProgram.transform.set(stack.last) glDrawElements(GL_TRIANGLES, indexCount, GL_UNSIGNED_INT, 0L) checkForGLError() - stack.translateWithScale(advanceX - bearingX, bearingY) + stack.translateWithMultiplication(advanceX - bearingX, bearingY) } override fun close() { diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/client/render/ILayeredRenderer.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/client/render/ILayeredRenderer.kt index 012e4168..43ab43f3 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/client/render/ILayeredRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/client/render/ILayeredRenderer.kt @@ -1,6 +1,6 @@ package ru.dbotthepony.kstarbound.client.render -import ru.dbotthepony.kstarbound.math.Matrix4fStack +import ru.dbotthepony.kvector.matrix.Matrix4fStack /** * Интерфейс для отрисовки комплексных объектов, в которых множество слоёв, который diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/client/render/TileRenderer.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/client/render/TileRenderer.kt index b680d55a..105c21de 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/client/render/TileRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/client/render/TileRenderer.kt @@ -8,9 +8,9 @@ import ru.dbotthepony.kstarbound.client.gl.* import ru.dbotthepony.kstarbound.defs.TileDefinition import ru.dbotthepony.kstarbound.defs.TileRenderMatchPiece import ru.dbotthepony.kstarbound.defs.TileRenderPiece -import ru.dbotthepony.kstarbound.math.Vector2i -import ru.dbotthepony.kstarbound.util.Color import ru.dbotthepony.kstarbound.world.ITileChunk +import ru.dbotthepony.kvector.vector.Color +import ru.dbotthepony.kvector.vector.nint.Vector2i import kotlin.collections.HashMap data class TileLayer( diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/Animation.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/Animation.kt index 81937520..55e3b4e0 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/Animation.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/Animation.kt @@ -1,6 +1,6 @@ package ru.dbotthepony.kstarbound.defs -import ru.dbotthepony.kstarbound.math.Vector2i +import ru.dbotthepony.kvector.vector.nint.Vector2i class AnimationDefinitionBuilder { var frames: String? = null diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/FrameGrid.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/FrameGrid.kt index 0a5e22fe..9d98dfda 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/FrameGrid.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/FrameGrid.kt @@ -6,7 +6,7 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap import org.apache.logging.log4j.LogManager import ru.dbotthepony.kstarbound.Starbound -import ru.dbotthepony.kstarbound.math.Vector2i +import ru.dbotthepony.kvector.vector.nint.Vector2i import java.io.FileNotFoundException import kotlin.collections.HashMap @@ -243,7 +243,7 @@ interface IFrameGrid { return ResolvedFrameGrid( texture = texturePath, size = size, - dimensions = Vector2i.ONE_ONE, + dimensions = Vector2i.POSITIVE_XY, frames = listOf(FrameSet( name = "root", frames = listOf(frame), diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/ProjectileDefinition.~kt b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/ProjectileDefinition.~kt new file mode 100644 index 00000000..773c6915 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/ProjectileDefinition.~kt @@ -0,0 +1,539 @@ +package ru.dbotthepony.kstarbound.defs + +import com.google.common.collect.ImmutableList +import com.google.gson.JsonElement +import com.google.gson.JsonPrimitive +import com.google.gson.TypeAdapter +import com.google.gson.stream.JsonReader +import com.google.gson.stream.JsonToken +import com.google.gson.stream.JsonWriter +import org.apache.logging.log4j.LogManager +import ru.dbotthepony.kstarbound.Starbound +import ru.dbotthepony.kvector.AABB +import ru.dbotthepony.kvector.AABBi +import ru.dbotthepony.kstarbound.math.Poly +import ru.dbotthepony.kstarbound.math.Vector2i +import ru.dbotthepony.kstarbound.util.Color +import java.util.* + +class ProjectileEffectBuilder( + var effect: String? = null, + var duration: Double? = null +) { + fun build() = ProjectileEffect(effect = effect!!, duration = duration) +} + +object ProjectileEffectBuilderTypeAdapter : TypeAdapter() { + override fun write(out: JsonWriter?, value: ProjectileEffectBuilder?) { + TODO("Not yet implemented") + } + + override fun read(reader: JsonReader): ProjectileEffectBuilder { + return when (val type = reader.peek()) { + JsonToken.STRING -> ProjectileEffectBuilder(effect = reader.nextString()) + JsonToken.BEGIN_OBJECT -> { + reader.beginObject() + + val obj = ProjectileEffectBuilder() + + while (reader.hasNext()) { + when (val key = reader.nextName()) { + "effect" -> obj.effect = reader.nextString() + "duration" -> obj.duration = reader.nextDouble() + else -> throw IllegalArgumentException("Unknown projectile effect key $key") + } + } + + reader.endObject() + + checkNotNull(obj.effect) { "Effect is null" } + + return obj + } + + else -> throw IllegalArgumentException("Unknown projectile effect token $type") + } + } +} + +class ProjectileDamageTeamBuilder { + var type: String? = null + + fun build() = ProjectileDamageTeam(type = type!!) +} + +class ProjectileActionOnReapTileBuilder { + var quantity: Int? = null + var kind: String? = null + + fun build() = ProjectileActionOnReapTileMaterial(kind = kind!!, quantity = quantity ?: 1) +} + +class ProjectileActionOnReapBuilder { + val action: String? = null + var inheritDamageFactor: Double? = null + var inheritSpeedFactor: Double? = null + var angleAdjust: Double? = null + var fuzzAngle: Double? = null + var type: String? = null + var direction: Vector2i? = null + var offset: Vector2i? = null + var config: ProjectileConfigBuilder? = null + var file: String? = null + + var options: Array? = null + var list: Array? = null + var body: Array? = null + var count: Int? = null + + var color: Color? = null + var materials: Array? = null + + val foregroundRadius: Double? = null + val backgroundRadius: Double? = null + val explosiveDamageAmount: Double? = null + val delaySteps: Int? = null + + var liquid: String? = null + var quantity: Double? = null + + var previousMod: String? = null + var newMod: String? = null + var radius: Double? = null + + fun build(directory: String = ""): ProjectileActionOnReap { + return when (val action = checkNotNull(action) { "actionOnReap.action is null" }) { + "projectile" -> ProjectileActionOnReapProjectile( + inheritDamageFactor = inheritDamageFactor, + inheritSpeedFactor = inheritSpeedFactor, + type = checkNotNull(type) { "actionOnReap.projectile.type is null" }.intern(), + direction = direction, + config = config?.buildConfig() ?: ProjectileConfig.EMPTY, + angleAdjust = angleAdjust, + fuzzAngle = fuzzAngle, + ) + + "config" -> ProjectileActionOnReapConfig( + file = ensureAbsolutePath(checkNotNull(file) { "actionOnReap.config.file is null" }, directory).also { + require(Starbound.pathExists(it)) { "$it does not exist" } + } + ) + + "option" -> ProjectileActionOnReapOption( + options = ImmutableList.copyOf(checkNotNull(options) { "actionOnReap.option.options is null" }.map { Starbound.gson.fromJson(it, ProjectileActionOnReapBuilder::class.java).build(directory) }) + ) + + "actions" -> ProjectileActionOnReapActions( + actions = ImmutableList.copyOf(checkNotNull(list) { "actionOnReap.action.list is null" }.map { it.build(directory) }) + ) + + "sound" -> ProjectileActionOnReapSound( + options = ImmutableList.copyOf(checkNotNull(options) { "actionOnReap.sound.options is null" } + .map { ensureAbsolutePath((it as? JsonPrimitive)?.let { it.asString } ?: throw IllegalArgumentException("$it is not a valid sound"), directory) } + .also { + for (sound in it) { + require(Starbound.pathExists(sound)) { "$it does not exist" } + } + }) + ) + + "spawnmonster" -> ProjectileActionOnReapSpawn( + type = checkNotNull(type) { "actionOnReap.spawnmonster.type is null" }.intern(), + offset = offset ?: Vector2i.ZERO, + ) + + "light" -> ProjectileActionOnReapLight( + color = checkNotNull(color) { "actionOnReap.light.color is null" } + ) + + "particle" -> ProjectileOnReapNothing // TODO: партикли + + "loop" -> ProjectileActionOnReapLoop( + body = ImmutableList.copyOf(checkNotNull(body) { "actionOnReap.loop.body is null" }.map { it.build(directory) }), + count = checkNotNull(count) { "actionOnReap.loop.count is null" } + ) + + "tile" -> ProjectileActionOnReapTile( + materials = ImmutableList.copyOf(checkNotNull(materials) { "actionOnReap.tile.materials is null" } + .map { Starbound.gson.fromJson(it, ProjectileActionOnReapTileBuilder::class.java).build() }) + ) + + "explosion" -> ProjectileActionOnReapExplosion( + foregroundRadius = checkNotNull(foregroundRadius) { "actionOnReap.explosion.foregroundRadius is null" }, + backgroundRadius = checkNotNull(backgroundRadius) { "actionOnReap.explosion.backgroundRadius is null" }, + explosiveDamageAmount = checkNotNull(explosiveDamageAmount) { "actionOnReap.explosion.explosiveDamageAmount is null" }, + delaySteps = checkNotNull(delaySteps) { "actionOnReap.explosion.delaySteps is null" }, + ) + + "liquid" -> ProjectileActionOnReapLiquid( + liquid = checkNotNull(liquid) { "actionOnReap.liquid.liquid is null" }, + quantity = checkNotNull(quantity) { "actionOnReap.liquid.quantity is null" }, + ) + + "applySurfaceMod" -> ProjectileActionOnReapApplySurfaceMod( + previousMod = previousMod, + newMod = newMod, + radius = checkNotNull(radius) { "actionOnReap.applySurfaceMod.radius is null" }, + ) + + else -> throw IllegalArgumentException("Unknown actionOnReap action type: $action") + } + } +} + +sealed interface ProjectileActionOnReap { + val action: String +} + +object ProjectileOnReapNothing : ProjectileActionOnReap { + override val action = "nothing" +} + +data class ProjectileActionOnReapProjectile( + val inheritDamageFactor: Double?, + val inheritSpeedFactor: Double?, + + val angleAdjust: Double?, + val fuzzAngle: Double?, + val direction: Vector2i?, + + val type: String, + val config: ProjectileConfig, +) : ProjectileActionOnReap { + override val action = "projectile" + + init { + // require(direction != null || angleAdjust != null && fuzzAngle != null) { "Projectile reap should have either angleAdjust && fuzzAngle or direction, not none" } + require(!(direction != null && (angleAdjust != null || fuzzAngle != null))) { "Projectile reap has direction ($direction), but also has angleAdjust ($angleAdjust) or fuzzAngle ($fuzzAngle). It should have direction, or the latter" } + } +} + +data class ProjectileActionOnReapConfig( + val file: String, +) : ProjectileActionOnReap { + override val action = "config" +} + +data class ProjectileActionOnReapOption( + val options: List, +) : ProjectileActionOnReap { + override val action = "option" +} + +data class ProjectileActionOnReapLoop( + val body: List, + val count: Int, +) : ProjectileActionOnReap { + override val action = "loop" +} + +data class ProjectileActionOnReapTileMaterial( + val quantity: Int, + val kind: String, +) + +data class ProjectileActionOnReapTile( + val materials: List, +) : ProjectileActionOnReap { + override val action = "tile" +} + +data class ProjectileActionOnReapLiquid( + val liquid: String, + val quantity: Double, +) : ProjectileActionOnReap { + override val action = "liquid" +} + +data class ProjectileActionOnReapSound( + val options: List, +) : ProjectileActionOnReap { + override val action = "sound" +} + +data class ProjectileActionOnReapSpawn( + val type: String, + val offset: Vector2i +) : ProjectileActionOnReap { + override val action = "spawnmonster" +} + +data class ProjectileActionOnReapLight( + val color: Color +) : ProjectileActionOnReap { + override val action = "light" +} + +data class ProjectileActionOnReapActions( + val actions: List, +) : ProjectileActionOnReap { + override val action = "action" +} + +data class ProjectileActionOnReapApplySurfaceMod( + val previousMod: String?, + val newMod: String?, + val radius: Double, +) : ProjectileActionOnReap { + override val action = "applySurfaceMod" +} + +data class ProjectileActionOnReapExplosion( + val foregroundRadius: Double, + val backgroundRadius: Double, + val explosiveDamageAmount: Double, + val delaySteps: Int, +) : ProjectileActionOnReap { + override val action = "explosion" +} + +class ProjectileMovementSettingsBuilder { + var gravityMultiplier: Double? = null + var collisionPoly: Array? = null + + fun build(): ProjectileMovementSettings { + return ProjectileMovementSettings( + gravityMultiplier = gravityMultiplier ?: 1.0, + collisionPoly = collisionPoly?.let { ImmutableList.copyOf(it) } + ) + } +} + +data class ProjectileMovementSettings( + val gravityMultiplier: Double, + val collisionPoly: List? +) + +interface IProjectileConfig { + val power: Double? + val speed: Double? + val timeToLive: Double? + val bounces: Int? + + val damageType: String? + val damageKind: String? + val damageTeam: ProjectileDamageTeam? + + val hydrophobic: Boolean? + val pointLight: Boolean? + val orientationLocked: Boolean? +} + +/** + * Projectile Config указывает те поля, которые можно изменить + */ +open class ProjectileConfigBuilder : ConfigurableDefinition() { + var power: Double = 0.0 + var speed: Double = 0.0 + var timeToLive: Double = Double.POSITIVE_INFINITY + var bounces: Int = -1 + + var damageType: String? = null + var damageKind: String? = null + var damageTeam: ProjectileDamageTeamBuilder? = null + + var hydrophobic: Boolean = false + var pointLight: Boolean = false + var orientationLocked: Boolean = false + + fun buildConfig(): ProjectileConfig { + return ProjectileConfig( + power = power, + speed = speed, + timeToLive = timeToLive, + bounces = bounces, + damageType = damageType, + damageKind = damageKind, + damageTeam = damageTeam?.build(), + hydrophobic = hydrophobic, + pointLight = pointLight, + orientationLocked = orientationLocked, + ) + } +} + +class ProjectileConfig( + json: Map, + override val power: Double, + override val speed: Double, + override val timeToLive: Double, + override val bounces: Int, + override val damageType: String?, + override val damageKind: String?, + override val damageTeam: ProjectileDamageTeam?, + override val hydrophobic: Boolean, + override val pointLight: Boolean, + override val orientationLocked: Boolean, +) : ConfiguredDefinition(), IProjectileConfig { + fun proxy(other: IProjectileConfig) = ProjectileConfigProxy(this, other) + + companion object { + val EMPTY = ProjectileConfigBuilder().buildConfig() + } +} + +class ProjectileConfigProxy(original: IProjectileConfig, private val proxied: IProjectileConfig) : IProjectileConfig { + override val power: Double? = original.power + get() = field ?: proxied.power + override val speed: Double? = original.speed + get() = field ?: proxied.speed + override val timeToLive: Double? = original.timeToLive + get() = field ?: proxied.timeToLive + override val bounces: Int? = original.bounces + get() = field ?: proxied.bounces + override val damageType: String? = original.damageType + get() = field ?: proxied.damageType + override val damageKind: String? = original.damageKind + get() = field ?: proxied.damageKind + override val damageTeam: ProjectileDamageTeam? = original.damageTeam + get() = field ?: proxied.damageTeam + override val hydrophobic: Boolean? = original.hydrophobic + get() = field ?: proxied.hydrophobic + override val pointLight: Boolean? = original.pointLight + get() = field ?: proxied.pointLight + override val orientationLocked: Boolean? = original.orientationLocked + get() = field ?: proxied.orientationLocked +} + +class ProjectileDefinitionBuilder : ProjectileConfigBuilder() { + var projectileName: String? = null + var image: String = "/assetmissing.png" + var physics = ProjectilePhysics.DEFAULT + var animationCycle: Double = Double.POSITIVE_INFINITY + var animationLoops: Boolean = false + + var frameNumber: Int = 1 + var damagePoly: Poly? = null + var lightColor: Color? = null + var statusEffects: Array? = null + var piercing: Boolean? = null + + var damageKindImage: String? = null + var movementSettings: ProjectileMovementSettingsBuilder? = null + + var actionOnReap: Array? = null + var emitters: Array? = null + var intangibleWindup: Boolean? = null + var windupFrames: Int? = null + var winddownFrames: Int? = null + var renderLayer: String? = null + var acceleration: Double? = null + var supportsProcessing: Boolean? = null + var initialVelocity: Double? = null + + var scripts: Array? = null + var onlyHitTerrain: Int? = null + + // TODO: Прожекталы могут иметь абсолютно случайные данные, которые нужны скриптам + // то же самое касается и npc + // и объектов + // такие как chainProjectile для /scripts/projectiles/chainbullet.lua + + fun build(directory: String = ""): ProjectileDefinition { + return ProjectileDefinition( + projectileName = requireNotNull(projectileName) { "projectileName is null" }, + image = IFrameGrid.loadFrameStrip(ensureAbsolutePath(requireNotNull(image) { "image is null" }, directory), weak = true), + physics = physics ?: ProjectilePhysics.DEFAULT, + animationCycle = animationCycle ?: Double.POSITIVE_INFINITY, + animationLoops = animationLoops ?: false, + frameNumber = frameNumber ?: 1, + power = power ?: -1.0, + speed = speed ?: 0.0, + timeToLive = timeToLive ?: Double.POSITIVE_INFINITY, + bounces = bounces ?: 0, + damagePoly = damagePoly, + statusEffects = statusEffects?.map { it.build() }?.let { Collections.unmodifiableList(it) } ?: listOf(), + piercing = piercing ?: false, + damageType = damageType, + damageKind = damageKind, + damageTeam = damageTeam?.build(), + + lightColor = lightColor, + + damageKindImage = damageKindImage?.let { ensureAbsolutePath(it, directory) }, + hydrophobic = hydrophobic ?: false, + pointLight = pointLight ?: false, + orientationLocked = orientationLocked ?: false, + + actionOnReap = actionOnReap?.map { it.build(directory) }?.let { Collections.unmodifiableList(it) } ?: listOf(), + emitters = emitters?.toList()?.let { Collections.unmodifiableList(it) } ?: listOf(), + + intangibleWindup = intangibleWindup ?: false, + windupFrames = windupFrames ?: -1, + winddownFrames = winddownFrames ?: -1, + renderLayer = renderLayer, + acceleration = acceleration ?: 0.0, + + supportsProcessing = supportsProcessing ?: false, + initialVelocity = initialVelocity ?: 0.0, + scripts = scripts?.map { ensureAbsolutePath(it, directory) }?.let { ImmutableList.copyOf(it) } ?: listOf(), + ) + } +} + +data class ProjectileEffect( + val effect: String, + val duration: Double?, // Если null, то стандартное время эффекта +) + +data class ProjectileDamageTeam( + val type: String +) + +class ProjectileDefinition( + json: Map, + val projectileName: String, + val image: FrameGridStrip, + val damageKindImage: String?, + val physics: ProjectilePhysics, + val animationCycle: Double, + val animationLoops: Boolean, + val frameNumber: Int, + + override val power: Double, + override val speed: Double, + override val timeToLive: Double, + override val bounces: Int, + + val damagePoly: Poly?, + val statusEffects: List, + val piercing: Boolean, + + override val damageType: String?, + override val damageKind: String?, + override val damageTeam: ProjectileDamageTeam?, + + val lightColor: Color?, + + override val hydrophobic: Boolean, + override val pointLight: Boolean, + override val orientationLocked: Boolean, + + val actionOnReap: List, + val emitters: List, + + val intangibleWindup: Boolean, + val windupFrames: Int, + val winddownFrames: Int, + + val renderLayer: String?, + val acceleration: Double, + val supportsProcessing: Boolean, + val initialVelocity: Double, + + val scripts: List, +) : ConfiguredDefinition(json), IProjectileConfig { + init { + // require(frameNumber <= image.frameCount) { "Frame number ($frameNumber) exceeds amount of frames in animated image strip (${image.frameCount})" } + + if (frameNumber != image.frameCount) { + LOGGER.warn("{} has lesser frameNumber {} than defined in frame strip {}", projectileName, frameNumber, image.frameCount) + } + } + + val unlimitedBounces get() = bounces <= -1 + + companion object { + private val LOGGER = LogManager.getLogger() + } +} diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/TileDefinition.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/TileDefinition.kt index 1f5e09a0..5a8ae028 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/TileDefinition.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/TileDefinition.kt @@ -7,10 +7,9 @@ import com.google.gson.JsonObject import com.google.gson.JsonPrimitive import org.apache.logging.log4j.LogManager import ru.dbotthepony.kstarbound.Starbound -import ru.dbotthepony.kstarbound.math.Vector2i -import ru.dbotthepony.kstarbound.util.Color import ru.dbotthepony.kstarbound.world.ITileGetter -import java.io.File +import ru.dbotthepony.kvector.vector.Color +import ru.dbotthepony.kvector.vector.nint.Vector2i data class TileDefinition( val materialId: Int, @@ -94,7 +93,7 @@ class TileDefinitionBuilder { require(builder.materialId >= 0) { "Invalid materialId ${builder.materialId}" } - builder.particleColor = Color(input["particleColor"].asJsonArray) + builder.particleColor = Starbound.gson.fromJson(input["particleColor"], Color::class.java) builder.itemDrop = input["itemDrop"]?.asString builder.description = input["description"]?.asString ?: builder.description builder.shortdescription = input["shortdescription"]?.asString ?: builder.shortdescription @@ -160,11 +159,11 @@ data class TileRenderPiece( return@let it } - val textureSize = Vector2i.fromJson(input["textureSize"].asJsonArray) - val texturePosition = Vector2i.fromJson(input["texturePosition"].asJsonArray) + val textureSize = Starbound.gson.fromJson(input["textureSize"], Vector2i::class.java) + val texturePosition = Starbound.gson.fromJson(input["texturePosition"], Vector2i::class.java) - val colorStride = input["colorStride"]?.asJsonArray?.let { Vector2i.fromJson(it) } - val variantStride = input["variantStride"]?.asJsonArray?.let { Vector2i.fromJson(it) } + val colorStride = input["colorStride"]?.let { Starbound.gson.fromJson(it, Vector2i::class.java) } + val variantStride = input["variantStride"]?.let { Starbound.gson.fromJson(it, Vector2i::class.java) } return TileRenderPiece(name, texture, textureSize, texturePosition, colorStride, variantStride) } @@ -324,7 +323,7 @@ data class TileRenderMatchedPiece( return@let tilePieces[it] ?: throw IllegalArgumentException("Unable to find render piece $it") } - val offset = Vector2i.fromJson(input[1].asJsonArray) + val offset = Starbound.gson.fromJson(input[1], Vector2i::class.java) return TileRenderMatchedPiece(piece, offset) } } @@ -343,7 +342,7 @@ data class TileRenderMatchPositioned( companion object { fun fromJson(input: JsonArray, rulePieces: Map): TileRenderMatchPositioned { - val offset = Vector2i.fromJson(input[0].asJsonArray) + val offset = Starbound.gson.fromJson(input[0], Vector2i::class.java) val condition = rulePieces[input[1].asString] ?: throw IllegalArgumentException("Rule ${input[1].asString} is missing!") return TileRenderMatchPositioned(condition, offset) diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/projectile/Configurable.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/projectile/Configurable.kt index d9361a39..e8207a0b 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/projectile/Configurable.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/projectile/Configurable.kt @@ -4,7 +4,7 @@ import ru.dbotthepony.kstarbound.defs.ConfigurableDefinition import ru.dbotthepony.kstarbound.defs.ConfigurableTypeAdapter import ru.dbotthepony.kstarbound.defs.IFrameGrid import ru.dbotthepony.kstarbound.defs.ensureAbsolutePath -import ru.dbotthepony.kstarbound.util.Color +import ru.dbotthepony.kvector.vector.Color class ConfigurableProjectile : ConfigurableDefinition() { var projectileName: String? = null diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/projectile/Configured.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/projectile/Configured.kt index 7a5dd141..c57f58fb 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/projectile/Configured.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/projectile/Configured.kt @@ -3,7 +3,7 @@ package ru.dbotthepony.kstarbound.defs.projectile import com.google.common.collect.ImmutableMap import ru.dbotthepony.kstarbound.defs.ConfiguredDefinition import ru.dbotthepony.kstarbound.defs.FrameSet -import ru.dbotthepony.kstarbound.util.Color +import ru.dbotthepony.kvector.vector.Color class ConfiguredProjectile( json: ImmutableMap, diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/io/AABBJson.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/io/AABBJson.kt new file mode 100644 index 00000000..103dd4a6 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/io/AABBJson.kt @@ -0,0 +1,60 @@ +package ru.dbotthepony.kstarbound.io + +import com.google.gson.TypeAdapter +import com.google.gson.stream.JsonReader +import com.google.gson.stream.JsonWriter +import ru.dbotthepony.kvector.util2d.AABB +import ru.dbotthepony.kvector.util2d.AABBi +import ru.dbotthepony.kvector.vector.ndouble.Vector2d +import ru.dbotthepony.kvector.vector.nint.Vector2i + +object AABBTypeAdapter : TypeAdapter() { + override fun write(out: JsonWriter, value: AABB) { + `out`.beginArray() + Vector2dTypeAdapter.write(out, value.mins) + Vector2dTypeAdapter.write(out, value.maxs) + `out`.endArray() + } + + override fun read(`in`: JsonReader): AABB { + val (x1, x2) = Vector2dTypeAdapter.read(`in`) + val (y1, y2) = Vector2dTypeAdapter.read(`in`) + + val xMins = x1.coerceAtMost(x2) + val xMaxs = x1.coerceAtLeast(x2) + + val yMins = y1.coerceAtMost(y2) + val yMaxs = y1.coerceAtLeast(y2) + + return AABB( + Vector2d(xMins, yMins), + Vector2d(xMaxs, yMaxs), + ) + } +} + +object AABBiTypeAdapter : TypeAdapter() { + override fun write(out: JsonWriter, value: AABBi) { + `out`.beginArray() + Vector2iTypeAdapter.write(out, value.mins) + Vector2iTypeAdapter.write(out, value.maxs) + `out`.endArray() + } + + override fun read(`in`: JsonReader): AABBi { + val (x1, x2) = Vector2iTypeAdapter.read(`in`) + val (y1, y2) = Vector2iTypeAdapter.read(`in`) + + val xMins = x1.coerceAtMost(x2) + val xMaxs = x1.coerceAtLeast(x2) + + val yMins = y1.coerceAtMost(y2) + val yMaxs = y1.coerceAtLeast(y2) + + return AABBi( + Vector2i(xMins, yMins), + Vector2i(xMaxs, yMaxs), + ) + } +} + diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/util/Color.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/io/ColorJson.kt similarity index 68% rename from src/main/kotlin/ru/dbotthepony/kstarbound/util/Color.kt rename to src/main/kotlin/ru/dbotthepony/kstarbound/io/ColorJson.kt index 451d5195..cf0a5798 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/util/Color.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/io/ColorJson.kt @@ -1,46 +1,10 @@ -package ru.dbotthepony.kstarbound.util +package ru.dbotthepony.kstarbound.io -import com.google.common.collect.ImmutableList -import com.google.gson.* +import com.google.gson.TypeAdapter import com.google.gson.stream.JsonReader import com.google.gson.stream.JsonToken import com.google.gson.stream.JsonWriter -import ru.dbotthepony.kstarbound.api.IStruct4f -import java.lang.reflect.Type - -data class Color(val red: Float, val green: Float, val blue: Float, val alpha: Float = 1f) : IStruct4f { - constructor(input: JsonArray) : this(input[0].asFloat / 255f, input[1].asFloat / 255f, input[2].asFloat / 255f, if (input.size() >= 4) input[3].asFloat / 255f else 1f) - - constructor(input: Long) : this( - ((input ushr 16) and 0xFFL).toFloat() / 255f, - ((input ushr 8) and 0xFFL).toFloat() / 255f, - (input and 0xFFL).toFloat() / 255f, - ) - - companion object { - val WHITE = Color(1f, 1f, 1f) - - val RED = Color(1f, 0f, 0f) - val GREEN = Color(0f, 1f, 0f) - val BLUE = Color(0f, 0f, 1f) - - val SLATE_GREY = Color(0.2f, 0.2f, 0.2f) - - val PRE_DEFINED_MAP = mapOf( - "red" to RED, - "green" to GREEN, - "blue" to BLUE, - ) - - val SHADES_OF_GRAY = ArrayList().let { - for (i in 0 .. 256) { - it.add(Color(i / 256f, i / 256f, i / 256f)) - } - - return@let ImmutableList.copyOf(it) as List - } - } -} +import ru.dbotthepony.kvector.vector.Color object ColorTypeAdapter : TypeAdapter() { override fun write(out: JsonWriter, value: Color) { @@ -119,7 +83,7 @@ object ColorTypeAdapter : TypeAdapter() { } } - JsonToken.NUMBER -> return Color(`in`.nextLong()) + JsonToken.NUMBER -> return Color(`in`.nextInt()) JsonToken.STRING -> { val name = `in`.nextString() return Color.PRE_DEFINED_MAP[name] ?: throw IllegalArgumentException("Unknown pre defined color name $name") diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/io/VectorJson.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/io/VectorJson.kt new file mode 100644 index 00000000..808338ad --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/io/VectorJson.kt @@ -0,0 +1,68 @@ +package ru.dbotthepony.kstarbound.io + +import com.google.gson.TypeAdapter +import com.google.gson.stream.JsonReader +import com.google.gson.stream.JsonWriter +import ru.dbotthepony.kvector.vector.ndouble.Vector2d +import ru.dbotthepony.kvector.vector.nfloat.Vector2f +import ru.dbotthepony.kvector.vector.nint.Vector2i + +object Vector2iTypeAdapter : TypeAdapter() { + override fun write(out: JsonWriter, value: Vector2i) { + `out`.beginArray() + `out`.value(value.x) + `out`.value(value.y) + `out`.endArray() + } + + override fun read(`in`: JsonReader): Vector2i { + `in`.beginArray() + + val x = `in`.nextInt() + val y = `in`.nextInt() + + `in`.endArray() + + return Vector2i(x, y) + } +} + +object Vector2fTypeAdapter : TypeAdapter() { + override fun write(out: JsonWriter, value: Vector2f) { + `out`.beginArray() + `out`.value(value.x) + `out`.value(value.y) + `out`.endArray() + } + + override fun read(`in`: JsonReader): Vector2f { + `in`.beginArray() + + val x = `in`.nextDouble().toFloat() + val y = `in`.nextDouble().toFloat() + + `in`.endArray() + + return Vector2f(x, y) + } +} + +object Vector2dTypeAdapter : TypeAdapter() { + override fun write(out: JsonWriter, value: Vector2d) { + `out`.beginArray() + `out`.value(value.x) + `out`.value(value.y) + `out`.endArray() + } + + override fun read(`in`: JsonReader): Vector2d { + `in`.beginArray() + + val x = `in`.nextDouble() + val y = `in`.nextDouble() + + `in`.endArray() + + return Vector2d(x, y) + } +} diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/math/AABB.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/math/AABB.kt index 6d398fe9..f87a514f 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/math/AABB.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/math/AABB.kt @@ -1,574 +1,50 @@ package ru.dbotthepony.kstarbound.math -import com.google.gson.TypeAdapter -import com.google.gson.stream.JsonReader -import com.google.gson.stream.JsonWriter -import ru.dbotthepony.kstarbound.api.IStruct2d import ru.dbotthepony.kstarbound.world.ChunkPos -import kotlin.math.absoluteValue +import ru.dbotthepony.kvector.util2d.AABB +import ru.dbotthepony.kvector.util2d.AABBi +import ru.dbotthepony.kvector.vector.nint.Vector2i -data class IntersectionTime( - val invEntry: Vector2d, - val invExit: Vector2d, - val entry: Vector2d, - val exit: Vector2d, -) { - companion object { - val ZERO = IntersectionTime(Vector2d.ZERO, Vector2d.ZERO, Vector2d.ZERO, Vector2d.ZERO) - } +fun AABB.encasingIntAABB(): AABBi { + return AABBi( + Vector2i(roundByAbsoluteValue(mins.x), roundByAbsoluteValue(mins.y)), + Vector2i(roundByAbsoluteValue(maxs.x), roundByAbsoluteValue(maxs.y)), + ) } -data class SweepResult( - val normal: Vector2d, - val collisionTime: Double, - val intersectionTime: IntersectionTime -) { - companion object { - val ZERO = SweepResult(Vector2d.ZERO, 1.0, IntersectionTime.ZERO) - val INTERSECT = SweepResult(Vector2d.ZERO, 0.0, IntersectionTime.ZERO) - } +fun AABB.encasingChunkPosAABB(): AABBi { + return AABBi( + Vector2i(ChunkPos.tileToChunkComponent(roundTowardsNegativeInfinity(mins.x)), ChunkPos.tileToChunkComponent(roundTowardsNegativeInfinity(mins.y))), + Vector2i(ChunkPos.tileToChunkComponent(roundTowardsPositiveInfinity(maxs.x)), ChunkPos.tileToChunkComponent(roundTowardsPositiveInfinity(maxs.y))), + ) } -/** - * Класс для описания Axis Aligned Bounding Box, двумя векторами, - * где [mins] - нижняя левая точка, - * [maxs] - верхняя правая - */ -data class AABB(val mins: Vector2d, val maxs: Vector2d) { - init { - require(mins.x <= maxs.x) { "mins.x ${mins.x} is more than maxs.x ${maxs.x}" } - require(mins.y <= maxs.y) { "mins.y ${mins.y} is more than maxs.y ${maxs.y}" } +private class Iterator(private val aabb: AABBi, private val factory: (x: Int, y: Int) -> T) : kotlin.collections.Iterator { + private var x = aabb.mins.x + private var y = aabb.mins.y + private var next = true + + override fun hasNext(): Boolean { + return next } - operator fun plus(other: AABB) = AABB(mins + other.mins, maxs + other.maxs) - operator fun minus(other: AABB) = AABB(mins - other.mins, maxs - other.maxs) - operator fun times(other: AABB) = AABB(mins * other.mins, maxs * other.maxs) - operator fun div(other: AABB) = AABB(mins / other.mins, maxs / other.maxs) + override fun next(): T { + if (!next) + throw IllegalStateException() - operator fun plus(other: Vector2d) = AABB(mins + other, maxs + other) - operator fun minus(other: Vector2d) = AABB(mins - other, maxs - other) - operator fun times(other: Vector2d) = AABB(mins * other, maxs * other) - operator fun div(other: Vector2d) = AABB(mins / other, maxs / other) + val obj = factory.invoke(x++, y) - operator fun plus(other: Double) = AABB(mins + other, maxs + other) - operator fun minus(other: Double) = AABB(mins - other, maxs - other) - operator fun times(other: Double) = AABB(mins * other, maxs * other) - operator fun div(other: Double) = AABB(mins / other, maxs / other) + if (x > aabb.maxs.x) { + x = aabb.mins.x - val xSpan get() = maxs.x - mins.x - val ySpan get() = maxs.y - mins.y - val centre get() = (mins + maxs) * 0.5 - - val A get() = mins - val B get() = Vector2d(mins.x, maxs.y) - val C get() = maxs - val D get() = Vector2d(maxs.x, mins.y) - - val bottomLeft get() = A - val topLeft get() = B - val topRight get() = C - val bottomRight get() = D - - val width get() = maxs.x - mins.x - val height get() = maxs.y - mins.y - - val extents get() = Vector2d(width * 0.5, height * 0.5) - - val diameter get() = mins.distance(maxs) - val radius get() = diameter / 2.0 - - val perimeter get() = (xSpan + ySpan) * 2.0 - - fun isInside(point: Vector2d): Boolean { - return point.x in mins.x .. maxs.x && point.y in mins.y .. maxs.y - } - - /** - * Есть ли пересечение между этим AABB и [other] - * - * Считается, что они пересекаются, даже если у них просто равна одна из осей - */ - fun intersect(other: AABB): Boolean { - val intersectX: Boolean - - if (xSpan <= other.xSpan) - intersectX = mins.x in other.mins.x .. other.maxs.x || maxs.x in other.mins.x .. other.maxs.x - else - intersectX = other.mins.x in mins.x .. maxs.x || other.maxs.x in mins.x .. maxs.x - - if (!intersectX) - return false - - val intersectY: Boolean - - if (ySpan <= other.ySpan) - intersectY = mins.y in other.mins.y .. other.maxs.y || maxs.y in other.mins.y .. other.maxs.y - else - intersectY = other.mins.y in mins.y .. maxs.y || other.maxs.y in mins.y .. maxs.y - - return intersectY - } - - /** - * @return Находится ли [other] внутри этого AABB - */ - fun contains(other: AABB): Boolean { - if (xSpan < other.xSpan || ySpan < other.ySpan) - return false - - return other.mins.x in mins.x .. maxs.x && - other.maxs.x in mins.x .. maxs.x && - other.mins.y in mins.y .. maxs.y && - other.maxs.y in mins.y .. maxs.y - } - - /** - * Есть ли пересечение между этим AABB и [other] - * - * Считается, что они НЕ пересекаются, если у них просто равна одна из осей - */ - fun intersectWeak(other: AABB): Boolean { - if (maxs.x == other.mins.x || mins.x == other.maxs.x || maxs.y == other.mins.y || mins.y == other.maxs.y) - return false - - val intersectX: Boolean - - if (xSpan <= other.xSpan) - intersectX = mins.x in other.mins.x .. other.maxs.x || maxs.x in other.mins.x .. other.maxs.x - else - intersectX = other.mins.x in mins.x .. maxs.x || other.maxs.x in mins.x .. maxs.x - - if (!intersectX) - return false - - val intersectY: Boolean - - if (ySpan <= other.ySpan) - intersectY = mins.y in other.mins.y .. other.maxs.y || maxs.y in other.mins.y .. other.maxs.y - else - intersectY = other.mins.y in mins.y .. maxs.y || other.maxs.y in mins.y .. maxs.y - - return intersectY - } - - fun intersectionDepth(other: AABB): Vector2d { - val xDepth: Double - val yDepth: Double - - val thisCentre = centre - val otherCentre = other.centre - - if (thisCentre.x > otherCentre.x) { - // считаем, что мы вошли справа - xDepth = mins.x - other.maxs.x - } else { - // считаем, что мы вошли слева - xDepth = maxs.x - other.mins.x - } - - if (thisCentre.y > otherCentre.y) { - // считаем, что мы вошли сверху - yDepth = mins.y - other.maxs.y - } else { - // считаем, что мы вошли снизу - yDepth = maxs.x - other.mins.x - } - - return Vector2d(xDepth, yDepth) - } - - fun distance(other: AABB): Double { - val intersectX: Boolean - val intersectY: Boolean - - if (ySpan <= other.ySpan) - intersectY = mins.y in other.mins.y .. other.maxs.y || maxs.y in other.mins.y .. other.maxs.y - else - intersectY = other.mins.y in mins.y .. maxs.y || other.maxs.y in mins.y .. maxs.y - - if (xSpan <= other.xSpan) - intersectX = mins.x in other.mins.x .. other.maxs.x || maxs.x in other.mins.x .. other.maxs.x - else - intersectX = other.mins.x in mins.x .. maxs.x || other.maxs.x in mins.x .. maxs.x - - if (intersectY && intersectX) { - return 0.0 - } - - if (intersectX) { - return (mins.y - other.maxs.y).absoluteValue.coerceAtMost((maxs.y - other.mins.y).absoluteValue) - } else { - return (mins.x - other.maxs.x).absoluteValue.coerceAtMost((maxs.x - other.mins.x).absoluteValue) - } - } - - fun pushOutFrom(other: AABB): Vector2d { - if (!intersect(other)) - return Vector2d.ZERO - - val depth = intersectionDepth(other) - - if (depth.x.absoluteValue < depth.y.absoluteValue) { - return Vector2d(x = depth.x) - } else { - return Vector2d(y = depth.y) - } - } - - /** - * Рассчитывает "время" пересечения - * - * https://www.gamedev.net/tutorials/programming/general-and-gameplay-programming/swept-aabb-collision-detection-and-response-r3084/ - * - * Исправленный комментатором той же статьи от hypernewbie - */ - fun intersectionTime(other: AABB, velocity: Vector2d): IntersectionTime { - val xInvEntry: Double - val yInvEntry: Double - val xInvExit: Double - val yInvExit: Double - - if (velocity.x > 0.0) { - xInvEntry = other.mins.x - maxs.x - xInvExit = other.maxs.x - mins.x - } else { - xInvEntry = other.maxs.x - mins.x - xInvExit = other.mins.x - maxs.x - } - - if (velocity.y > 0.0) { - yInvEntry = other.mins.y - maxs.y - yInvExit = other.maxs.y - mins.y - } else { - yInvEntry = other.maxs.y - mins.y - yInvExit = other.mins.y - maxs.y - } - - var xEntry: Double - var yEntry: Double - val xExit: Double - val yExit: Double - - if (velocity.x == 0.0) { - xEntry = Double.NEGATIVE_INFINITY - xExit = Double.POSITIVE_INFINITY - } else { - xEntry = xInvEntry / velocity.x - xExit = xInvExit / velocity.x - } - - if (velocity.y == 0.0) { - yEntry = Double.NEGATIVE_INFINITY - yExit = Double.POSITIVE_INFINITY - } else { - yEntry = yInvEntry / velocity.y - yExit = yInvExit / velocity.y - } - - if (yEntry > 1.0) yEntry = Double.NEGATIVE_INFINITY - if (xEntry > 1.0) xEntry = Double.NEGATIVE_INFINITY - - return IntersectionTime( - Vector2d(xInvEntry, yInvEntry), - Vector2d(xInvExit, yInvExit), - Vector2d(xEntry, yEntry), - Vector2d(xExit, yExit), - ) - } - - /** - * Рассчитывает нормаль пересечения и процент пути ("время"), на котором произошло столкновение. - * - * Если столкновение не произошло, то возвращается [SweepResult.ZERO] - * - * Внимание: Если пересечение уже произошло (т.е. другой AABB пересекается с this), то данный метод - * вернёт заведомо ложный результат (т.е. "нет пересечения") - * - * https://www.gamedev.net/tutorials/programming/general-and-gameplay-programming/swept-aabb-collision-detection-and-response-r3084/ - * - * Исправленный комментатором той же статьи от hypernewbie - */ - fun sweep(other: AABB, velocity: Vector2d): SweepResult { - val time = intersectionTime(other, velocity) - val (near, far, entry, exit) = time - val (xEntry, yEntry) = entry - val (xExit, yExit) = exit - - val entryTime = xEntry.coerceAtLeast(yEntry) - val exitTime = xExit.coerceAtLeast(yExit) - - // гарантированно нет столкновения - if (entryTime > exitTime || xEntry < 0.0 && yEntry < 0.0) { - return SweepResult.ZERO - } - - if (xEntry < 0.0) { - if (maxs.x < other.mins.x || mins.x > other.maxs.x) - return SweepResult.ZERO - } - - if (yEntry < 0.0) { - if (maxs.y < other.mins.y || mins.y > other.maxs.y) - return SweepResult.ZERO - } - - val (xInvEntry, yInvEntry) = near - val normal: Vector2d - - if (xEntry > yEntry) { - if (xInvEntry <= 0.0) { // исправление от меня: <= для тех случаев, когда мы уже на той же оси - normal = Vector2d.RIGHT - } else { - normal = Vector2d.LEFT - } - } else { - if (yInvEntry <= 0.0) { // исправление от меня: <= для тех случаев, когда мы уже на той же оси - normal = Vector2d.UP - } else { - normal = Vector2d.DOWN + if (++y > aabb.maxs.y) { + next = false } } - return SweepResult(normal, entryTime, time) - } - - /** - * Рассчитывает нормаль пересечения и процент пути ("время"), на котором произошло столкновение. - * - * Если столкновение не произошло, то возвращается [SweepResult.ZERO] - * - * Если данный AABB уже столкнулся с [other], возвращается [SweepResult.INTERSECT] - * - * https://www.gamedev.net/tutorials/programming/general-and-gameplay-programming/swept-aabb-collision-detection-and-response-r3084/ - */ - fun safeSweep(other: AABB, velocity: Vector2d): SweepResult { - if (intersect(other)) { - return SweepResult.INTERSECT - } - - return sweep(other, velocity) - } - - fun encasingIntAABB(): AABBi { - return AABBi( - Vector2i(roundByAbsoluteValue(mins.x), roundByAbsoluteValue(mins.y)), - Vector2i(roundByAbsoluteValue(maxs.x), roundByAbsoluteValue(maxs.y)), - ) - } - - fun encasingChunkPosAABB(): AABBi { - return AABBi( - Vector2i(ChunkPos.tileToChunkComponent(roundTowardsNegativeInfinity(mins.x)), ChunkPos.tileToChunkComponent(roundTowardsNegativeInfinity(mins.y))), - Vector2i(ChunkPos.tileToChunkComponent(roundTowardsPositiveInfinity(maxs.x)), ChunkPos.tileToChunkComponent(roundTowardsPositiveInfinity(maxs.y))), - ) - } - - /** - * Возвращает AABB, который содержит в себе оба AABB - */ - fun combine(other: AABB): AABB { - val minX = mins.x.coerceAtMost(other.mins.x) - val minY = mins.y.coerceAtMost(other.mins.y) - val maxX = maxs.x.coerceAtLeast(other.maxs.x) - val maxY = maxs.y.coerceAtLeast(other.maxs.y) - - return AABB(Vector2d(minX, minY), Vector2d(maxX, maxY)) - } - - companion object { - fun rectangle(pos: IStruct2d, width: Double, height: Double = width): AABB { - val (x, y) = pos - - return AABB( - Vector2d(x - width / 2.0, y - height / 2.0), - Vector2d(x + width / 2.0, y + height / 2.0), - ) - } - } -} - -object AABBTypeAdapter : TypeAdapter() { - override fun write(out: JsonWriter, value: AABB) { - `out`.beginArray() - Vector2dTypeAdapter.write(out, value.mins) - Vector2dTypeAdapter.write(out, value.maxs) - `out`.endArray() - } - - override fun read(`in`: JsonReader): AABB { - val (x1, x2) = Vector2dTypeAdapter.read(`in`) - val (y1, y2) = Vector2dTypeAdapter.read(`in`) - - val xMins = x1.coerceAtMost(x2) - val xMaxs = x1.coerceAtLeast(x2) - - val yMins = y1.coerceAtMost(y2) - val yMaxs = y1.coerceAtLeast(y2) - - return AABB( - Vector2d(xMins, yMins), - Vector2d(xMaxs, yMaxs), - ) - } -} - -data class AABBi(val mins: Vector2i, val maxs: Vector2i) { - init { - require(mins.x <= maxs.x) { "mins.x ${mins.x} is more than maxs.x ${maxs.x}" } - require(mins.y <= maxs.y) { "mins.y ${mins.y} is more than maxs.y ${maxs.y}" } - } - - operator fun plus(other: AABBi) = AABBi(mins + other.mins, maxs + other.maxs) - operator fun minus(other: AABBi) = AABBi(mins - other.mins, maxs - other.maxs) - operator fun times(other: AABBi) = AABBi(mins * other.mins, maxs * other.maxs) - operator fun div(other: AABBi) = AABBi(mins / other.mins, maxs / other.maxs) - - operator fun plus(other: Vector2i) = AABBi(mins + other, maxs + other) - operator fun minus(other: Vector2i) = AABBi(mins - other, maxs - other) - operator fun times(other: Vector2i) = AABBi(mins * other, maxs * other) - operator fun div(other: Vector2i) = AABBi(mins / other, maxs / other) - - operator fun plus(other: Int) = AABBi(mins + other, maxs + other) - operator fun minus(other: Int) = AABBi(mins - other, maxs - other) - operator fun times(other: Int) = AABBi(mins * other, maxs * other) - operator fun div(other: Int) = AABBi(mins / other, maxs / other) - - val xSpan get() = maxs.x - mins.x - val ySpan get() = maxs.y - mins.y - val centre get() = mins.toDoubleVector() + maxs.toDoubleVector() * 0.5 - - val A get() = mins - val B get() = Vector2i(mins.x, maxs.y) - val C get() = maxs - val D get() = Vector2i(maxs.x, mins.y) - - val bottomLeft get() = A - val topLeft get() = B - val topRight get() = C - val bottomRight get() = D - - val width get() = (maxs.x - mins.x) / 2 - val height get() = (maxs.y - mins.y) / 2 - - val diameter get() = mins.distance(maxs) - val radius get() = diameter / 2.0 - - val perimeter get() = (xSpan + ySpan) * 2 - - fun isInside(point: Vector2i): Boolean { - return point.x in mins.x .. maxs.x && point.y in mins.y .. maxs.y - } - - /** - * Есть ли пересечение между этим AABB и [other] - * - * Считается, что они пересекаются, даже если у них просто равна одна из осей - */ - fun intersect(other: AABBi): Boolean { - val intersectX: Boolean - - if (xSpan <= other.xSpan) - intersectX = mins.x in other.mins.x .. other.maxs.x || maxs.x in other.mins.x .. other.maxs.x - else - intersectX = other.mins.x in mins.x .. maxs.x || other.maxs.x in mins.x .. maxs.x - - if (!intersectX) - return false - - val intersectY: Boolean - - if (ySpan <= other.ySpan) - intersectY = mins.y in other.mins.y .. other.maxs.y || maxs.y in other.mins.y .. other.maxs.y - else - intersectY = other.mins.y in mins.y .. maxs.y || other.maxs.y in mins.y .. maxs.y - - return intersectY - } - - /** - * Есть ли пересечение между этим AABB и [other] - * - * Считается, что они НЕ пересекаются, если у них просто равна одна из осей - */ - fun intersectWeak(other: AABBi): Boolean { - if (maxs.x == other.mins.x || mins.x == other.maxs.x || maxs.y == other.mins.y || mins.y == other.maxs.y) - return false - - val intersectX: Boolean - - if (xSpan <= other.xSpan) - intersectX = mins.x in other.mins.x .. other.maxs.x || maxs.x in other.mins.x .. other.maxs.x - else - intersectX = other.mins.x in mins.x .. maxs.x || other.maxs.x in mins.x .. maxs.x - - if (!intersectX) - return false - - val intersectY: Boolean - - if (ySpan <= other.ySpan) - intersectY = mins.y in other.mins.y .. other.maxs.y || maxs.y in other.mins.y .. other.maxs.y - else - intersectY = other.mins.y in mins.y .. maxs.y || other.maxs.y in mins.y .. maxs.y - - return intersectY - } - - fun toDoubleAABB() = AABB(mins.toDoubleVector(), maxs.toDoubleVector()) - - private inner class Iterator(private val factory: (x: Int, y: Int) -> T) : kotlin.collections.Iterator { - private var x = mins.x - private var y = mins.y - private var next = true - - override fun hasNext(): Boolean { - return next - } - - override fun next(): T { - if (!next) - throw IllegalStateException() - - val obj = factory.invoke(x++, y) - - if (x > maxs.x) { - x = mins.x - - if (++y > maxs.y) { - next = false - } - } - - return obj - } - } - - val vectors: kotlin.collections.Iterator get() = Iterator(::Vector2i) - val chunkPositions: kotlin.collections.Iterator get() = Iterator(::ChunkPos) -} - -object AABBiTypeAdapter : TypeAdapter() { - override fun write(out: JsonWriter, value: AABBi) { - `out`.beginArray() - Vector2iTypeAdapter.write(out, value.mins) - Vector2iTypeAdapter.write(out, value.maxs) - `out`.endArray() - } - - override fun read(`in`: JsonReader): AABBi { - val (x1, x2) = Vector2iTypeAdapter.read(`in`) - val (y1, y2) = Vector2iTypeAdapter.read(`in`) - - val xMins = x1.coerceAtMost(x2) - val xMaxs = x1.coerceAtLeast(x2) - - val yMins = y1.coerceAtMost(y2) - val yMaxs = y1.coerceAtLeast(y2) - - return AABBi( - Vector2i(xMins, yMins), - Vector2i(xMaxs, yMaxs), - ) + return obj } } +val AABBi.vectors: kotlin.collections.Iterator get() = Iterator(this, ::Vector2i) +val AABBi.chunkPositions: kotlin.collections.Iterator get() = Iterator(this, ::ChunkPos) diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/math/Matrix.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/math/Matrix.kt deleted file mode 100644 index 1dc63546..00000000 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/math/Matrix.kt +++ /dev/null @@ -1,2525 +0,0 @@ -package ru.dbotthepony.kstarbound.math - -import ru.dbotthepony.kbox2d.api.b2Cross -import ru.dbotthepony.kbox2d.api.b2Dot -import ru.dbotthepony.kstarbound.api.IStruct3d -import ru.dbotthepony.kstarbound.api.IStruct3f -import ru.dbotthepony.kstarbound.api.IStruct4d -import ru.dbotthepony.kstarbound.api.IStruct4f -import java.nio.ByteBuffer -import java.nio.ByteOrder -import java.nio.DoubleBuffer -import java.nio.FloatBuffer -import kotlin.math.PI -import kotlin.math.absoluteValue -import kotlin.math.tan - -interface IMatrixLike { - val columns: Int - val rows: Int -} - -interface IMatrixLikeInt { - operator fun get(row: Int, column: Int): Int -} - -interface IMatrixLikeFloat : IMatrixLike { - operator fun get(row: Int, column: Int): Float -} - -interface IMatrixLikeDouble : IMatrixLike { - operator fun get(row: Int, column: Int): Double -} - -interface IMatrix : IMatrixLike { - operator fun plus(other: IMatrix): IMatrix - operator fun minus(other: IMatrix): IMatrix - operator fun times(other: IMatrix): IMatrix -} - -interface FloatMatrix> : IMatrix, IMatrixLikeFloat { - operator fun plus(other: Float): T - operator fun minus(other: Float): T - operator fun times(other: Float): T - operator fun div(other: Float): T - - override operator fun plus(other: IMatrix): T - override operator fun minus(other: IMatrix): T - override operator fun times(other: IMatrix): T - - /** - * Если матрица больше или меньше, считать что всевозможные остальные координаты равны единице (не менять) - */ - fun scale(x: Float, y: Float = 1f, z: Float = 1f, w: Float = 1f): T - fun scale(value: IStruct4f): T { - val (x, y, z, w) = value - return scale(x, y, z, w) - } - - fun translate(x: Float = 0f, y: Float = 0f, z: Float = 0f): T - fun translate(value: IStruct3f): T { - val (x, y, z) = value - return translate(x, y, z) - } - - fun translateWithScale(x: Float = 0f, y: Float = 0f, z: Float = 0f): T - fun translateWithScale(value: IStruct3f): T { - val (x, y, z) = value - return translateWithScale(x, y, z) - } - - /** - * Выдает массив в готовом для OpenGL виде (строка -> столбец) по умолчанию - */ - fun toFloatArray(columnMajor: Boolean = true): FloatArray { - val buff = FloatArray(rows * columns) - - if (columnMajor) { - for (row in 0 until rows) { - for (column in 0 until columns) { - buff[row + rows * column] = this[row, column] - } - } - } else { - for (row in 0 until rows) { - for (column in 0 until columns) { - buff[row * columns + column] = this[row, column] - } - } - } - - return buff - } -} - -interface DoubleMatrix> : IMatrix, IMatrixLikeDouble { - operator fun plus(other: Double): T - operator fun minus(other: Double): T - operator fun times(other: Double): T - operator fun div(other: Double): T - - override operator fun plus(other: IMatrix): T - override operator fun minus(other: IMatrix): T - override operator fun times(other: IMatrix): T - - /** - * Если матрица больше или меньше, считать что всевозможные остальные координаты равны единице (не менять) - */ - fun scale(x: Double, y: Double = 1.0, z: Double = 1.0, w: Double = 1.0): T - - fun scale(value: IStruct4d): T { - val (x, y, z, w) = value - return scale(x, y, z, w) - } - - fun translate(x: Double = 0.0, y: Double = 0.0, z: Double = 0.0): T - - fun translate(value: IStruct3d): T { - val (x, y, z) = value - return translate(x, y, z) - } - - fun translateWithScale(x: Double = 0.0, y: Double = 0.0, z: Double = 0.0): T - - fun translateWithScale(value: IStruct3d): T { - val (x, y, z) = value - return translateWithScale(x, y, z) - } - - /** - * Выдает массив в готовом для OpenGL виде (строка -> столбец) по умолчанию - */ - fun toDoubleArray(columnMajor: Boolean = true): DoubleArray { - val buff = DoubleArray(rows * columns) - - if (columnMajor) { - for (row in 0 until rows) { - for (column in 0 until columns) { - buff[row + rows * column] = this[row, column] - } - } - } else { - for (row in 0 until rows) { - for (column in 0 until columns) { - buff[row * columns + column] = this[row, column] - } - } - } - - return buff - } -} - -interface MutableFloatMatrix> : FloatMatrix { - operator fun set(row: Int, column: Int, value: Float) -} - -abstract class AbstractMatrix4f> : FloatMatrix { - companion object { - private val directBuffer by lazy { ByteBuffer.allocateDirect(4 * 4 * 4).also { it.order(ByteOrder.nativeOrder()) }.asFloatBuffer()!! } - } - - /** - * Наполняет синглтон и возвращает DirectFloatBuffer который необходимо использовать сразу, - * нет никаких гарантий что он не будет изменён в дальнейшем - * - * Функция предназначена исключительно для загрузки данной матрицы в память видеокарты - * - * Данный буфер всегда будет одним и тем же, но его содержимое обновлено - */ - fun toFloatBuffer(columnMajor: Boolean = true): FloatBuffer { - val directBuffer = directBuffer - directBuffer.position(0) - - if (columnMajor) { - directBuffer.put(m00) - directBuffer.put(m10) - directBuffer.put(m20) - directBuffer.put(m30) - - directBuffer.put(m01) - directBuffer.put(m11) - directBuffer.put(m21) - directBuffer.put(m31) - - directBuffer.put(m02) - directBuffer.put(m12) - directBuffer.put(m22) - directBuffer.put(m32) - - directBuffer.put(m03) - directBuffer.put(m13) - directBuffer.put(m23) - directBuffer.put(m33) - } else { - directBuffer.put(m00) - directBuffer.put(m01) - directBuffer.put(m02) - directBuffer.put(m03) - - directBuffer.put(m10) - directBuffer.put(m11) - directBuffer.put(m12) - directBuffer.put(m13) - - directBuffer.put(m20) - directBuffer.put(m21) - directBuffer.put(m22) - directBuffer.put(m23) - - directBuffer.put(m30) - directBuffer.put(m31) - directBuffer.put(m32) - directBuffer.put(m33) - } - - directBuffer.position(0) - return directBuffer - } - - abstract val m00: Float; abstract val m01: Float; abstract val m02: Float; abstract val m03: Float - abstract val m10: Float; abstract val m11: Float; abstract val m12: Float; abstract val m13: Float - abstract val m20: Float; abstract val m21: Float; abstract val m22: Float; abstract val m23: Float - abstract val m30: Float; abstract val m31: Float; abstract val m32: Float; abstract val m33: Float - - override val columns: Int - get() = 4 - - override val rows: Int - get() = 4 - - override fun get(row: Int, column: Int): Float { - return when (column) { - 0 -> when (row) { - 0 -> m00 - 1 -> m10 - 2 -> m20 - 3 -> m30 - else -> throw IndexOutOfBoundsException("Row: $row") - } - - 1 -> when (row) { - 0 -> m01 - 1 -> m11 - 2 -> m21 - 3 -> m31 - else -> throw IndexOutOfBoundsException("Row: $row") - } - - 2 -> when (row) { - 0 -> m02 - 1 -> m12 - 2 -> m22 - 3 -> m32 - else -> throw IndexOutOfBoundsException("Row: $row") - } - - 3 -> when (row) { - 0 -> m03 - 1 -> m13 - 2 -> m23 - 3 -> m33 - else -> throw IndexOutOfBoundsException("Row: $row") - } - - else -> throw IndexOutOfBoundsException("Column: $column") - } - } - - protected abstract fun createOrModify( - m00: Float, m01: Float, m02: Float, m03: Float, - m10: Float, m11: Float, m12: Float, m13: Float, - m20: Float, m21: Float, m22: Float, m23: Float, - m30: Float, m31: Float, m32: Float, m33: Float, - ): T - - override fun plus(other: IMatrix): T { - if (other !is IMatrixLikeFloat) { - throw IllegalArgumentException("Can not use $other for addition") - } - - if (other.columns != 4 || other.rows != 4) { - throw IllegalArgumentException("Concrete Matrix4f can only use 4x4 matrixes") - } - - val m00: Float; val m01: Float; val m02: Float; val m03: Float; - val m10: Float; val m11: Float; val m12: Float; val m13: Float; - val m20: Float; val m21: Float; val m22: Float; val m23: Float; - val m30: Float; val m31: Float; val m32: Float; val m33: Float; - - if (other is AbstractMatrix4f<*>) { - m00 = other.m00; m01 = other.m01; m02 = other.m02; m03 = other.m03; - m10 = other.m10; m11 = other.m11; m12 = other.m12; m13 = other.m13; - m20 = other.m20; m21 = other.m21; m22 = other.m22; m23 = other.m23; - m30 = other.m30; m31 = other.m31; m32 = other.m32; m33 = other.m33; - } else { - m00 = other[0, 0]; m01 = other[0, 1]; m02 = other[0, 2]; m03 = other[0, 3]; - m10 = other[1, 0]; m11 = other[1, 1]; m12 = other[1, 2]; m13 = other[1, 3]; - m20 = other[2, 0]; m21 = other[2, 1]; m22 = other[2, 2]; m23 = other[2, 3]; - m30 = other[3, 0]; m31 = other[3, 1]; m32 = other[3, 2]; m33 = other[3, 3]; - } - - return createOrModify( - this.m00 + m00, this.m01 + m01, this.m02 + m02, this.m03 + m03, - this.m10 + m10, this.m11 + m11, this.m12 + m12, this.m13 + m13, - this.m20 + m20, this.m21 + m21, this.m22 + m22, this.m23 + m23, - this.m30 + m30, this.m31 + m31, this.m32 + m32, this.m33 + m33, - ) - } - - override fun minus(other: IMatrix): T { - if (other !is IMatrixLikeFloat) { - throw IllegalArgumentException("Can not use $other for subtraction") - } - - if (other.columns != 4 || other.rows != 4) { - throw IllegalArgumentException("Concrete Matrix4f can only use 4x4 matrices") - } - - val m00: Float; val m01: Float; val m02: Float; val m03: Float; - val m10: Float; val m11: Float; val m12: Float; val m13: Float; - val m20: Float; val m21: Float; val m22: Float; val m23: Float; - val m30: Float; val m31: Float; val m32: Float; val m33: Float; - - if (other is AbstractMatrix4f<*>) { - m00 = other.m00; m01 = other.m01; m02 = other.m02; m03 = other.m03; - m10 = other.m10; m11 = other.m11; m12 = other.m12; m13 = other.m13; - m20 = other.m20; m21 = other.m21; m22 = other.m22; m23 = other.m23; - m30 = other.m30; m31 = other.m31; m32 = other.m32; m33 = other.m33; - } else { - m00 = other[0, 0]; m01 = other[0, 1]; m02 = other[0, 2]; m03 = other[0, 3]; - m10 = other[1, 0]; m11 = other[1, 1]; m12 = other[1, 2]; m13 = other[1, 3]; - m20 = other[2, 0]; m21 = other[2, 1]; m22 = other[2, 2]; m23 = other[2, 3]; - m30 = other[3, 0]; m31 = other[3, 1]; m32 = other[3, 2]; m33 = other[3, 3]; - } - - return createOrModify( - this.m00 - m00, this.m01 - m01, this.m02 - m02, this.m03 - m03, - this.m10 - m10, this.m11 - m11, this.m12 - m12, this.m13 - m13, - this.m20 - m20, this.m21 - m21, this.m22 - m22, this.m23 - m23, - this.m30 - m30, this.m31 - m31, this.m32 - m32, this.m33 - m33, - ) - } - - override fun plus(other: Float): T { - return createOrModify( - this.m00 + other, this.m01 + other, this.m02 + other, this.m03 + other, - this.m10 + other, this.m11 + other, this.m12 + other, this.m13 + other, - this.m20 + other, this.m21 + other, this.m22 + other, this.m23 + other, - this.m30 + other, this.m31 + other, this.m32 + other, this.m33 + other, - ) - } - - override fun minus(other: Float): T { - return createOrModify( - this.m00 - other, this.m01 - other, this.m02 - other, this.m03 - other, - this.m10 - other, this.m11 - other, this.m12 - other, this.m13 - other, - this.m20 - other, this.m21 - other, this.m22 - other, this.m23 - other, - this.m30 - other, this.m31 - other, this.m32 - other, this.m33 - other, - ) - } - - override fun times(other: Float): T { - return createOrModify( - this.m00 * other, this.m01 * other, this.m02 * other, this.m03 * other, - this.m10 * other, this.m11 * other, this.m12 * other, this.m13 * other, - this.m20 * other, this.m21 * other, this.m22 * other, this.m23 * other, - this.m30 * other, this.m31 * other, this.m32 * other, this.m33 * other, - ) - } - - override fun scale(x: Float, y: Float, z: Float, w: Float): T { - return createOrModify( - this.m00 * x, this.m01, this.m02, this.m03, - this.m10, this.m11 * y, this.m12, this.m13, - this.m20, this.m21, this.m22 * z, this.m23, - this.m30, this.m31, this.m32, this.m33 * w, - ) - } - - override fun translate(x: Float, y: Float, z: Float): T { - return createOrModify( - this.m00, this.m01, this.m02, this.m03 + x, - this.m10, this.m11, this.m12, this.m13 + y, - this.m20, this.m21, this.m22, this.m23 + z, - this.m30, this.m31, this.m32, this.m33, - ) - } - - open val translation: Vector3f - get() { - return Vector3f(m03, m13, m23) - } - - override fun div(other: Float): T { - return createOrModify( - this.m00 / other, this.m01 / other, this.m02 / other, this.m03 / other, - this.m10 / other, this.m11 / other, this.m12 / other, this.m13 / other, - this.m20 / other, this.m21 / other, this.m22 / other, this.m23 / other, - this.m30 / other, this.m31 / other, this.m32 / other, this.m33 / other, - ) - } - - override fun times(other: IMatrix): T { - if (other !is IMatrixLikeFloat) { - throw IllegalArgumentException("Can not use $other for multiplication") - } - - if (other.columns != 4 || other.rows != 4) { - throw IllegalArgumentException("Concrete Matrix4f can only use 4x4 matrices") - } - - val m00: Float; val m01: Float; val m02: Float; val m03: Float; - val m10: Float; val m11: Float; val m12: Float; val m13: Float; - val m20: Float; val m21: Float; val m22: Float; val m23: Float; - val m30: Float; val m31: Float; val m32: Float; val m33: Float; - - if (other is AbstractMatrix4f<*>) { - m00 = other.m00; m01 = other.m01; m02 = other.m02; m03 = other.m03; - m10 = other.m10; m11 = other.m11; m12 = other.m12; m13 = other.m13; - m20 = other.m20; m21 = other.m21; m22 = other.m22; m23 = other.m23; - m30 = other.m30; m31 = other.m31; m32 = other.m32; m33 = other.m33; - } else { - m00 = other[0, 0]; m01 = other[0, 1]; m02 = other[0, 2]; m03 = other[0, 3]; - m10 = other[1, 0]; m11 = other[1, 1]; m12 = other[1, 2]; m13 = other[1, 3]; - m20 = other[2, 0]; m21 = other[2, 1]; m22 = other[2, 2]; m23 = other[2, 3]; - m30 = other[3, 0]; m31 = other[3, 1]; m32 = other[3, 2]; m33 = other[3, 3]; - } - - // первый столбец - val newm00 = - this.m00 * m00 + - this.m01 * m10 + - this.m02 * m20 + - this.m03 * m30 - - val newm10 = - this.m10 * m00 + - this.m11 * m10 + - this.m12 * m20 + - this.m13 * m30 - - val newm20 = - this.m20 * m00 + - this.m21 * m10 + - this.m22 * m20 + - this.m23 * m30 - - val newm30 = - this.m30 * m00 + - this.m31 * m10 + - this.m32 * m20 + - this.m33 * m30 - - // второй столбец - val newm01 = - this.m00 * m01 + - this.m01 * m11 + - this.m02 * m21 + - this.m03 * m31 - - val newm11 = - this.m10 * m01 + - this.m11 * m11 + - this.m12 * m21 + - this.m13 * m31 - - val newm21 = - this.m20 * m01 + - this.m21 * m11 + - this.m22 * m21 + - this.m23 * m31 - - val newm31 = - this.m30 * m01 + - this.m31 * m11 + - this.m32 * m21 + - this.m33 * m31 - - // третий столбец - val newm02 = - this.m00 * m02 + - this.m01 * m12 + - this.m02 * m22 + - this.m03 * m32 - - val newm12 = - this.m10 * m02 + - this.m11 * m12 + - this.m12 * m22 + - this.m13 * m32 - - val newm22 = - this.m20 * m02 + - this.m21 * m12 + - this.m22 * m22 + - this.m23 * m32 - - val newm32 = - this.m30 * m02 + - this.m31 * m12 + - this.m32 * m22 + - this.m33 * m32 - - // четвёртый столбец - val newm03 = - this.m00 * m03 + - this.m01 * m13 + - this.m02 * m23 + - this.m03 * m33 - - val newm13 = - this.m10 * m03 + - this.m11 * m13 + - this.m12 * m23 + - this.m13 * m33 - - val newm23 = - this.m20 * m03 + - this.m21 * m13 + - this.m22 * m23 + - this.m23 * m33 - - val newm33 = - this.m30 * m03 + - this.m31 * m13 + - this.m32 * m23 + - this.m33 * m33 - - return createOrModify( - newm00, newm01, newm02, newm03, - newm10, newm11, newm12, newm13, - newm20, newm21, newm22, newm23, - newm30, newm31, newm32, newm33, - ) - } - - override fun translateWithScale(x: Float, y: Float, z: Float): T { - return createOrModify( - m00, m01, m02, m03 + x * m00 + y * m01 + z * m02, - m10, m11, m12, m13 + x * m10 + y * m11 + z * m12, - m20, m21, m22, m23 + x * m20 + y * m21 + z * m22, - m30, m31, m32, m33, - ) - } - - val absoluteMatrix get() = Matrix4f( - m00 = m00.absoluteValue, m01 = m01.absoluteValue, m02 = m02.absoluteValue, m03 = m03.absoluteValue, - m10 = m10.absoluteValue, m11 = m11.absoluteValue, m12 = m12.absoluteValue, m13 = m13.absoluteValue, - m20 = m20.absoluteValue, m21 = m21.absoluteValue, m22 = m22.absoluteValue, m23 = m23.absoluteValue, - m30 = m30.absoluteValue, m31 = m31.absoluteValue, m32 = m32.absoluteValue, m33 = m33.absoluteValue, - ) -} - -data class Matrix4f( - override val m00: Float = 1f, override val m01: Float = 0f, override val m02: Float = 0f, override val m03: Float = 0f, - override val m10: Float = 0f, override val m11: Float = 1f, override val m12: Float = 0f, override val m13: Float = 0f, - override val m20: Float = 0f, override val m21: Float = 0f, override val m22: Float = 1f, override val m23: Float = 0f, - override val m30: Float = 0f, override val m31: Float = 0f, override val m32: Float = 0f, override val m33: Float = 1f, -) : AbstractMatrix4f() { - override fun createOrModify( - m00: Float, m01: Float, m02: Float, m03: Float, - m10: Float, m11: Float, m12: Float, m13: Float, - m20: Float, m21: Float, m22: Float, m23: Float, - m30: Float, m31: Float, m32: Float, m33: Float, - ): Matrix4f { - return Matrix4f( - m00 = m00, m01 = m01, m02 = m02, m03 = m03, - m10 = m10, m11 = m11, m12 = m12, m13 = m13, - m20 = m20, m21 = m21, m22 = m22, m23 = m23, - m30 = m30, m31 = m31, m32 = m32, m33 = m33, - ) - } - - fun toMutableMatrix(): MutableMatrix4f { - return MutableMatrix4f( - m00 = m00, m01 = m01, m02 = m02, m03 = m03, - m10 = m10, m11 = m11, m12 = m12, m13 = m13, - m20 = m20, m21 = m21, m22 = m22, m23 = m23, - m30 = m30, m31 = m31, m32 = m32, m33 = m33, - ) - } - - companion object { - val IDENTITY = Matrix4f() - - val SCREEN_FLIP = IDENTITY.let { - return@let it * Vector3f.FORWARD.rotateAroundThis(-PI / 2) - } - - /** - * Возвращает матрицу ортографической проекции, с ИНВЕНТИРОВАННОЙ y координатой, и с добавлением 2f - * - * Т.е. любое значение компоненты вектора y будет иметь противоположный знак после перемножения на данную матрицу - * - * Смысл данного изменения знака в преобразовании экранных координат OpenGL к вменяемому виду. Многие примеры указывают Z как отрицательную компоненту, - * что так же "убирает" это недоумение, только вот у нас Z это глубина, а не высота - * - * y = 0 будет соответствовать верхнему левому углу окна - */ - fun ortho(left: Float, right: Float, bottom: Float, top: Float, zNear: Float, zFar: Float): Matrix4f { - return Matrix4f( - m00 = 2f / (right - left), - m11 = -2f / (top - bottom), - m22 = 2f / (zFar - zNear), - m03 = -(right + left) / (right - left), - m13 = -(top + bottom) / (top - bottom) + 2f, - m23 = -(zFar + zNear) / (zFar - zNear) - ) - } - - /** - * Возвращает матрицу ортографической проекции, без инвентирования - * - * y = 0 будет соответствовать нижнему левому углу окна - */ - fun orthoDirect(left: Float, right: Float, bottom: Float, top: Float, zNear: Float, zFar: Float): Matrix4f { - return Matrix4f( - m00 = 2f / (right - left), - m11 = 2f / (top - bottom), - m22 = 2f / (zFar - zNear), - m03 = -(right + left) / (right - left), - m13 = -(top + bottom) / (top - bottom), - m23 = -(zFar + zNear) / (zFar - zNear) - ) - } - - fun perspective(fov: Float, zFar: Float, zNear: Float): Matrix4f { - val scale = (1.0 / (tan(Math.toRadians(fov.toDouble()) / 2.0))).toFloat() - val r = zFar - zNear - - return Matrix4f( - m00 = scale, - m11 = scale, - m22 = -zFar / r, - m23 = -1f, - m32 = -zFar * zNear / r, - ) - } - } -} - -data class MutableMatrix4f( - override var m00: Float = 1f, override var m01: Float = 0f, override var m02: Float = 0f, override var m03: Float = 0f, - override var m10: Float = 0f, override var m11: Float = 1f, override var m12: Float = 0f, override var m13: Float = 0f, - override var m20: Float = 0f, override var m21: Float = 0f, override var m22: Float = 1f, override var m23: Float = 0f, - override var m30: Float = 0f, override var m31: Float = 0f, override var m32: Float = 0f, override var m33: Float = 1f, -) : AbstractMatrix4f() { - override fun createOrModify( - m00: Float, m01: Float, m02: Float, m03: Float, - m10: Float, m11: Float, m12: Float, m13: Float, - m20: Float, m21: Float, m22: Float, m23: Float, - m30: Float, m31: Float, m32: Float, m33: Float, - ): MutableMatrix4f { - this.m00 = m00; this.m01 = m01; this.m02 = m02; this.m03 = m03 - this.m10 = m10; this.m11 = m11; this.m12 = m12; this.m13 = m13 - this.m20 = m20; this.m21 = m21; this.m22 = m22; this.m23 = m23 - this.m30 = m30; this.m31 = m31; this.m32 = m32; this.m33 = m33 - - return this - } - - override var translation: Vector3f - get() { - return Vector3f(m03, m13, m23) - } - set(value) { - translate(value) - } - - fun set(row: Int, column: Int, value: Float) { - when (column) { - 0 -> when (row) { - 0 -> m00 = value - 1 -> m10 = value - 2 -> m20 = value - 3 -> m30 = value - else -> throw IndexOutOfBoundsException("Row: $row") - } - - 1 -> when (row) { - 0 -> m01 = value - 1 -> m11 = value - 2 -> m21 = value - 3 -> m31 = value - else -> throw IndexOutOfBoundsException("Row: $row") - } - - 2 -> when (row) { - 0 -> m02 = value - 1 -> m12 = value - 2 -> m22 = value - 3 -> m32 = value - else -> throw IndexOutOfBoundsException("Row: $row") - } - - 3 -> when (row) { - 0 -> m03 = value - 1 -> m13 = value - 2 -> m23 = value - 3 -> m33 = value - else -> throw IndexOutOfBoundsException("Row: $row") - } - - else -> throw IndexOutOfBoundsException("Column: $column") - } - } -} - -abstract class AbstractMatrix4d> : DoubleMatrix { - companion object { - private val directBuffer by lazy { ByteBuffer.allocateDirect(4 * 4 * 4).also { it.order(ByteOrder.nativeOrder()) }.asDoubleBuffer()!! } - } - - /** - * Наполняет синглтон и возвращает DirectDoubleBuffer который необходимо использовать сразу, - * нет никаких гарантий что он не будет изменён в дальнейшем - * - * Функция предназначена исключительно для загрузки данной матрицы в память видеокарты - * - * Данный буфер всегда будет одним и тем же, но его содержимое обновлено - */ - fun toDoubleBuffer(columnMajor: Boolean = true): DoubleBuffer { - val directBuffer = directBuffer - directBuffer.position(0) - - if (columnMajor) { - directBuffer.put(m00) - directBuffer.put(m10) - directBuffer.put(m20) - directBuffer.put(m30) - - directBuffer.put(m01) - directBuffer.put(m11) - directBuffer.put(m21) - directBuffer.put(m31) - - directBuffer.put(m02) - directBuffer.put(m12) - directBuffer.put(m22) - directBuffer.put(m32) - - directBuffer.put(m03) - directBuffer.put(m13) - directBuffer.put(m23) - directBuffer.put(m33) - } else { - directBuffer.put(m00) - directBuffer.put(m01) - directBuffer.put(m02) - directBuffer.put(m03) - - directBuffer.put(m10) - directBuffer.put(m11) - directBuffer.put(m12) - directBuffer.put(m13) - - directBuffer.put(m20) - directBuffer.put(m21) - directBuffer.put(m22) - directBuffer.put(m23) - - directBuffer.put(m30) - directBuffer.put(m31) - directBuffer.put(m32) - directBuffer.put(m33) - } - - directBuffer.position(0) - return directBuffer - } - - abstract val m00: Double; abstract val m01: Double; abstract val m02: Double; abstract val m03: Double - abstract val m10: Double; abstract val m11: Double; abstract val m12: Double; abstract val m13: Double - abstract val m20: Double; abstract val m21: Double; abstract val m22: Double; abstract val m23: Double - abstract val m30: Double; abstract val m31: Double; abstract val m32: Double; abstract val m33: Double - - override val columns: Int - get() = 4 - - override val rows: Int - get() = 4 - - override fun get(row: Int, column: Int): Double { - return when (column) { - 0 -> when (row) { - 0 -> m00 - 1 -> m10 - 2 -> m20 - 3 -> m30 - else -> throw IndexOutOfBoundsException("Row: $row") - } - - 1 -> when (row) { - 0 -> m01 - 1 -> m11 - 2 -> m21 - 3 -> m31 - else -> throw IndexOutOfBoundsException("Row: $row") - } - - 2 -> when (row) { - 0 -> m02 - 1 -> m12 - 2 -> m22 - 3 -> m32 - else -> throw IndexOutOfBoundsException("Row: $row") - } - - 3 -> when (row) { - 0 -> m03 - 1 -> m13 - 2 -> m23 - 3 -> m33 - else -> throw IndexOutOfBoundsException("Row: $row") - } - - else -> throw IndexOutOfBoundsException("Column: $column") - } - } - - protected abstract fun createOrModify( - m00: Double, m01: Double, m02: Double, m03: Double, - m10: Double, m11: Double, m12: Double, m13: Double, - m20: Double, m21: Double, m22: Double, m23: Double, - m30: Double, m31: Double, m32: Double, m33: Double, - ): T - - override fun plus(other: IMatrix): T { - if (other !is IMatrixLikeDouble) { - throw IllegalArgumentException("Can not use $other for addition") - } - - if (other.columns != 4 || other.rows != 4) { - throw IllegalArgumentException("Concrete Matrix4d can only use 4x4 matrixes") - } - - val m00: Double; val m01: Double; val m02: Double; val m03: Double; - val m10: Double; val m11: Double; val m12: Double; val m13: Double; - val m20: Double; val m21: Double; val m22: Double; val m23: Double; - val m30: Double; val m31: Double; val m32: Double; val m33: Double; - - if (other is AbstractMatrix4d<*>) { - m00 = other.m00; m01 = other.m01; m02 = other.m02; m03 = other.m03; - m10 = other.m10; m11 = other.m11; m12 = other.m12; m13 = other.m13; - m20 = other.m20; m21 = other.m21; m22 = other.m22; m23 = other.m23; - m30 = other.m30; m31 = other.m31; m32 = other.m32; m33 = other.m33; - } else { - m00 = other[0, 0]; m01 = other[0, 1]; m02 = other[0, 2]; m03 = other[0, 3]; - m10 = other[1, 0]; m11 = other[1, 1]; m12 = other[1, 2]; m13 = other[1, 3]; - m20 = other[2, 0]; m21 = other[2, 1]; m22 = other[2, 2]; m23 = other[2, 3]; - m30 = other[3, 0]; m31 = other[3, 1]; m32 = other[3, 2]; m33 = other[3, 3]; - } - - return createOrModify( - this.m00 + m00, this.m01 + m01, this.m02 + m02, this.m03 + m03, - this.m10 + m10, this.m11 + m11, this.m12 + m12, this.m13 + m13, - this.m20 + m20, this.m21 + m21, this.m22 + m22, this.m23 + m23, - this.m30 + m30, this.m31 + m31, this.m32 + m32, this.m33 + m33, - ) - } - - override fun minus(other: IMatrix): T { - if (other !is IMatrixLikeDouble) { - throw IllegalArgumentException("Can not use $other for subtraction") - } - - if (other.columns != 4 || other.rows != 4) { - throw IllegalArgumentException("Concrete Matrix4d can only use 4x4 matrices") - } - - val m00: Double; val m01: Double; val m02: Double; val m03: Double; - val m10: Double; val m11: Double; val m12: Double; val m13: Double; - val m20: Double; val m21: Double; val m22: Double; val m23: Double; - val m30: Double; val m31: Double; val m32: Double; val m33: Double; - - if (other is AbstractMatrix4d<*>) { - m00 = other.m00; m01 = other.m01; m02 = other.m02; m03 = other.m03; - m10 = other.m10; m11 = other.m11; m12 = other.m12; m13 = other.m13; - m20 = other.m20; m21 = other.m21; m22 = other.m22; m23 = other.m23; - m30 = other.m30; m31 = other.m31; m32 = other.m32; m33 = other.m33; - } else { - m00 = other[0, 0]; m01 = other[0, 1]; m02 = other[0, 2]; m03 = other[0, 3]; - m10 = other[1, 0]; m11 = other[1, 1]; m12 = other[1, 2]; m13 = other[1, 3]; - m20 = other[2, 0]; m21 = other[2, 1]; m22 = other[2, 2]; m23 = other[2, 3]; - m30 = other[3, 0]; m31 = other[3, 1]; m32 = other[3, 2]; m33 = other[3, 3]; - } - - return createOrModify( - this.m00 - m00, this.m01 - m01, this.m02 - m02, this.m03 - m03, - this.m10 - m10, this.m11 - m11, this.m12 - m12, this.m13 - m13, - this.m20 - m20, this.m21 - m21, this.m22 - m22, this.m23 - m23, - this.m30 - m30, this.m31 - m31, this.m32 - m32, this.m33 - m33, - ) - } - - override fun plus(other: Double): T { - return createOrModify( - this.m00 + other, this.m01 + other, this.m02 + other, this.m03 + other, - this.m10 + other, this.m11 + other, this.m12 + other, this.m13 + other, - this.m20 + other, this.m21 + other, this.m22 + other, this.m23 + other, - this.m30 + other, this.m31 + other, this.m32 + other, this.m33 + other, - ) - } - - override fun minus(other: Double): T { - return createOrModify( - this.m00 - other, this.m01 - other, this.m02 - other, this.m03 - other, - this.m10 - other, this.m11 - other, this.m12 - other, this.m13 - other, - this.m20 - other, this.m21 - other, this.m22 - other, this.m23 - other, - this.m30 - other, this.m31 - other, this.m32 - other, this.m33 - other, - ) - } - - override fun times(other: Double): T { - return createOrModify( - this.m00 * other, this.m01 * other, this.m02 * other, this.m03 * other, - this.m10 * other, this.m11 * other, this.m12 * other, this.m13 * other, - this.m20 * other, this.m21 * other, this.m22 * other, this.m23 * other, - this.m30 * other, this.m31 * other, this.m32 * other, this.m33 * other, - ) - } - - override fun scale(x: Double, y: Double, z: Double, w: Double): T { - return createOrModify( - this.m00 * x, this.m01, this.m02, this.m03, - this.m10, this.m11 * y, this.m12, this.m13, - this.m20, this.m21, this.m22 * z, this.m23, - this.m30, this.m31, this.m32, this.m33 * w, - ) - } - - override fun translate(x: Double, y: Double, z: Double): T { - return createOrModify( - this.m00, this.m01, this.m02, this.m03 + x, - this.m10, this.m11, this.m12, this.m13 + y, - this.m20, this.m21, this.m22, this.m23 + z, - this.m30, this.m31, this.m32, this.m33, - ) - } - - open val translation: Vector3d - get() { - return Vector3d(m03, m13, m23) - } - - override fun div(other: Double): T { - return createOrModify( - this.m00 / other, this.m01 / other, this.m02 / other, this.m03 / other, - this.m10 / other, this.m11 / other, this.m12 / other, this.m13 / other, - this.m20 / other, this.m21 / other, this.m22 / other, this.m23 / other, - this.m30 / other, this.m31 / other, this.m32 / other, this.m33 / other, - ) - } - - override fun times(other: IMatrix): T { - if (other !is IMatrixLikeDouble) { - throw IllegalArgumentException("Can not use $other for multiplication") - } - - if (other.columns != 4 || other.rows != 4) { - throw IllegalArgumentException("Concrete Matrix4d can only use 4x4 matrices") - } - - val m00: Double; val m01: Double; val m02: Double; val m03: Double; - val m10: Double; val m11: Double; val m12: Double; val m13: Double; - val m20: Double; val m21: Double; val m22: Double; val m23: Double; - val m30: Double; val m31: Double; val m32: Double; val m33: Double; - - if (other is AbstractMatrix4d<*>) { - m00 = other.m00; m01 = other.m01; m02 = other.m02; m03 = other.m03; - m10 = other.m10; m11 = other.m11; m12 = other.m12; m13 = other.m13; - m20 = other.m20; m21 = other.m21; m22 = other.m22; m23 = other.m23; - m30 = other.m30; m31 = other.m31; m32 = other.m32; m33 = other.m33; - } else { - m00 = other[0, 0]; m01 = other[0, 1]; m02 = other[0, 2]; m03 = other[0, 3]; - m10 = other[1, 0]; m11 = other[1, 1]; m12 = other[1, 2]; m13 = other[1, 3]; - m20 = other[2, 0]; m21 = other[2, 1]; m22 = other[2, 2]; m23 = other[2, 3]; - m30 = other[3, 0]; m31 = other[3, 1]; m32 = other[3, 2]; m33 = other[3, 3]; - } - - // первый столбец - val newm00 = - this.m00 * m00 + - this.m01 * m10 + - this.m02 * m20 + - this.m03 * m30 - - val newm10 = - this.m10 * m00 + - this.m11 * m10 + - this.m12 * m20 + - this.m13 * m30 - - val newm20 = - this.m20 * m00 + - this.m21 * m10 + - this.m22 * m20 + - this.m23 * m30 - - val newm30 = - this.m30 * m00 + - this.m31 * m10 + - this.m32 * m20 + - this.m33 * m30 - - // второй столбец - val newm01 = - this.m00 * m01 + - this.m01 * m11 + - this.m02 * m21 + - this.m03 * m31 - - val newm11 = - this.m10 * m01 + - this.m11 * m11 + - this.m12 * m21 + - this.m13 * m31 - - val newm21 = - this.m20 * m01 + - this.m21 * m11 + - this.m22 * m21 + - this.m23 * m31 - - val newm31 = - this.m30 * m01 + - this.m31 * m11 + - this.m32 * m21 + - this.m33 * m31 - - // третий столбец - val newm02 = - this.m00 * m02 + - this.m01 * m12 + - this.m02 * m22 + - this.m03 * m32 - - val newm12 = - this.m10 * m02 + - this.m11 * m12 + - this.m12 * m22 + - this.m13 * m32 - - val newm22 = - this.m20 * m02 + - this.m21 * m12 + - this.m22 * m22 + - this.m23 * m32 - - val newm32 = - this.m30 * m02 + - this.m31 * m12 + - this.m32 * m22 + - this.m33 * m32 - - // четвёртый столбец - val newm03 = - this.m00 * m03 + - this.m01 * m13 + - this.m02 * m23 + - this.m03 * m33 - - val newm13 = - this.m10 * m03 + - this.m11 * m13 + - this.m12 * m23 + - this.m13 * m33 - - val newm23 = - this.m20 * m03 + - this.m21 * m13 + - this.m22 * m23 + - this.m23 * m33 - - val newm33 = - this.m30 * m03 + - this.m31 * m13 + - this.m32 * m23 + - this.m33 * m33 - - return createOrModify( - newm00, newm01, newm02, newm03, - newm10, newm11, newm12, newm13, - newm20, newm21, newm22, newm23, - newm30, newm31, newm32, newm33, - ) - } - - override fun translateWithScale(x: Double, y: Double, z: Double): T { - return createOrModify( - m00, m01, m02, m03 + x * m00 + y * m01 + z * m02, - m10, m11, m12, m13 + x * m10 + y * m11 + z * m12, - m20, m21, m22, m23 + x * m20 + y * m21 + z * m22, - m30, m31, m32, m33, - ) - } - - val absoluteMatrix get() = Matrix4d( - m00 = m00.absoluteValue, m01 = m01.absoluteValue, m02 = m02.absoluteValue, m03 = m03.absoluteValue, - m10 = m10.absoluteValue, m11 = m11.absoluteValue, m12 = m12.absoluteValue, m13 = m13.absoluteValue, - m20 = m20.absoluteValue, m21 = m21.absoluteValue, m22 = m22.absoluteValue, m23 = m23.absoluteValue, - m30 = m30.absoluteValue, m31 = m31.absoluteValue, m32 = m32.absoluteValue, m33 = m33.absoluteValue, - ) -} - -data class Matrix4d( - override val m00: Double = 1.0, override val m01: Double = 0.0, override val m02: Double = 0.0, override val m03: Double = 0.0, - override val m10: Double = 0.0, override val m11: Double = 1.0, override val m12: Double = 0.0, override val m13: Double = 0.0, - override val m20: Double = 0.0, override val m21: Double = 0.0, override val m22: Double = 1.0, override val m23: Double = 0.0, - override val m30: Double = 0.0, override val m31: Double = 0.0, override val m32: Double = 0.0, override val m33: Double = 1.0, -) : AbstractMatrix4d() { - override fun createOrModify( - m00: Double, m01: Double, m02: Double, m03: Double, - m10: Double, m11: Double, m12: Double, m13: Double, - m20: Double, m21: Double, m22: Double, m23: Double, - m30: Double, m31: Double, m32: Double, m33: Double, - ): Matrix4d { - return Matrix4d( - m00 = m00, m01 = m01, m02 = m02, m03 = m03, - m10 = m10, m11 = m11, m12 = m12, m13 = m13, - m20 = m20, m21 = m21, m22 = m22, m23 = m23, - m30 = m30, m31 = m31, m32 = m32, m33 = m33, - ) - } - - fun toMutableMatrix(): MutableMatrix4d { - return MutableMatrix4d( - m00 = m00, m01 = m01, m02 = m02, m03 = m03, - m10 = m10, m11 = m11, m12 = m12, m13 = m13, - m20 = m20, m21 = m21, m22 = m22, m23 = m23, - m30 = m30, m31 = m31, m32 = m32, m33 = m33, - ) - } - - companion object { - val IDENTITY = Matrix4d() - - val SCREEN_FLIP = IDENTITY.let { - return@let it * Vector3d.FORWARD.rotateAroundThis(-PI / 2) - } - - /** - * Возвращает матрицу ортографической проекции, с ИНВЕНТИРОВАННОЙ y координатой, и с добавлением 2f - * - * Т.е. любое значение компоненты вектора y будет иметь противоположный знак после перемножения на данную матрицу - * - * Смысл данного изменения знака в преобразовании экранных координат OpenGL к вменяемому виду. Многие примеры указывают Z как отрицательную компоненту, - * что так же "убирает" это недоумение, только вот у нас Z это глубина, а не высота - * - * y = 0 будет соответствовать верхнему левому углу окна - */ - fun ortho(left: Double, right: Double, bottom: Double, top: Double, zNear: Double, zFar: Double): Matrix4d { - return Matrix4d( - m00 = 2f / (right - left), - m11 = -2f / (top - bottom), - m22 = 2f / (zFar - zNear), - m03 = -(right + left) / (right - left), - m13 = -(top + bottom) / (top - bottom) + 2f, - m23 = -(zFar + zNear) / (zFar - zNear) - ) - } - - /** - * Возвращает матрицу ортографической проекции, без инвентирования - * - * y = 0 будет соответствовать нижнему левому углу окна - */ - fun orthoDirect(left: Double, right: Double, bottom: Double, top: Double, zNear: Double, zFar: Double): Matrix4d { - return Matrix4d( - m00 = 2f / (right - left), - m11 = 2f / (top - bottom), - m22 = 2f / (zFar - zNear), - m03 = -(right + left) / (right - left), - m13 = -(top + bottom) / (top - bottom), - m23 = -(zFar + zNear) / (zFar - zNear) - ) - } - - fun perspective(fov: Double, zFar: Double, zNear: Double): Matrix4d { - val scale = (1.0 / (tan(Math.toRadians(fov.toDouble()) / 2.0))).toDouble() - val r = zFar - zNear - - return Matrix4d( - m00 = scale, - m11 = scale, - m22 = -zFar / r, - m23 = -1.0, - m32 = -zFar * zNear / r, - ) - } - } -} - -data class MutableMatrix4d( - override var m00: Double = 1.0, override var m01: Double = 0.0, override var m02: Double = 0.0, override var m03: Double = 0.0, - override var m10: Double = 0.0, override var m11: Double = 1.0, override var m12: Double = 0.0, override var m13: Double = 0.0, - override var m20: Double = 0.0, override var m21: Double = 0.0, override var m22: Double = 1.0, override var m23: Double = 0.0, - override var m30: Double = 0.0, override var m31: Double = 0.0, override var m32: Double = 0.0, override var m33: Double = 1.0, -) : AbstractMatrix4d() { - override fun createOrModify( - m00: Double, m01: Double, m02: Double, m03: Double, - m10: Double, m11: Double, m12: Double, m13: Double, - m20: Double, m21: Double, m22: Double, m23: Double, - m30: Double, m31: Double, m32: Double, m33: Double, - ): MutableMatrix4d { - this.m00 = m00; this.m01 = m01; this.m02 = m02; this.m03 = m03 - this.m10 = m10; this.m11 = m11; this.m12 = m12; this.m13 = m13 - this.m20 = m20; this.m21 = m21; this.m22 = m22; this.m23 = m23 - this.m30 = m30; this.m31 = m31; this.m32 = m32; this.m33 = m33 - - return this - } - - override var translation: Vector3d - get() { - return Vector3d(m03, m13, m23) - } - set(value) { - translate(value) - } - - fun set(row: Int, column: Int, value: Double) { - when (column) { - 0 -> when (row) { - 0 -> m00 = value - 1 -> m10 = value - 2 -> m20 = value - 3 -> m30 = value - else -> throw IndexOutOfBoundsException("Row: $row") - } - - 1 -> when (row) { - 0 -> m01 = value - 1 -> m11 = value - 2 -> m21 = value - 3 -> m31 = value - else -> throw IndexOutOfBoundsException("Row: $row") - } - - 2 -> when (row) { - 0 -> m02 = value - 1 -> m12 = value - 2 -> m22 = value - 3 -> m32 = value - else -> throw IndexOutOfBoundsException("Row: $row") - } - - 3 -> when (row) { - 0 -> m03 = value - 1 -> m13 = value - 2 -> m23 = value - 3 -> m33 = value - else -> throw IndexOutOfBoundsException("Row: $row") - } - - else -> throw IndexOutOfBoundsException("Column: $column") - } - } -} - -abstract class AbstractMatrix3f> : FloatMatrix { - companion object { - private val directBuffer by lazy { ByteBuffer.allocateDirect(4 * 3 * 3).also { it.order(ByteOrder.nativeOrder()) }.asFloatBuffer()!! } - } - - /** - * Наполняет синглтон и возвращает DirectFloatBuffer который необходимо использовать сразу, - * нет никаких гарантий что он не будет изменён в дальнейшем - * - * Функция предназначена исключительно для загрузки данной матрицы в память видеокарты - * - * Данный буфер всегда будет одним и тем же, но его содержимое обновлено - */ - fun toFloatBuffer(columnMajor: Boolean = true): FloatBuffer { - val directBuffer = directBuffer - directBuffer.position(0) - - if (columnMajor) { - directBuffer.put(m00) - directBuffer.put(m10) - directBuffer.put(m20) - - directBuffer.put(m01) - directBuffer.put(m11) - directBuffer.put(m21) - - directBuffer.put(m02) - directBuffer.put(m12) - directBuffer.put(m22) - } else { - directBuffer.put(m00) - directBuffer.put(m01) - directBuffer.put(m02) - - directBuffer.put(m10) - directBuffer.put(m11) - directBuffer.put(m12) - - directBuffer.put(m20) - directBuffer.put(m21) - directBuffer.put(m22) - } - - directBuffer.position(0) - return directBuffer - } - - abstract val m00: Float; abstract val m01: Float; abstract val m02: Float - abstract val m10: Float; abstract val m11: Float; abstract val m12: Float - abstract val m20: Float; abstract val m21: Float; abstract val m22: Float - - open val a11 get() = m00; open val a12 get() = m01; open val a13 get() = m02 - open val a21 get() = m10; open val a22 get() = m11; open val a23 get() = m12 - open val a31 get() = m20; open val a32 get() = m21; open val a33 get() = m22 - - override val columns: Int - get() = 3 - - override val rows: Int - get() = 3 - - override fun get(row: Int, column: Int): Float { - return when (column) { - 0 -> when (row) { - 0 -> m00 - 1 -> m10 - 2 -> m20 - else -> throw IndexOutOfBoundsException("Row: $row") - } - - 1 -> when (row) { - 0 -> m01 - 1 -> m11 - 2 -> m21 - else -> throw IndexOutOfBoundsException("Row: $row") - } - - 2 -> when (row) { - 0 -> m02 - 1 -> m12 - 2 -> m22 - else -> throw IndexOutOfBoundsException("Row: $row") - } - - else -> throw IndexOutOfBoundsException("Column: $column") - } - } - - protected abstract fun createOrModify( - m00: Float, m01: Float, m02: Float, - m10: Float, m11: Float, m12: Float, - m20: Float, m21: Float, m22: Float, - ): T - - override fun plus(other: IMatrix): T { - if (other !is IMatrixLikeFloat) { - throw IllegalArgumentException("Can not use $other for addition") - } - - if (other.columns != 3 || other.rows != 3) { - throw IllegalArgumentException("Concrete Matrix3f can only use 3x3 matrices") - } - - val m00: Float; val m01: Float; val m02: Float; - val m10: Float; val m11: Float; val m12: Float; - val m20: Float; val m21: Float; val m22: Float; - - if (other is AbstractMatrix3f<*>) { - m00 = other.m00; m01 = other.m01; m02 = other.m02; - m10 = other.m10; m11 = other.m11; m12 = other.m12; - m20 = other.m20; m21 = other.m21; m22 = other.m22; - } else { - m00 = other[0, 0]; m01 = other[0, 1]; m02 = other[0, 2]; - m10 = other[1, 0]; m11 = other[1, 1]; m12 = other[1, 2]; - m20 = other[2, 0]; m21 = other[2, 1]; m22 = other[2, 2]; - } - - return createOrModify( - this.m00 + m00, this.m01 + m01, this.m02 + m02, - this.m10 + m10, this.m11 + m11, this.m12 + m12, - this.m20 + m20, this.m21 + m21, this.m22 + m22, - ) - } - - override fun minus(other: IMatrix): T { - if (other !is IMatrixLikeFloat) { - throw IllegalArgumentException("Can not use $other for subtraction") - } - - if (other.columns != 3 || other.rows != 3) { - throw IllegalArgumentException("Concrete Matrix3f can only use 3x3 matrices") - } - - val m00: Float; val m01: Float; val m02: Float; - val m10: Float; val m11: Float; val m12: Float; - val m20: Float; val m21: Float; val m22: Float; - - if (other is AbstractMatrix3f<*>) { - m00 = other.m00; m01 = other.m01; m02 = other.m02; - m10 = other.m10; m11 = other.m11; m12 = other.m12; - m20 = other.m20; m21 = other.m21; m22 = other.m22; - } else { - m00 = other[0, 0]; m01 = other[0, 1]; m02 = other[0, 2]; - m10 = other[1, 0]; m11 = other[1, 1]; m12 = other[1, 2]; - m20 = other[2, 0]; m21 = other[2, 1]; m22 = other[2, 2]; - } - - return createOrModify( - this.m00 - m00, this.m01 - m01, this.m02 - m02, - this.m10 - m10, this.m11 - m11, this.m12 - m12, - this.m20 - m20, this.m21 - m21, this.m22 - m22, - ) - } - - override fun plus(other: Float): T { - return createOrModify( - this.m00 + other, this.m01 + other, this.m02 + other, - this.m10 + other, this.m11 + other, this.m12 + other, - this.m20 + other, this.m21 + other, this.m22 + other, - ) - } - - override fun minus(other: Float): T { - return createOrModify( - this.m00 - other, this.m01 - other, this.m02 - other, - this.m10 - other, this.m11 - other, this.m12 - other, - this.m20 - other, this.m21 - other, this.m22 - other, - ) - } - - override fun times(other: Float): T { - return createOrModify( - this.m00 * other, this.m01 * other, this.m02 * other, - this.m10 * other, this.m11 * other, this.m12 * other, - this.m20 * other, this.m21 * other, this.m22 * other, - ) - } - - override fun div(other: Float): T { - return createOrModify( - this.m00 / other, this.m01 / other, this.m02 / other, - this.m10 / other, this.m11 / other, this.m12 / other, - this.m20 / other, this.m21 / other, this.m22 / other, - ) - } - - override fun scale(x: Float, y: Float, z: Float, w: Float): T { - return createOrModify( - this.m00 * x, this.m01, this.m02, - this.m10, this.m11 * y, this.m12, - this.m20, this.m21, this.m22 * z, - ) - } - - override fun translate(x: Float, y: Float, z: Float): T { - return createOrModify( - this.m00, this.m01, this.m02 + x, - this.m10, this.m11, this.m12 + y, - this.m20, this.m21, this.m22, - ) - } - - override fun times(other: IMatrix): T { - if (other !is IMatrixLikeFloat) { - throw IllegalArgumentException("Can not use $other for multiplication") - } - - if (other.columns != 3 || other.rows != 3) { - throw IllegalArgumentException("Concrete Matrix3f can only use 3x3 matrixes") - } - - val m00: Float; val m01: Float; val m02: Float; - val m10: Float; val m11: Float; val m12: Float; - val m20: Float; val m21: Float; val m22: Float; - - if (other is AbstractMatrix3f<*>) { - m00 = other.m00; m01 = other.m01; m02 = other.m02; - m10 = other.m10; m11 = other.m11; m12 = other.m12; - m20 = other.m20; m21 = other.m21; m22 = other.m22; - } else { - m00 = other[0, 0]; m01 = other[0, 1]; m02 = other[0, 2]; - m10 = other[1, 0]; m11 = other[1, 1]; m12 = other[1, 2]; - m20 = other[2, 0]; m21 = other[2, 1]; m22 = other[2, 2]; - } - - // первый столбец - val newm00 = - this.m00 * m00 + - this.m01 * m10 + - this.m02 * m20 - - val newm10 = - this.m10 * m00 + - this.m11 * m10 + - this.m12 * m20 - - val newm20 = - this.m20 * m00 + - this.m21 * m10 + - this.m22 * m20 - - // второй столбец - val newm01 = - this.m00 * m01 + - this.m01 * m11 + - this.m02 * m21 - - val newm11 = - this.m10 * m01 + - this.m11 * m11 + - this.m12 * m21 - - val newm21 = - this.m20 * m01 + - this.m21 * m11 + - this.m22 * m21 - - // третий столбец - val newm02 = - this.m00 * m02 + - this.m01 * m12 + - this.m02 * m22 - - val newm12 = - this.m10 * m02 + - this.m11 * m12 + - this.m12 * m22 - - val newm22 = - this.m20 * m02 + - this.m21 * m12 + - this.m22 * m22 - - return createOrModify( - newm00, newm01, newm02, - newm10, newm11, newm12, - newm20, newm21, newm22, - ) - } - - override fun translateWithScale(x: Float, y: Float, z: Float): T { - return createOrModify( - m00, m01, m02 + x * m00 + y * m01, - m10, m11, m12 + x * m10 + y * m11, - m20, m21, m22, - ) - } - - val determinant get() = m00 * m11 * m22 + m01 * m12 * m20 + m02 * m10 * m21 - m02 * m11 * m20 - m00 * m12 * m21 - m01 * m10 * m22 - - val absoluteMatrix get() = Matrix3f( - m00 = m00.absoluteValue, m01 = m01.absoluteValue, m02 = m02.absoluteValue, - m10 = m10.absoluteValue, m11 = m11.absoluteValue, m12 = m12.absoluteValue, - m20 = m20.absoluteValue, m21 = m21.absoluteValue, m22 = m22.absoluteValue, - ) -} - -data class Matrix3f( - override val m00: Float = 1f, override val m01: Float = 0f, override val m02: Float = 0f, - override val m10: Float = 0f, override val m11: Float = 1f, override val m12: Float = 0f, - override val m20: Float = 0f, override val m21: Float = 0f, override val m22: Float = 1f, -) : AbstractMatrix3f() { - override fun createOrModify( - m00: Float, m01: Float, m02: Float, - m10: Float, m11: Float, m12: Float, - m20: Float, m21: Float, m22: Float, - ): Matrix3f { - return Matrix3f( - m00 = m00, m01 = m01, m02 = m02, - m10 = m10, m11 = m11, m12 = m12, - m20 = m20, m21 = m21, m22 = m22, - ) - } - - companion object { - val IDENTITY = Matrix3f() - } -} - -data class MutableMatrix3f( - override var m00: Float = 1f, override var m01: Float = 0f, override var m02: Float = 0f, - override var m10: Float = 0f, override var m11: Float = 1f, override var m12: Float = 0f, - override var m20: Float = 0f, override var m21: Float = 0f, override var m22: Float = 1f, -) : AbstractMatrix3f() { - override fun createOrModify( - m00: Float, m01: Float, m02: Float, - m10: Float, m11: Float, m12: Float, - m20: Float, m21: Float, m22: Float, - ): MutableMatrix3f { - this.m00 = m00; this.m01 = m01; this.m02 = m02 - this.m10 = m10; this.m11 = m11; this.m12 = m12 - this.m20 = m20; this.m21 = m21; this.m22 = m22 - - return this - } - - fun load(from: FloatMatrix<*>) { - val m00: Float; val m01: Float; val m02: Float; - val m10: Float; val m11: Float; val m12: Float; - val m20: Float; val m21: Float; val m22: Float; - - if (from is AbstractMatrix3f<*>) { - m00 = from.m00; m01 = from.m01; m02 = from.m02; - m10 = from.m10; m11 = from.m11; m12 = from.m12; - m20 = from.m20; m21 = from.m21; m22 = from.m22; - } else { - m00 = from[0, 0]; m01 = from[0, 1]; m02 = from[0, 2]; - m10 = from[1, 0]; m11 = from[1, 1]; m12 = from[1, 2]; - m20 = from[2, 0]; m21 = from[2, 1]; m22 = from[2, 2]; - } - - this.m00 = m00; this.m01 = m01; this.m02 = m02 - this.m10 = m10; this.m11 = m11; this.m12 = m12 - this.m20 = m20; this.m21 = m21; this.m22 = m22 - } - - override var a11 by this::m00; override var a12 by this::m01; override var a13 by this::m02 - override var a21 by this::m10; override var a22 by this::m11; override var a23 by this::m12 - override var a31 by this::m20; override var a32 by this::m21; override var a33 by this::m22 - - operator fun set(row: Int, column: Int, value: Float) { - when (column) { - 0 -> when (row) { - 0 -> m00 = value - 1 -> m10 = value - 2 -> m20 = value - else -> throw IndexOutOfBoundsException("Row: $row") - } - - 1 -> when (row) { - 0 -> m01 = value - 1 -> m11 = value - 2 -> m21 = value - else -> throw IndexOutOfBoundsException("Row: $row") - } - - 2 -> when (row) { - 0 -> m02 = value - 1 -> m12 = value - 2 -> m22 = value - else -> throw IndexOutOfBoundsException("Row: $row") - } - - else -> throw IndexOutOfBoundsException("Column: $column") - } - } -} - -abstract class AbstractMatrix3d> : DoubleMatrix { - companion object { - private val directBuffer by lazy { ByteBuffer.allocateDirect(4 * 3 * 3).also { it.order(ByteOrder.nativeOrder()) }.asDoubleBuffer()!! } - } - - /** - * Наполняет синглтон и возвращает DirectDoubleBuffer который необходимо использовать сразу, - * нет никаких гарантий что он не будет изменён в дальнейшем - * - * Функция предназначена исключительно для загрузки данной матрицы в память видеокарты - * - * Данный буфер всегда будет одним и тем же, но его содержимое обновлено - */ - fun toDoubleBuffer(columnMajor: Boolean = true): DoubleBuffer { - val directBuffer = directBuffer - directBuffer.position(0) - - if (columnMajor) { - directBuffer.put(m00) - directBuffer.put(m10) - directBuffer.put(m20) - - directBuffer.put(m01) - directBuffer.put(m11) - directBuffer.put(m21) - - directBuffer.put(m02) - directBuffer.put(m12) - directBuffer.put(m22) - } else { - directBuffer.put(m00) - directBuffer.put(m01) - directBuffer.put(m02) - - directBuffer.put(m10) - directBuffer.put(m11) - directBuffer.put(m12) - - directBuffer.put(m20) - directBuffer.put(m21) - directBuffer.put(m22) - } - - directBuffer.position(0) - return directBuffer - } - - abstract val m00: Double; abstract val m01: Double; abstract val m02: Double - abstract val m10: Double; abstract val m11: Double; abstract val m12: Double - abstract val m20: Double; abstract val m21: Double; abstract val m22: Double - - open val a11 get() = m00; open val a12 get() = m01; open val a13 get() = m02 - open val a21 get() = m10; open val a22 get() = m11; open val a23 get() = m12 - open val a31 get() = m20; open val a32 get() = m21; open val a33 get() = m22 - - override val columns: Int - get() = 3 - - override val rows: Int - get() = 3 - - override fun get(row: Int, column: Int): Double { - return when (column) { - 0 -> when (row) { - 0 -> m00 - 1 -> m10 - 2 -> m20 - else -> throw IndexOutOfBoundsException("Row: $row") - } - - 1 -> when (row) { - 0 -> m01 - 1 -> m11 - 2 -> m21 - else -> throw IndexOutOfBoundsException("Row: $row") - } - - 2 -> when (row) { - 0 -> m02 - 1 -> m12 - 2 -> m22 - else -> throw IndexOutOfBoundsException("Row: $row") - } - - else -> throw IndexOutOfBoundsException("Column: $column") - } - } - - protected abstract fun createOrModify( - m00: Double, m01: Double, m02: Double, - m10: Double, m11: Double, m12: Double, - m20: Double, m21: Double, m22: Double, - ): T - - override fun plus(other: IMatrix): T { - if (other !is IMatrixLikeDouble) { - throw IllegalArgumentException("Can not use $other for addition") - } - - if (other.columns != 3 || other.rows != 3) { - throw IllegalArgumentException("Concrete Matrix3d can only use 3x3 matrices") - } - - val m00: Double; val m01: Double; val m02: Double; - val m10: Double; val m11: Double; val m12: Double; - val m20: Double; val m21: Double; val m22: Double; - - if (other is AbstractMatrix3d<*>) { - m00 = other.m00; m01 = other.m01; m02 = other.m02; - m10 = other.m10; m11 = other.m11; m12 = other.m12; - m20 = other.m20; m21 = other.m21; m22 = other.m22; - } else { - m00 = other[0, 0]; m01 = other[0, 1]; m02 = other[0, 2]; - m10 = other[1, 0]; m11 = other[1, 1]; m12 = other[1, 2]; - m20 = other[2, 0]; m21 = other[2, 1]; m22 = other[2, 2]; - } - - return createOrModify( - this.m00 + m00, this.m01 + m01, this.m02 + m02, - this.m10 + m10, this.m11 + m11, this.m12 + m12, - this.m20 + m20, this.m21 + m21, this.m22 + m22, - ) - } - - override fun minus(other: IMatrix): T { - if (other !is IMatrixLikeDouble) { - throw IllegalArgumentException("Can not use $other for subtraction") - } - - if (other.columns != 3 || other.rows != 3) { - throw IllegalArgumentException("Concrete Matrix3d can only use 3x3 matrices") - } - - val m00: Double; val m01: Double; val m02: Double; - val m10: Double; val m11: Double; val m12: Double; - val m20: Double; val m21: Double; val m22: Double; - - if (other is AbstractMatrix3d<*>) { - m00 = other.m00; m01 = other.m01; m02 = other.m02; - m10 = other.m10; m11 = other.m11; m12 = other.m12; - m20 = other.m20; m21 = other.m21; m22 = other.m22; - } else { - m00 = other[0, 0]; m01 = other[0, 1]; m02 = other[0, 2]; - m10 = other[1, 0]; m11 = other[1, 1]; m12 = other[1, 2]; - m20 = other[2, 0]; m21 = other[2, 1]; m22 = other[2, 2]; - } - - return createOrModify( - this.m00 - m00, this.m01 - m01, this.m02 - m02, - this.m10 - m10, this.m11 - m11, this.m12 - m12, - this.m20 - m20, this.m21 - m21, this.m22 - m22, - ) - } - - override fun plus(other: Double): T { - return createOrModify( - this.m00 + other, this.m01 + other, this.m02 + other, - this.m10 + other, this.m11 + other, this.m12 + other, - this.m20 + other, this.m21 + other, this.m22 + other, - ) - } - - override fun minus(other: Double): T { - return createOrModify( - this.m00 - other, this.m01 - other, this.m02 - other, - this.m10 - other, this.m11 - other, this.m12 - other, - this.m20 - other, this.m21 - other, this.m22 - other, - ) - } - - override fun times(other: Double): T { - return createOrModify( - this.m00 * other, this.m01 * other, this.m02 * other, - this.m10 * other, this.m11 * other, this.m12 * other, - this.m20 * other, this.m21 * other, this.m22 * other, - ) - } - - override fun div(other: Double): T { - return createOrModify( - this.m00 / other, this.m01 / other, this.m02 / other, - this.m10 / other, this.m11 / other, this.m12 / other, - this.m20 / other, this.m21 / other, this.m22 / other, - ) - } - - override fun scale(x: Double, y: Double, z: Double, w: Double): T { - return createOrModify( - this.m00 * x, this.m01, this.m02, - this.m10, this.m11 * y, this.m12, - this.m20, this.m21, this.m22 * z, - ) - } - - override fun translate(x: Double, y: Double, z: Double): T { - return createOrModify( - this.m00, this.m01, this.m02 + x, - this.m10, this.m11, this.m12 + y, - this.m20, this.m21, this.m22, - ) - } - - override fun times(other: IMatrix): T { - if (other !is IMatrixLikeDouble) { - throw IllegalArgumentException("Can not use $other for multiplication") - } - - if (other.columns != 3 || other.rows != 3) { - throw IllegalArgumentException("Concrete Matrix3d can only use 3x3 matrixes") - } - - val m00: Double; val m01: Double; val m02: Double; - val m10: Double; val m11: Double; val m12: Double; - val m20: Double; val m21: Double; val m22: Double; - - if (other is AbstractMatrix3d<*>) { - m00 = other.m00; m01 = other.m01; m02 = other.m02; - m10 = other.m10; m11 = other.m11; m12 = other.m12; - m20 = other.m20; m21 = other.m21; m22 = other.m22; - } else { - m00 = other[0, 0]; m01 = other[0, 1]; m02 = other[0, 2]; - m10 = other[1, 0]; m11 = other[1, 1]; m12 = other[1, 2]; - m20 = other[2, 0]; m21 = other[2, 1]; m22 = other[2, 2]; - } - - // первый столбец - val newm00 = - this.m00 * m00 + - this.m01 * m10 + - this.m02 * m20 - - val newm10 = - this.m10 * m00 + - this.m11 * m10 + - this.m12 * m20 - - val newm20 = - this.m20 * m00 + - this.m21 * m10 + - this.m22 * m20 - - // второй столбец - val newm01 = - this.m00 * m01 + - this.m01 * m11 + - this.m02 * m21 - - val newm11 = - this.m10 * m01 + - this.m11 * m11 + - this.m12 * m21 - - val newm21 = - this.m20 * m01 + - this.m21 * m11 + - this.m22 * m21 - - // третий столбец - val newm02 = - this.m00 * m02 + - this.m01 * m12 + - this.m02 * m22 - - val newm12 = - this.m10 * m02 + - this.m11 * m12 + - this.m12 * m22 - - val newm22 = - this.m20 * m02 + - this.m21 * m12 + - this.m22 * m22 - - return createOrModify( - newm00, newm01, newm02, - newm10, newm11, newm12, - newm20, newm21, newm22, - ) - } - - override fun translateWithScale(x: Double, y: Double, z: Double): T { - return createOrModify( - m00, m01, m02 + x * m00 + y * m01, - m10, m11, m12 + x * m10 + y * m11, - m20, m21, m22, - ) - } - - val determinant get() = m00 * m11 * m22 + m01 * m12 * m20 + m02 * m10 * m21 - m02 * m11 * m20 - m00 * m12 * m21 - m01 * m10 * m22 - - val absoluteMatrix get() = Matrix3d( - m00 = m00.absoluteValue, m01 = m01.absoluteValue, m02 = m02.absoluteValue, - m10 = m10.absoluteValue, m11 = m11.absoluteValue, m12 = m12.absoluteValue, - m20 = m20.absoluteValue, m21 = m21.absoluteValue, m22 = m22.absoluteValue, - ) - - /// Solve A * x = b, where b is a column vector. This is more efficient - /// than computing the inverse in one-shot cases. - fun solve(b: IVector3d<*>): Vector3d { - var determinant = determinant - - if (determinant != 0.0) { - determinant = 1.0 / determinant - } - - return Vector3d( - x = determinant * scalarDotWithCross( - b.x, b.y, b.z, - m01, m11, m21, - m02, m12, m22, - ), - - y = determinant * scalarDotWithCross( - m00, m10, m20, - b.x, b.y, b.z, - m02, m12, m22, - ), - - z = determinant * scalarDotWithCross( - m00, m10, m20, - m01, m11, m21, - b.x, b.y, b.z, - ), - ) - } - - /// Solve A * x = b, where b is a column vector. This is more efficient - /// than computing the inverse in one-shot cases. - fun solve(b: IVector2d<*>): Vector2d { - var determinant = determinant - - if (determinant != 0.0) { - determinant = 1.0 / determinant - } - - return Vector2d( - x = determinant * (m11 * b.x - m01 * b.y), - y = determinant * (m00 * b.y - m10 * b.x), - ) - } - - fun getInverse2(): Matrix3d { - val a = m00 - val b = m01 - val c = m10 - val d = m11 - - var determinant = a * d - b * c - - if (determinant != 0.0) { - determinant = 1.0 / determinant - } - - return Matrix3d( - m00 = determinant * d, m01 = -determinant * b, m02 = 0.0, - m10 = -determinant * c, m11 = determinant * a, m12 = 0.0, - m20 = 0.0, m21 = 0.0, m22 = 0.0, - ) - } - - fun getInverse(): Matrix3d { - var determinant = determinant - - if (determinant != 0.0) { - determinant = 1.0 / determinant - } else { - return Matrix3d( - 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, - ) - } - - val m00 = determinant * (a22 * a33 - a23 * a23) - val m10 = determinant * (a13 * a23 - a12 * a33) - val m20 = determinant * (a12 * a23 - a13 * a22) - - val m01 = m10 - val m11 = determinant * (a11 * a33 - a13 * a13) - val m21 = determinant * (a13 * a12 - a11 * a23) - - val m02 = m20 - val m12 = m21 - val m22 = determinant * (a11 * a22 - a12 * a12) - - return Matrix3d( - m00 = m00, - m10 = m10, - m20 = m20, - m01 = m01, - m11 = m11, - m21 = m21, - m02 = m02, - m12 = m12, - m22 = m22, - ) - } -} - -data class Matrix3d( - override val m00: Double = 1.0, override val m01: Double = 0.0, override val m02: Double = 0.0, - override val m10: Double = 0.0, override val m11: Double = 1.0, override val m12: Double = 0.0, - override val m20: Double = 0.0, override val m21: Double = 0.0, override val m22: Double = 1.0, -) : AbstractMatrix3d() { - override fun createOrModify( - m00: Double, m01: Double, m02: Double, - m10: Double, m11: Double, m12: Double, - m20: Double, m21: Double, m22: Double, - ): Matrix3d { - return Matrix3d( - m00 = m00, m01 = m01, m02 = m02, - m10 = m10, m11 = m11, m12 = m12, - m20 = m20, m21 = m21, m22 = m22, - ) - } - - fun asMutableMatrix(): MutableMatrix3d { - return MutableMatrix3d( - m00 = m00, m01 = m01, m02 = m02, - m10 = m10, m11 = m11, m12 = m12, - m20 = m20, m21 = m21, m22 = m22, - ) - } - - companion object { - val IDENTITY = Matrix3d() - } -} - -data class MutableMatrix3d( - override var m00: Double = 1.0, override var m01: Double = 0.0, override var m02: Double = 0.0, - override var m10: Double = 0.0, override var m11: Double = 1.0, override var m12: Double = 0.0, - override var m20: Double = 0.0, override var m21: Double = 0.0, override var m22: Double = 1.0, -) : AbstractMatrix3d() { - override fun createOrModify( - m00: Double, m01: Double, m02: Double, - m10: Double, m11: Double, m12: Double, - m20: Double, m21: Double, m22: Double, - ): MutableMatrix3d { - this.m00 = m00; this.m01 = m01; this.m02 = m02 - this.m10 = m10; this.m11 = m11; this.m12 = m12 - this.m20 = m20; this.m21 = m21; this.m22 = m22 - - return this - } - - override var a11 by this::m00; override var a12 by this::m01; override var a13 by this::m02 - override var a21 by this::m10; override var a22 by this::m11; override var a23 by this::m12 - override var a31 by this::m20; override var a32 by this::m21; override var a33 by this::m22 - - fun load(from: DoubleMatrix<*>) { - val m00: Double; val m01: Double; val m02: Double; - val m10: Double; val m11: Double; val m12: Double; - val m20: Double; val m21: Double; val m22: Double; - - if (from is AbstractMatrix3d<*>) { - m00 = from.m00; m01 = from.m01; m02 = from.m02; - m10 = from.m10; m11 = from.m11; m12 = from.m12; - m20 = from.m20; m21 = from.m21; m22 = from.m22; - } else { - m00 = from[0, 0]; m01 = from[0, 1]; m02 = from[0, 2]; - m10 = from[1, 0]; m11 = from[1, 1]; m12 = from[1, 2]; - m20 = from[2, 0]; m21 = from[2, 1]; m22 = from[2, 2]; - } - - this.m00 = m00; this.m01 = m01; this.m02 = m02 - this.m10 = m10; this.m11 = m11; this.m12 = m12 - this.m20 = m20; this.m21 = m21; this.m22 = m22 - } - - fun setColumns(column1: IVector3d<*>, column2: IVector3d<*>, column3: IVector3d<*>) { - m00 = column1.x - m10 = column1.y - m20 = column1.z - - m01 = column2.x - m11 = column2.y - m21 = column2.y - - m02 = column3.x - m12 = column3.y - m22 = column3.y - } - - fun setIdentity() { - m00 = 1.0 - m01 = 0.0 - m02 = 0.0 - - m10 = 0.0 - m11 = 1.0 - m12 = 0.0 - - m20 = 0.0 - m21 = 0.0 - m22 = 1.0 - } - - fun zero() { - m00 = 0.0 - m01 = 0.0 - m02 = 0.0 - - m10 = 0.0 - m11 = 0.0 - m12 = 0.0 - - m20 = 0.0 - m21 = 0.0 - m22 = 0.0 - } - - operator fun set(row: Int, column: Int, value: Double) { - when (column) { - 0 -> when (row) { - 0 -> m00 = value - 1 -> m10 = value - 2 -> m20 = value - else -> throw IndexOutOfBoundsException("Row: $row") - } - - 1 -> when (row) { - 0 -> m01 = value - 1 -> m11 = value - 2 -> m21 = value - else -> throw IndexOutOfBoundsException("Row: $row") - } - - 2 -> when (row) { - 0 -> m02 = value - 1 -> m12 = value - 2 -> m22 = value - else -> throw IndexOutOfBoundsException("Row: $row") - } - - else -> throw IndexOutOfBoundsException("Column: $column") - } - } -} - -abstract class AbstractMatrix2d> : DoubleMatrix { - companion object { - private val directBuffer by lazy { ByteBuffer.allocateDirect(8 * 2 * 2).also { it.order(ByteOrder.nativeOrder()) }.asDoubleBuffer()!! } - } - - /** - * Наполняет синглтон и возвращает DirectFloatBuffer который необходимо использовать сразу, - * нет никаких гарантий что он не будет изменён в дальнейшем - * - * Функция предназначена исключительно для загрузки данной матрицы в память видеокарты - * - * Данный буфер всегда будет одним и тем же, но его содержимое обновлено - */ - fun toDoubleBuffer(columnMajor: Boolean = true): DoubleBuffer { - val directBuffer = directBuffer - directBuffer.position(0) - - if (columnMajor) { - directBuffer.put(m00) - directBuffer.put(m10) - - directBuffer.put(m01) - directBuffer.put(m11) - } else { - directBuffer.put(m00) - directBuffer.put(m01) - - directBuffer.put(m10) - directBuffer.put(m11) - } - - directBuffer.position(0) - return directBuffer - } - - abstract val m00: Double; abstract val m01: Double; - abstract val m10: Double; abstract val m11: Double; - - override val columns: Int - get() = 2 - - override val rows: Int - get() = 2 - - override fun get(row: Int, column: Int): Double { - return when (column) { - 0 -> when (row) { - 0 -> m00 - 1 -> m10 - else -> throw IndexOutOfBoundsException("Row: $row") - } - - 1 -> when (row) { - 0 -> m01 - 1 -> m11 - else -> throw IndexOutOfBoundsException("Row: $row") - } - - else -> throw IndexOutOfBoundsException("Column: $column") - } - } - - protected abstract fun createOrModify( - m00: Double, m01: Double, - m10: Double, m11: Double, - ): T - - override fun plus(other: IMatrix): T { - if (other !is DoubleMatrix<*>) { - throw IllegalArgumentException("Can not use $other for addition") - } - - if (other.columns != 2 || other.rows != 2) { - throw IllegalArgumentException("Concrete Matrix2f can only use 2x2 matrices") - } - - val m00: Double; val m01: Double; - val m10: Double; val m11: Double; - - if (other is AbstractMatrix2d<*>) { - m00 = other.m00; m01 = other.m01; - m10 = other.m10; m11 = other.m11; - } else { - m00 = other[0, 0]; m01 = other[0, 1]; - m10 = other[1, 0]; m11 = other[1, 1]; - } - - return createOrModify( - this.m00 + m00, this.m01 + m01, - this.m10 + m10, this.m11 + m11, - ) - } - - override fun minus(other: IMatrix): T { - if (other !is IMatrixLikeDouble) { - throw IllegalArgumentException("Can not use $other for subtraction") - } - - if (other.columns != 2 || other.rows != 2) { - throw IllegalArgumentException("Concrete Matrix2f can only use 2x2 matrices") - } - - val m00: Double; val m01: Double; - val m10: Double; val m11: Double; - - if (other is AbstractMatrix2d<*>) { - m00 = other.m00; m01 = other.m01; - m10 = other.m10; m11 = other.m11; - } else { - m00 = other[0, 0]; m01 = other[0, 1]; - m10 = other[1, 0]; m11 = other[1, 1]; - } - - return createOrModify( - this.m00 - m00, this.m01 - m01, - this.m10 - m10, this.m11 - m11, - ) - } - - override fun plus(other: Double): T { - return createOrModify( - this.m00 + other, this.m01 + other, - this.m10 + other, this.m11 + other, - ) - } - - override fun minus(other: Double): T { - return createOrModify( - this.m00 - other, this.m01 - other, - this.m10 - other, this.m11 - other, - ) - } - - override fun times(other: Double): T { - return createOrModify( - this.m00 * other, this.m01 * other, - this.m10 * other, this.m11 * other, - ) - } - - override fun div(other: Double): T { - return createOrModify( - this.m00 / other, this.m01 / other, - this.m10 / other, this.m11 / other, - ) - } - - override fun scale(x: Double, y: Double, z: Double, w: Double): T { - return createOrModify( - this.m00 * x, this.m01, - this.m10, this.m11 * y, - ) - } - - override fun translate(x: Double, y: Double, z: Double): T { - return createOrModify( - this.m00, this.m01 + x, - this.m10, this.m11, - ) - } - - override fun times(other: IMatrix): T { - if (other !is IMatrixLikeDouble) { - throw IllegalArgumentException("Can not use $other for multiplication") - } - - if (other.columns != 3 || other.rows != 3) { - throw IllegalArgumentException("Concrete Matrix3f can only use 3x3 matrixes") - } - - val m00: Double; val m01: Double; - val m10: Double; val m11: Double; - - if (other is AbstractMatrix2d<*>) { - m00 = other.m00; m01 = other.m01; - m10 = other.m10; m11 = other.m11; - } else { - m00 = other[0, 0]; m01 = other[0, 1]; - m10 = other[1, 0]; m11 = other[1, 1]; - } - - // первый столбец - val newm00 = - this.m00 * m00 + - this.m01 * m10 - - val newm10 = - this.m10 * m00 + - this.m11 * m10 - - // второй столбец - val newm01 = - this.m00 * m01 + - this.m01 * m11 - - val newm11 = - this.m10 * m01 + - this.m11 * m11 - - return createOrModify( - newm00, newm01, - newm10, newm11, - ) - } - - override fun translateWithScale(x: Double, y: Double, z: Double): T { - return createOrModify( - m00, m01 + x * m00, - m10, m11, - ) - } - - val determinant: Double get() = m00 * m11 - m01 * m10 - - val absoluteMatrix get() = Matrix2d( - m00 = m00.absoluteValue, m01 = m01.absoluteValue, - m10 = m10.absoluteValue, m11 = m11.absoluteValue, - ) - - fun getInverse(): Matrix2d { - val a = m00 - val b = m01 - val c = m10 - val d = m11 - - var determinant = determinant - - if (determinant != 0.0) { - determinant = 1.0 / determinant - } - - return Matrix2d( - m00 = determinant * d, m01 = -determinant * b, - m10 = -determinant * c, m11 = determinant * a, - ) - } - - /// Solve A * x = b, where b is a column vector. This is more efficient - /// than computing the inverse in one-shot cases. - fun solve(b: IVector2d<*>): Vector2d { - var determinant = determinant - - if (determinant != 0.0) { - determinant = 1.0 / determinant - } - - return Vector2d( - x = determinant * (m11 * b.x - m01 * b.y), - y = determinant * (m00 * b.y - m10 * b.x), - ) - } -} - -// ex.x = m00 -// ex.y = m10 -// ey.x = m01 -// ey.y = m11 -data class Matrix2d( - override val m00: Double = 1.0, override val m01: Double = 0.0, - override val m10: Double = 0.0, override val m11: Double = 1.0, -) : AbstractMatrix2d() { - override fun createOrModify( - m00: Double, m01: Double, - m10: Double, m11: Double, - ): Matrix2d { - return Matrix2d( - m00 = m00, m01 = m01, - m10 = m10, m11 = m11, - ) - } - - fun asMutableMatrix(): MutableMatrix2d { - return MutableMatrix2d( - m00 = m00, m01 = m01, - m10 = m10, m11 = m11, - ) - } - - companion object { - val IDENTITY = Matrix2d() - } -} - -data class MutableMatrix2d( - override var m00: Double = 1.0, override var m01: Double = 0.0, - override var m10: Double = 0.0, override var m11: Double = 1.0, -) : AbstractMatrix2d() { - override fun createOrModify( - m00: Double, m01: Double, - m10: Double, m11: Double, - ): MutableMatrix2d { - this.m00 = m00; this.m01 = m01; - this.m10 = m10; this.m11 = m11; - - return this - } - - fun setColumns(column1: IVector2d<*>, column2: IVector2d<*>) { - m00 = column1.x - m10 = column1.y - - m01 = column2.x - m11 = column2.y - } - - fun setIdentity() { - m00 = 1.0 - m01 = 0.0 - m11 = 1.0 - m10 = 0.0 - } - - fun zero() { - m00 = 0.0 - m01 = 0.0 - m11 = 0.0 - m10 = 0.0 - } - - operator fun set(row: Int, column: Int, value: Double) { - when (column) { - 0 -> when (row) { - 0 -> m00 = value - 1 -> m10 = value - else -> throw IndexOutOfBoundsException("Row: $row") - } - - 1 -> when (row) { - 0 -> m01 = value - 1 -> m11 = value - else -> throw IndexOutOfBoundsException("Row: $row") - } - - else -> throw IndexOutOfBoundsException("Column: $column") - } - } -} diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/math/Matrix4fStack.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/math/Matrix4fStack.kt deleted file mode 100644 index f1e4802e..00000000 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/math/Matrix4fStack.kt +++ /dev/null @@ -1,90 +0,0 @@ -package ru.dbotthepony.kstarbound.math - -import ru.dbotthepony.kstarbound.api.IStruct3f - -class Matrix4fStack { - private val stack = ArrayDeque() - - init { - stack.add(MutableMatrix4f()) - } - - val last get() = stack.last() - - fun push(matrix4f: MutableMatrix4f = last.copy()): Matrix4fStack { - stack.add(matrix4f) - return this - } - - fun pop(): Matrix4fStack { - stack.removeLast() - return this - } - - fun clear(matrix: MutableMatrix4f = MutableMatrix4f()): Matrix4fStack { - stack.clear() - stack.add(matrix) - return this - } - - operator fun plus(other: FloatMatrix<*>): Matrix4fStack { - last.plus(other) - return this - } - - operator fun minus(other: FloatMatrix<*>): Matrix4fStack { - last.minus(other) - return this - } - - operator fun times(other: FloatMatrix<*>): Matrix4fStack { - last.times(other) - return this - } - - operator fun plus(other: Float): Matrix4fStack { - last.plus(other) - return this - } - - operator fun minus(other: Float): Matrix4fStack { - last.minus(other) - return this - } - - operator fun times(other: Float): Matrix4fStack { - last.times(other) - return this - } - - fun scale(x: Float = 1f, y: Float = 1f, z: Float = 1f, w: Float = 1f): Matrix4fStack { - last.scale(x, y, z, w) - return this - } - - fun translate(x: Float = 0f, y: Float = 0f, z: Float = 0f): Matrix4fStack { - last.translate(x, y, z) - return this - } - - fun translateWithScale(x: Float = 0f, y: Float = 0f, z: Float = 0f): Matrix4fStack { - last.translateWithScale(x, y, z) - return this - } - - fun translate(vec: IStruct3f): Matrix4fStack { - last.translate(vec) - return this - } - - fun translateWithScale(vec: IStruct3f): Matrix4fStack { - last.translateWithScale(vec) - return this - } - - fun replace(matrix4f: MutableMatrix4f): Matrix4fStack { - stack.removeLast() - stack.add(matrix4f) - return this - } -} diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/math/Poly.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/math/Poly.kt index 43173e85..494c0cc9 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/math/Poly.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/math/Poly.kt @@ -5,6 +5,8 @@ import com.google.gson.TypeAdapter import com.google.gson.stream.JsonReader import com.google.gson.stream.JsonToken import com.google.gson.stream.JsonWriter +import ru.dbotthepony.kstarbound.io.Vector2dTypeAdapter +import ru.dbotthepony.kvector.vector.ndouble.Vector2d class Poly(vararg points: Vector2d) { val points: List = ImmutableList.copyOf(points) diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/math/Vector.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/math/Vector.kt deleted file mode 100644 index 8c1c75b9..00000000 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/math/Vector.kt +++ /dev/null @@ -1,1080 +0,0 @@ -package ru.dbotthepony.kstarbound.math - -import com.google.gson.JsonArray -import com.google.gson.TypeAdapter -import com.google.gson.stream.JsonReader -import com.google.gson.stream.JsonWriter -import ru.dbotthepony.kstarbound.api.* -import kotlin.math.* - -// Так как у нас нет шаблонов ни в Java, ни в Kotlin -// а дженерики вызывают autoboxing -// приходится создавать "бетонные" реализации для каждого вида вектора - -// а ведь компилятор мог бы это генерировать. - -abstract class IVector2i> : IMatrixLike, IMatrixLikeInt, IStruct2i { - override val columns = 1 - override val rows = 2 - - abstract val x: Int - abstract val y: Int - - operator fun plus(other: IVector2i<*>) = make(x + other.x, y + other.y) - operator fun minus(other: IVector2i<*>) = make(x - other.x, y - other.y) - operator fun times(other: IVector2i<*>) = make(x * other.x, y * other.y) - operator fun div(other: IVector2i<*>) = make(x / other.x, y / other.y) - - //operator fun plus(other: IVector2f<*>) = Vector2f(x + other.x, y + other.y) - //operator fun minus(other: IVector2f<*>) = Vector2f(x - other.x, y - other.y) - //operator fun times(other: IVector2f<*>) = Vector2f(x * other.x, y * other.y) - //operator fun div(other: IVector2f<*>) = Vector2f(x / other.x, y / other.y) - - //operator fun plus(other: IVector2d<*>) = Vector2d(x + other.x, y + other.y) - //operator fun minus(other: IVector2d<*>) = Vector2d(x - other.x, y - other.y) - //operator fun times(other: IVector2d<*>) = Vector2d(x * other.x, y * other.y) - //operator fun div(other: IVector2d<*>) = Vector2d(x / other.x, y / other.y) - - operator fun div(other: Int) = make(x / other, y / other) - operator fun times(other: Int) = make(x * other, y * other) - operator fun minus(other: Int) = make(x - other, y - other) - operator fun plus(other: Int) = make(x + other, y + other) - - //operator fun div(other: Float) = Vector2f(x / other, y / other) - //operator fun times(other: Float) = Vector2f(x * other, y * other) - //operator fun minus(other: Float) = Vector2f(x - other, y - other) - //operator fun plus(other: Float) = Vector2f(x + other, y + other) - - //operator fun div(other: Double) = Vector2d(x / other, y / other) - //operator fun times(other: Double) = Vector2d(x * other, y * other) - //operator fun minus(other: Double) = Vector2d(x - other, y - other) - //operator fun plus(other: Double) = Vector2d(x + other, y + other) - - operator fun unaryMinus() = make(-x, -y) - - val length get() = sqrt(x.toDouble() * x.toDouble() + y.toDouble() * y.toDouble()) - val lengthSquared get() = x.toDouble() * x.toDouble() + y.toDouble() * y.toDouble() - - fun dotProduct(other: IVector2i<*>): Double { - return other.x.toDouble() * x.toDouble() + other.y.toDouble() * y.toDouble() - } - - fun dotProduct(other: IVector2f<*>): Double { - return other.x.toDouble() * x.toDouble() + other.y.toDouble() * y.toDouble() - } - - fun dotProduct(other: IVector2d<*>): Double { - return other.x * x.toDouble() + other.y * y.toDouble() - } - - fun invDotProduct(other: IVector2i<*>): Double { - return other.x.toDouble() * y.toDouble() + other.y.toDouble() * x.toDouble() - } - - fun invDotProduct(other: IVector2f<*>): Double { - return other.x.toDouble() * y.toDouble() + other.y.toDouble() * x.toDouble() - } - - fun invDotProduct(other: IVector2d<*>): Double { - return other.x * y.toDouble() + other.y * x.toDouble() - } - - fun distance(other: IVector2i<*>): Double { - return sqrt((x - other.x).toDouble().pow(2.0) + (y - other.y).toDouble().pow(2.0)) - } - - fun distance(other: IVector2f<*>): Double { - return sqrt((x - other.x).toDouble().pow(2.0) + (y - other.y).toDouble().pow(2.0)) - } - - fun distance(other: IVector2d<*>): Double { - return sqrt((x - other.x).toDouble().pow(2.0) + (y - other.y).toDouble().pow(2.0)) - } - - val normalized: Vector2d get() { - val len = length - return Vector2d(x / len, y / len) - } - - val absoluteVector: Vector2i get() = Vector2i(x.absoluteValue, y.absoluteValue) - - fun minimumPerComponent(other: IVector2i<*>): Vector2i { - return Vector2i( - x = x.coerceAtMost(other.x), - y = y.coerceAtMost(other.y), - ) - } - - fun maximumPerComponent(other: IVector2i<*>): Vector2i { - return Vector2i( - x = x.coerceAtLeast(other.x), - y = y.coerceAtLeast(other.y), - ) - } - - fun clampPerComponent(min: IVector2i<*>, max: IVector2i<*>): Vector2i { - return Vector2i( - x = x.coerceAtLeast(min.x).coerceAtMost(max.x), - y = y.coerceAtLeast(min.y).coerceAtMost(max.y), - ) - } - - fun left() = make(x - 1, y) - fun right() = make(x + 1, y) - fun up() = make(x, y + 1) - fun down() = make(x, y - 1) - - override fun get(row: Int, column: Int): Int { - if (column != 0) { - throw IndexOutOfBoundsException("Column must be 0 ($column given)") - } - - return when (row) { - 0 -> x - 1 -> y - else -> throw IndexOutOfBoundsException("Row out of bounds: $row") - } - } - - protected abstract fun make(x: Int, y: Int): T - - fun toFloatVector() = Vector2f(x.toFloat(), y.toFloat()) - fun toDoubleVector() = Vector2d(x.toDouble(), y.toDouble()) -} - -data class Vector2i(override val x: Int = 0, override val y: Int = 0) : IVector2i() { - override fun make(x: Int, y: Int) = Vector2i(x, y) - - companion object { - fun fromJson(input: JsonArray): Vector2i { - return Vector2i(input[0].asInt, input[1].asInt) - } - - val ZERO = Vector2i() - val LEFT = Vector2i().left() - val RIGHT = Vector2i().right() - val UP = Vector2i().up() - val DOWN = Vector2i().down() - val ONE_ONE = Vector2i(1, 1) - } -} - -object Vector2iTypeAdapter : TypeAdapter() { - override fun write(out: JsonWriter, value: Vector2i) { - `out`.beginArray() - `out`.value(value.x) - `out`.value(value.y) - `out`.endArray() - } - - override fun read(`in`: JsonReader): Vector2i { - `in`.beginArray() - - val x = `in`.nextInt() - val y = `in`.nextInt() - - `in`.endArray() - - return Vector2i(x, y) - } -} - -data class MutableVector2i(override var x: Int = 0, override var y: Int = 0) : IVector2i() { - override fun make(x: Int, y: Int): MutableVector2i { - this.x = x - this.y = y - return this - } - - companion object { - fun fromJson(input: JsonArray): MutableVector2i { - return MutableVector2i(input[0].asInt, input[1].asInt) - } - } -} - -abstract class IVector2f> : IMatrixLike, IMatrixLikeFloat, IStruct2f { - override val columns = 1 - override val rows = 2 - - abstract val x: Float - abstract val y: Float - - operator fun plus(other: IVector2f<*>) = make(x + other.x, y + other.y) - operator fun minus(other: IVector2f<*>) = make(x - other.x, y - other.y) - operator fun times(other: IVector2f<*>) = make(x * other.x, y * other.y) - operator fun div(other: IVector2f<*>) = make(x / other.x, y / other.y) - - operator fun plus(other: Float) = make(x + other, y + other) - operator fun minus(other: Float) = make(x - other, y - other) - operator fun times(other: Float) = make(x * other, y * other) - operator fun div(other: Float) = make(x / other, y / other) - - operator fun unaryMinus() = make(-x, -y) - - fun left() = make(x - 1, y) - fun right() = make(x + 1, y) - fun up() = make(x, y + 1) - fun down() = make(x, y - 1) - - val length get() = sqrt(x.toDouble() * x.toDouble() + y.toDouble() * y.toDouble()) - val lengthSquared get() = x.toDouble() * x.toDouble() + y.toDouble() * y.toDouble() - - val isFinite get() = x.isFinite() && y.isFinite() && !x.isNaN() && !y.isNaN() - - fun dotProduct(other: IVector2i<*>): Double { - return other.x.toDouble() * x.toDouble() + other.y.toDouble() * y.toDouble() - } - - fun dotProduct(other: IVector2f<*>): Double { - return other.x.toDouble() * x.toDouble() + other.y.toDouble() * y.toDouble() - } - - fun dotProduct(other: IVector2d<*>): Double { - return other.x * x.toDouble() + other.y * y.toDouble() - } - - fun invDotProduct(other: IVector2i<*>): Double { - return other.x.toDouble() * y.toDouble() + other.y.toDouble() * x.toDouble() - } - - fun invDotProduct(other: IVector2f<*>): Double { - return other.x.toDouble() * y.toDouble() + other.y.toDouble() * x.toDouble() - } - - fun invDotProduct(other: IVector2d<*>): Double { - return other.x * y.toDouble() + other.y * x.toDouble() - } - - fun distance(other: IVector2i<*>): Double { - return sqrt((x - other.x).toDouble().pow(2.0) + (y - other.y).toDouble().pow(2.0)) - } - - fun distance(other: IVector2f<*>): Double { - return sqrt((x - other.x).toDouble().pow(2.0) + (y - other.y).toDouble().pow(2.0)) - } - - fun distance(other: IVector2d<*>): Double { - return sqrt((x - other.x).toDouble().pow(2.0) + (y - other.y).toDouble().pow(2.0)) - } - - val normalized: Vector2d get() { - val len = length - return Vector2d(x / len, y / len) - } - - val absoluteVector: Vector2f get() = Vector2f(x.absoluteValue, y.absoluteValue) - - fun minimumPerComponent(other: IVector2f<*>): Vector2f { - return Vector2f( - x = x.coerceAtMost(other.x), - y = y.coerceAtMost(other.y), - ) - } - - fun maximumPerComponent(other: IVector2f<*>): Vector2f { - return Vector2f( - x = x.coerceAtLeast(other.x), - y = y.coerceAtLeast(other.y), - ) - } - - fun clampPerComponent(min: IVector2f<*>, max: IVector2f<*>): Vector2f { - return Vector2f( - x = x.coerceAtLeast(min.x).coerceAtMost(max.x), - y = y.coerceAtLeast(min.y).coerceAtMost(max.y), - ) - } - - override fun get(row: Int, column: Int): Float { - if (column != 0) { - throw IndexOutOfBoundsException("Column must be 0 ($column given)") - } - - return when (row) { - 0 -> x - 1 -> y - else -> throw IndexOutOfBoundsException("Row out of bounds: $row") - } - } - - protected abstract fun make(x: Float, y: Float): T - - fun toDoubleVector() = Vector2d(x.toDouble(), y.toDouble()) -} - -data class Vector2f(override val x: Float = 0f, override val y: Float = 0f) : IVector2f() { - override fun make(x: Float, y: Float) = Vector2f(x, y) - - companion object { - fun fromJson(input: JsonArray): Vector2f { - return Vector2f(input[0].asFloat, input[1].asFloat) - } - - val ZERO = Vector2f() - val LEFT = Vector2f().left() - val RIGHT = Vector2f().right() - val UP = Vector2f().up() - val DOWN = Vector2f().down() - } -} - -object Vector2fTypeAdapter : TypeAdapter() { - override fun write(out: JsonWriter, value: Vector2f) { - `out`.beginArray() - `out`.value(value.x) - `out`.value(value.y) - `out`.endArray() - } - - override fun read(`in`: JsonReader): Vector2f { - `in`.beginArray() - - val x = `in`.nextDouble().toFloat() - val y = `in`.nextDouble().toFloat() - - `in`.endArray() - - return Vector2f(x, y) - } -} - -data class MutableVector2f(override var x: Float = 0f, override var y: Float = 0f) : IVector2f() { - override fun make(x: Float, y: Float): MutableVector2f { - this.x = x - this.y = y - return this - } - - companion object { - fun fromJson(input: JsonArray): MutableVector2f { - return MutableVector2f(input[0].asFloat, input[1].asFloat) - } - } -} - -abstract class IVector2d> : IMatrixLike, IMatrixLikeDouble, IStruct2d { - override val columns = 1 - override val rows = 2 - - abstract val x: Double - abstract val y: Double - - operator fun plus(other: IVector2d<*>) = make(x + other.x, y + other.y) - operator fun minus(other: IVector2d<*>) = make(x - other.x, y - other.y) - operator fun times(other: IVector2d<*>) = make(x * other.x, y * other.y) - operator fun div(other: IVector2d<*>) = make(x / other.x, y / other.y) - - operator fun plus(other: Double) = make(x + other, y + other) - operator fun minus(other: Double) = make(x - other, y - other) - operator fun times(other: Double) = make(x * other, y * other) - operator fun div(other: Double) = make(x / other, y / other) - - operator fun unaryMinus() = make(-x, -y) - - val length get() = sqrt(x * x + y * y) - val lengthSquared get() = x * x + y * y - - val isFinite get() = x.isFinite() && y.isFinite() && !x.isNaN() && !y.isNaN() - - inline fun isFiniteOrThrow(lazy: () -> Any) { - if (!isFinite) { - throw IllegalStateException(lazy.invoke().toString()) - } - } - - fun dotProduct(other: IVector2i<*>): Double { - return other.x * x + other.y * y - } - - fun dotProduct(other: IVector2f<*>): Double { - return other.x * x + other.y * y - } - - fun dotProduct(other: IVector2d<*>): Double { - return other.x * x + other.y * y - } - - fun invDotProduct(other: IVector2i<*>): Double { - return other.x * y + other.y * x - } - - fun invDotProduct(other: IVector2f<*>): Double { - return other.x * y + other.y * x - } - - fun invDotProduct(other: IVector2d<*>): Double { - return other.x * y + other.y * x - } - - fun crossProduct(other: IVector2i<*>): Double { - return x * other.y - y * other.x - } - - fun crossProduct(other: IVector2f<*>): Double { - return x * other.y - y * other.x - } - - fun crossProduct(other: IVector2d<*>): Double { - return x * other.y - y * other.x - } - - fun crossProduct(other: Double): Vector2d { - return Vector2d(y * other, x * -other) - } - - fun distance(other: IVector2i<*>): Double { - return sqrt((x - other.x).toDouble().pow(2.0) + (y - other.y).toDouble().pow(2.0)) - } - - fun distance(other: IVector2f<*>): Double { - return sqrt((x - other.x).toDouble().pow(2.0) + (y - other.y).toDouble().pow(2.0)) - } - - fun distance(other: IVector2d<*>): Double { - return sqrt((x - other.x).toDouble().pow(2.0) + (y - other.y).toDouble().pow(2.0)) - } - - fun distanceSquared(other: IVector2i<*>): Double { - return (x - other.x).toDouble().pow(2.0) + (y - other.y).toDouble().pow(2.0) - } - - fun distanceSquared(other: IVector2f<*>): Double { - return (x - other.x).toDouble().pow(2.0) + (y - other.y).toDouble().pow(2.0) - } - - fun distanceSquared(other: IVector2d<*>): Double { - return (x - other.x).toDouble().pow(2.0) + (y - other.y).toDouble().pow(2.0) - } - - val normalized: Vector2d get() { - val len = length - return Vector2d(x / len, y / len) - } - - val absoluteVector: Vector2d get() = Vector2d(x.absoluteValue, y.absoluteValue) - - fun minimumPerComponent(other: IVector2d<*>): Vector2d { - return Vector2d( - x = x.coerceAtMost(other.x), - y = y.coerceAtMost(other.y), - ) - } - - fun maximumPerComponent(other: IVector2d<*>): Vector2d { - return Vector2d( - x = x.coerceAtLeast(other.x), - y = y.coerceAtLeast(other.y), - ) - } - - fun clampPerComponent(min: IVector2d<*>, max: IVector2d<*>): Vector2d { - return Vector2d( - x = x.coerceAtLeast(min.x).coerceAtMost(max.x), - y = y.coerceAtLeast(min.y).coerceAtMost(max.y), - ) - } - - fun left() = make(x - 1, y) - fun right() = make(x + 1, y) - fun up() = make(x, y + 1) - fun down() = make(x, y - 1) - - override fun get(row: Int, column: Int): Double { - if (column != 0) { - throw IndexOutOfBoundsException("Column must be 0 ($column given)") - } - - return when (row) { - 0 -> x - 1 -> y - else -> throw IndexOutOfBoundsException("Row out of bounds: $row") - } - } - - operator fun times(other: IMatrixLikeDouble): T { - if (other.rows >= 2 && other.columns >= 2) { - val x = this.x * other[0, 0] + - this.y * other[0, 1] - - val y = this.x * other[1, 0] + - this.y * other[1, 1] - - return make(x, y) - } - - throw IllegalArgumentException("Incompatible matrix provided: ${other.rows} x ${other.columns}") - } - - protected abstract fun make(x: Double, y: Double): T - fun toFloatVector(): Vector2f = Vector2f(x.toFloat(), y.toFloat()) -} - -fun Double.crossProduct(other: IVector2d<*>): Vector2d { - return Vector2d(-this * other.y, this * other.x) -} - -// Только Vector2d во избежание двоякого поведения с мутирующими векторами -operator fun Double.times(other: Vector2d) = Vector2d(this * other.x, this * other.y) - -data class Vector2d(override val x: Double = 0.0, override val y: Double = 0.0) : IVector2d() { - override fun make(x: Double, y: Double) = Vector2d(x, y) - - fun toMutableVector(): MutableVector2d { - return MutableVector2d(x, y) - } - - companion object { - fun fromJson(input: JsonArray): Vector2d { - return Vector2d(input[0].asDouble, input[1].asDouble) - } - - val ZERO = Vector2d() - val LEFT = Vector2d().left() - val RIGHT = Vector2d().right() - val UP = Vector2d().up() - val DOWN = Vector2d().down() - - val INVERT_X = Vector2d(-1.0, 1.0) - val INVERT_Y = Vector2d(1.0, -1.0) - val INVERT_XY = Vector2d(-1.0, -1.0) - - val DROP_TO_FLOOR = Vector2d(y = -1_000.0) - } -} - -object Vector2dTypeAdapter : TypeAdapter() { - override fun write(out: JsonWriter, value: Vector2d) { - `out`.beginArray() - `out`.value(value.x) - `out`.value(value.y) - `out`.endArray() - } - - override fun read(`in`: JsonReader): Vector2d { - `in`.beginArray() - - val x = `in`.nextDouble() - val y = `in`.nextDouble() - - `in`.endArray() - - return Vector2d(x, y) - } -} - -data class MutableVector2d(override var x: Double = 0.0, override var y: Double = 0.0) : IVector2d() { - override fun make(x: Double, y: Double): MutableVector2d { - this.x = x - this.y = y - return this - } - - fun zero(): MutableVector2d { - this.x = 0.0 - this.y = 0.0 - return this - } - - fun toVector(): Vector2d { - return Vector2d(x, y) - } - - fun load(from: IStruct2d) { - x = from.component1() - y = from.component2() - } - - companion object { - fun fromJson(input: JsonArray): MutableVector2d { - return MutableVector2d(input[0].asDouble, input[1].asDouble) - } - } -} - -abstract class IVector3f> : IMatrixLike, IMatrixLikeFloat, IStruct3f { - override val columns = 1 - override val rows = 3 - - abstract val x: Float - abstract val y: Float - abstract val z: Float - - operator fun plus(other: IVector3f<*>) = make(x + other.x, y + other.y, z + other.z) - operator fun minus(other: IVector3f<*>) = make(x - other.x, y - other.y, z - other.z) - operator fun times(other: IVector3f<*>) = make(x * other.x, y * other.y, z * other.z) - operator fun div(other: IVector3f<*>) = make(x / other.x, y / other.y, z / other.z) - - operator fun plus(other: Float) = make(x + other, y + other, z + other) - operator fun minus(other: Float) = make(x - other, y - other, z - other) - operator fun times(other: Float) = make(x * other, y * other, z * other) - operator fun div(other: Float) = make(x / other, y / other, z / other) - - operator fun unaryMinus() = make(-x, -y, -z) - - val length get() = sqrt(x.toDouble() * x.toDouble() + y.toDouble() * y.toDouble() + z.toDouble() * z.toDouble()) - val lengthSquared get() = x.toDouble() * x.toDouble() + y.toDouble() * y.toDouble() + z.toDouble() * z.toDouble() - - val isFinite get() = x.isFinite() && y.isFinite() && z.isFinite() && !x.isNaN() && !y.isNaN() && !z.isNaN() - - val absoluteVector: Vector3f get() = Vector3f(x.absoluteValue, y.absoluteValue, z.absoluteValue) - - fun minimumPerComponent(other: IVector3f<*>): Vector3f { - return Vector3f( - x = x.coerceAtMost(other.x), - y = y.coerceAtMost(other.y), - ) - } - - fun maximumPerComponent(other: IVector3f<*>): Vector3f { - return Vector3f( - x = x.coerceAtLeast(other.x), - y = y.coerceAtLeast(other.y), - ) - } - - fun clampPerComponent(min: IVector3f<*>, max: IVector3f<*>): Vector3f { - return Vector3f( - x = x.coerceAtLeast(min.x).coerceAtMost(max.x), - y = y.coerceAtLeast(min.y).coerceAtMost(max.y), - ) - } - - fun dotProduct(other: IVector3f<*>): Double { - return other.x.toDouble() * x.toDouble() + other.y.toDouble() * y.toDouble() + other.z.toDouble() * z.toDouble() - } - - override fun get(row: Int, column: Int): Float { - if (column != 0) { - throw IndexOutOfBoundsException("Column must be 0 ($column given)") - } - - return when (row) { - 0 -> x - 1 -> y - 2 -> z - else -> throw IndexOutOfBoundsException("Row out of bounds: $row") - } - } - - fun rotateAroundThis(rotation: Double): Matrix4f { - val c = cos(rotation).toFloat() - val s = sin(rotation).toFloat() - val cInv = 1f - c - - return Matrix4f( - m00 = c + x * x * cInv, m01 = x * y * cInv - z * s, m02 = x * z * cInv + y * s, - m10 = y * x * cInv + z * s, m11 = c + y * y * cInv, m12 = y * z * cInv - x * s, - m20 = z * x * cInv - y * s, m21 = z * y * cInv + x * s, m22 = c + z * z * cInv, - ) - } - - operator fun times(other: IMatrixLikeFloat): T { - if (other.rows >= 4 && other.columns >= 4) { - val x = this.x * other[0, 0] + - this.y * other[0, 1] + - this.z * other[0, 2] + - other[0, 3] - - val y = this.x * other[1, 0] + - this.y * other[1, 1] + - this.z * other[1, 2] + - other[1, 3] - - val z = this.x * other[2, 0] + - this.y * other[2, 1] + - this.z * other[2, 2] + - other[2, 3] - - return make(x, y, z) - } else if (other.rows >= 3 && other.columns >= 3) { - val x = this.x * other[0, 0] + - this.y * other[0, 1] + - this.z * other[0, 2] - - val y = this.x * other[1, 0] + - this.y * other[1, 1] + - this.z * other[1, 2] - - val z = this.x * other[2, 0] + - this.y * other[2, 1] + - this.z * other[2, 2] - - return make(x, y, z) - } - - throw IllegalArgumentException("Incompatible matrix provided: ${other.rows} x ${other.columns}") - } - - protected abstract fun make(x: Float, y: Float, z: Float): T -} - -data class Vector3f(override val x: Float = 0f, override val y: Float = 0f, override val z: Float = 0f) : IVector3f() { - override fun make(x: Float, y: Float, z: Float): Vector3f { - return Vector3f(x, y, z) - } - - fun toMutableVector(): MutableVector3f { - return MutableVector3f(x, y, z) - } - - companion object { - val UP = Vector3f(0f, 1f, 0f) - val DOWN = Vector3f(0f, -1f, 0f) - val LEFT = Vector3f(-1f, 0f, 0f) - val RIGHT = Vector3f(1f, 0f, 0f) - val FORWARD = Vector3f(0f, 0f, 1f) - val BACKWARD = Vector3f(0f, 0f, -1f) - } -} - -data class MutableVector3f(override var x: Float = 0f, override var y: Float = 0f, override var z: Float = 0f) : IVector3f() { - fun toVector(): Vector3f { - return Vector3f(x, y, z) - } - - override fun make(x: Float, y: Float, z: Float): MutableVector3f { - this.x = x - this.y = y - this.z = z - return this - } -} - -abstract class IVector3d> : IMatrixLike, IMatrixLikeDouble, IStruct3d { - override val columns = 1 - override val rows = 3 - - abstract val x: Double - abstract val y: Double - abstract val z: Double - - operator fun plus(other: IVector3d<*>) = make(x + other.x, y + other.y, z + other.z) - operator fun minus(other: IVector3d<*>) = make(x - other.x, y - other.y, z - other.z) - operator fun times(other: IVector3d<*>) = make(x * other.x, y * other.y, z * other.z) - operator fun div(other: IVector3d<*>) = make(x / other.x, y / other.y, z / other.z) - - operator fun plus(other: Double) = make(x + other, y + other, z + other) - operator fun minus(other: Double) = make(x - other, y - other, z - other) - operator fun times(other: Double) = make(x * other, y * other, z * other) - operator fun div(other: Double) = make(x / other, y / other, z / other) - - operator fun unaryMinus() = make(-x, -y, -z) - - val length get() = sqrt(x * x + y * y + z * z) - val lengthSquared get() = x * x + y * y + z * z - - val isFinite get() = x.isFinite() && y.isFinite() && z.isFinite() && !x.isNaN() && !y.isNaN() && !z.isNaN() - - val absoluteVector: Vector3d get() = Vector3d(x.absoluteValue, y.absoluteValue, z.absoluteValue) - - fun minimumPerComponent(other: IVector3d<*>): Vector3d { - return Vector3d( - x = x.coerceAtMost(other.x), - y = y.coerceAtMost(other.y), - ) - } - - fun maximumPerComponent(other: IVector3d<*>): Vector3d { - return Vector3d( - x = x.coerceAtLeast(other.x), - y = y.coerceAtLeast(other.y), - ) - } - - fun clampPerComponent(min: IVector3d<*>, max: IVector3d<*>): Vector3d { - return Vector3d( - x = x.coerceAtLeast(min.x).coerceAtMost(max.x), - y = y.coerceAtLeast(min.y).coerceAtMost(max.y), - ) - } - - fun dotProduct(other: IVector3d<*>): Double { - return other.x * x + other.y * y + other.z * z - } - - override fun get(row: Int, column: Int): Double { - if (column != 0) { - throw IndexOutOfBoundsException("Column must be 0 ($column given)") - } - - return when (row) { - 0 -> x - 1 -> y - 2 -> z - else -> throw IndexOutOfBoundsException("Row out of bounds: $row") - } - } - - fun rotateAroundThis(rotation: Double): Matrix4d { - val c = cos(rotation) - val s = sin(rotation) - val cInv = 1f - c - - return Matrix4d( - m00 = c + x * x * cInv, m01 = x * y * cInv - z * s, m02 = x * z * cInv + y * s, - m10 = y * x * cInv + z * s, m11 = c + y * y * cInv, m12 = y * z * cInv - x * s, - m20 = z * x * cInv - y * s, m21 = z * y * cInv + x * s, m22 = c + z * z * cInv, - ) - } - - operator fun times(other: IMatrixLikeDouble): T { - if (other.rows >= 4 && other.columns >= 4) { - val x = this.x * other[0, 0] + - this.y * other[0, 1] + - this.z * other[0, 2] + - other[0, 3] - - val y = this.x * other[1, 0] + - this.y * other[1, 1] + - this.z * other[1, 2] + - other[1, 3] - - val z = this.x * other[2, 0] + - this.y * other[2, 1] + - this.z * other[2, 2] + - other[2, 3] - - return make(x, y, z) - } else if (other.rows >= 3 && other.columns >= 3) { - val x = this.x * other[0, 0] + - this.y * other[0, 1] + - this.z * other[0, 2] - - val y = this.x * other[1, 0] + - this.y * other[1, 1] + - this.z * other[1, 2] - - val z = this.x * other[2, 0] + - this.y * other[2, 1] + - this.z * other[2, 2] - - return make(x, y, z) - } - - throw IllegalArgumentException("Incompatible matrix provided: ${other.rows} x ${other.columns}") - } - - protected abstract fun make(x: Double, y: Double, z: Double): T -} - -data class Vector3d(override val x: Double = 0.0, override val y: Double = 0.0, override val z: Double = 0.0) : IVector3d() { - override fun make(x: Double, y: Double, z: Double): Vector3d { - return Vector3d(x, y, z) - } - - fun toMutableVector(): MutableVector3d { - return MutableVector3d(x, y, z) - } - - companion object { - val UP = Vector3d(0.0, 1.0, 0.0) - val DOWN = Vector3d(0.0, -1.0, 0.0) - val LEFT = Vector3d(-1.0, 0.0, 0.0) - val RIGHT = Vector3d(1.0, 0.0, 0.0) - val FORWARD = Vector3d(0.0, 0.0, 1.0) - val BACKWARD = Vector3d(0.0, 0.0, -1.0) - } -} - -data class MutableVector3d(override var x: Double = 0.0, override var y: Double = 0.0, override var z: Double = 0.0) : IVector3d() { - fun toVector(): Vector3d { - return Vector3d(x, y, z) - } - - override fun make(x: Double, y: Double, z: Double): MutableVector3d { - this.x = x - this.y = y - this.z = z - return this - } -} - -abstract class IVector4f> : IMatrixLike, IMatrixLikeFloat, IStruct4f { - abstract val x: Float - abstract val y: Float - abstract val z: Float - abstract val w: Float - - operator fun plus(other: IVector4f<*>) = make(x + other.x, y + other.y, z + other.z, w + other.w) - operator fun minus(other: IVector4f<*>) = make(x - other.x, y - other.y, z - other.z, w + other.w) - operator fun times(other: IVector4f<*>) = make(x * other.x, y * other.y, z * other.z, w + other.w) - operator fun div(other: IVector4f<*>) = make(x / other.x, y / other.y, z / other.z, w + other.w) - - operator fun plus(other: Float) = make(x + other, y + other, z + other, w + other) - operator fun minus(other: Float) = make(x - other, y - other, z - other, w - other) - operator fun times(other: Float) = make(x * other, y * other, z * other, w * other) - operator fun div(other: Float) = make(x / other, y / other, z / other, w / other) - - operator fun unaryMinus() = make(-x, -y, -z, -w) - - val absoluteVector: Vector4f get() = Vector4f(x.absoluteValue, y.absoluteValue, z.absoluteValue, w.absoluteValue) - - val isFinite get() = x.isFinite() && y.isFinite() && z.isFinite() && w.isFinite() && !x.isNaN() && !y.isNaN() && !z.isNaN() && !w.isNaN() - - fun minimumPerComponent(other: IVector4f<*>): Vector4f { - return Vector4f( - x = x.coerceAtMost(other.x), - y = y.coerceAtMost(other.y), - ) - } - - fun maximumPerComponent(other: IVector4f<*>): Vector4f { - return Vector4f( - x = x.coerceAtLeast(other.x), - y = y.coerceAtLeast(other.y), - ) - } - - fun clampPerComponent(min: IVector4f<*>, max: IVector4f<*>): Vector4f { - return Vector4f( - x = x.coerceAtLeast(min.x).coerceAtMost(max.x), - y = y.coerceAtLeast(min.y).coerceAtMost(max.y), - ) - } - - override val columns = 1 - override val rows = 4 - - override fun get(row: Int, column: Int): Float { - if (column != 0) { - throw IndexOutOfBoundsException("Column must be 0 ($column given)") - } - - return when (row) { - 0 -> x - 1 -> y - 2 -> z - 3 -> w - else -> throw IndexOutOfBoundsException("Row out of bounds: $row") - } - } - - operator fun times(other: IMatrixLikeFloat): T { - if (other.rows >= 4 && other.columns >= 4) { - val x = this.x * other[0, 0] + - this.y * other[0, 1] + - this.z * other[0, 2] + - this.w * other[0, 3] - - val y = this.x * other[1, 0] + - this.y * other[1, 1] + - this.z * other[1, 2] + - this.w * other[1, 3] - - val z = this.x * other[2, 0] + - this.y * other[2, 1] + - this.z * other[2, 2] + - this.w * other[2, 3] - - val w = this.x * other[3, 0] + - this.y * other[3, 1] + - this.z * other[3, 2] + - this.w * other[3, 3] - - return make(x, y, z, w) - } - - throw IllegalArgumentException("Incompatible matrix provided: ${other.rows} x ${other.columns}") - } - - protected abstract fun make(x: Float, y: Float, z: Float, w: Float): T -} - -data class Vector4f(override val x: Float = 0f, override val y: Float = 0f, override val z: Float = 0f, override val w: Float = 0f) : IVector4f() { - override fun make(x: Float, y: Float, z: Float, w: Float): Vector4f { - return Vector4f(x, y, z, w) - } -} - -data class MutableVector4f(override var x: Float = 0f, override var y: Float = 0f, override var z: Float = 0f, override var w: Float = 0f) : IVector4f() { - override fun make(x: Float, y: Float, z: Float, w: Float): MutableVector4f { - this.x = x - this.y = y - this.z = z - this.w = w - return this - } -} - -abstract class IVector4d> : IMatrixLike, IMatrixLikeDouble, IStruct4d { - abstract val x: Double - abstract val y: Double - abstract val z: Double - abstract val w: Double - - operator fun plus(other: IVector4f<*>) = make(x + other.x, y + other.y, z + other.z, w + other.w) - operator fun minus(other: IVector4f<*>) = make(x - other.x, y - other.y, z - other.z, w + other.w) - operator fun times(other: IVector4f<*>) = make(x * other.x, y * other.y, z * other.z, w + other.w) - operator fun div(other: IVector4f<*>) = make(x / other.x, y / other.y, z / other.z, w + other.w) - - operator fun plus(other: Double) = make(x + other, y + other, z + other, w + other) - operator fun minus(other: Double) = make(x - other, y - other, z - other, w - other) - operator fun times(other: Double) = make(x * other, y * other, z * other, w * other) - operator fun div(other: Double) = make(x / other, y / other, z / other, w / other) - - operator fun unaryMinus() = make(-x, -y, -z, -w) - - override val columns = 1 - override val rows = 4 - - override fun get(row: Int, column: Int): Double { - if (column != 0) { - throw IndexOutOfBoundsException("Column must be 0 ($column given)") - } - - return when (row) { - 0 -> x - 1 -> y - 2 -> z - 3 -> w - else -> throw IndexOutOfBoundsException("Row out of bounds: $row") - } - } - - operator fun times(other: IMatrixLikeDouble): T { - if (other.rows >= 4 && other.columns >= 4) { - val x = this.x * other[0, 0] + - this.y * other[0, 1] + - this.z * other[0, 2] + - this.w * other[0, 3] - - val y = this.x * other[1, 0] + - this.y * other[1, 1] + - this.z * other[1, 2] + - this.w * other[1, 3] - - val z = this.x * other[2, 0] + - this.y * other[2, 1] + - this.z * other[2, 2] + - this.w * other[2, 3] - - val w = this.x * other[3, 0] + - this.y * other[3, 1] + - this.z * other[3, 2] + - this.w * other[3, 3] - - return make(x, y, z, w) - } - - throw IllegalArgumentException("Incompatible matrix provided: ${other.rows} x ${other.columns}") - } - - protected abstract fun make(x: Double, y: Double, z: Double, w: Double): T -} - -data class Vector4d(override val x: Double = 0.0, override val y: Double = 0.0, override val z: Double = 0.0, override val w: Double = 0.0) : IVector4d() { - override fun make(x: Double, y: Double, z: Double, w: Double): Vector4d { - return Vector4d(x, y, z, w) - } -} - -data class MutableVector4d(override var x: Double = 0.0, override var y: Double = 0.0, override var z: Double = 0.0, override var w: Double = 0.0) : IVector4d() { - override fun make(x: Double, y: Double, z: Double, w: Double): MutableVector4d { - this.x = x - this.y = y - this.z = z - this.w = w - return this - } -} diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/world/Chunk.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/world/Chunk.kt index c791d196..2096f061 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/world/Chunk.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/world/Chunk.kt @@ -1,10 +1,13 @@ package ru.dbotthepony.kstarbound.world -import ru.dbotthepony.kstarbound.api.IStruct2d -import ru.dbotthepony.kstarbound.api.IStruct2i import ru.dbotthepony.kstarbound.defs.TileDefinition import ru.dbotthepony.kstarbound.math.* import ru.dbotthepony.kstarbound.world.entities.Entity +import ru.dbotthepony.kvector.api.IStruct2d +import ru.dbotthepony.kvector.api.IStruct2i +import ru.dbotthepony.kvector.util2d.AABB +import ru.dbotthepony.kvector.vector.ndouble.Vector2d +import ru.dbotthepony.kvector.vector.nint.Vector2i import java.util.* import kotlin.collections.ArrayList import kotlin.collections.HashSet @@ -156,13 +159,28 @@ const val CHUNK_SIZE_FF = CHUNK_SIZE - 1 const val CHUNK_SIZEf = CHUNK_SIZE.toFloat() const val CHUNK_SIZEd = CHUNK_SIZE.toDouble() -data class ChunkPos(override val x: Int, override val y: Int) : IVector2i() { +data class ChunkPos(val x: Int, val y: Int) { constructor(pos: IStruct2i) : this(pos.component1(), pos.component2()) - override fun make(x: Int, y: Int) = ChunkPos(x, y) val firstBlock get() = Vector2i(x shl CHUNK_SHIFT, y shl CHUNK_SHIFT) val lastBlock get() = Vector2i(((x + 1) shl CHUNK_SHIFT) - 1, ((y + 1) shl CHUNK_SHIFT) - 1) + fun up(): ChunkPos { + return ChunkPos(x, y + 1) + } + + fun down(): ChunkPos { + return ChunkPos(x, y - 1) + } + + fun left(): ChunkPos { + return ChunkPos(x + 1, y) + } + + fun right(): ChunkPos { + return ChunkPos(x - 1, y) + } + companion object { val ZERO = ChunkPos(0, 0) @@ -375,10 +393,12 @@ abstract class Chunk, This : Chunk, This : Chunk, ChunkType : Chunk { - var dot = deltaMovement.invDotProduct(normal) + var dot = deltaMovement.pseudoDot(normal) val magnitude = deltaMovement.length * weakDoubleZeroing(remainingTime, epsilon = EPSILON) if (dot > 0.0) { @@ -402,7 +406,7 @@ abstract class World, ChunkType : Chunk { - val dot = deltaMovement.invDotProduct(normal) * remainingTime + val dot = deltaMovement.pseudoDot(normal) * remainingTime if (weakDoubleZeroing(dot) != 0.0) { deltaMovement = Vector2d(dot * normal.y, dot * normal.x) @@ -429,11 +433,11 @@ abstract class World, ChunkType : Chunk 0.00001 && normal.y.absoluteValue > 0.00001) { - deltaMovement *= Vector2d.INVERT_XY + deltaMovement *= Vector2d.NEGATIVE_XY } else if (normal.x.absoluteValue > 0.00001) { - deltaMovement *= Vector2d.INVERT_X + deltaMovement *= Vector2d.NEGATIVE_X } else if (normal.y.absoluteValue > 0.00001) { - deltaMovement *= Vector2d.INVERT_Y + deltaMovement *= Vector2d.NEGATIVE_Y } } } diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/world/entities/AliveEntity.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/world/entities/AliveEntity.kt index 9dfa8c43..8926172b 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/world/entities/AliveEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/world/entities/AliveEntity.kt @@ -1,10 +1,10 @@ package ru.dbotthepony.kstarbound.world.entities import ru.dbotthepony.kstarbound.client.ClientWorld -import ru.dbotthepony.kstarbound.math.AABB -import ru.dbotthepony.kstarbound.math.Vector2d -import ru.dbotthepony.kstarbound.util.Color import ru.dbotthepony.kstarbound.world.World +import ru.dbotthepony.kvector.util2d.AABB +import ru.dbotthepony.kvector.vector.Color +import ru.dbotthepony.kvector.vector.ndouble.Vector2d import kotlin.math.absoluteValue enum class Move { @@ -82,7 +82,8 @@ abstract class WalkableMovementController(entity: T) : Move var isDucked = false protected set - override val currentAABB: AABB get() { + override val currentAABB: AABB + get() { if (isDucked) { return entity.duckingAABB } diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/world/entities/Entity.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/world/entities/Entity.kt index 7ace1eab..bf5b5b23 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/world/entities/Entity.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/world/entities/Entity.kt @@ -1,12 +1,9 @@ package ru.dbotthepony.kstarbound.world.entities -import org.apache.logging.log4j.LogManager -import ru.dbotthepony.kstarbound.math.AABB -import ru.dbotthepony.kstarbound.math.Vector2d -import ru.dbotthepony.kstarbound.math.lerp import ru.dbotthepony.kstarbound.world.Chunk import ru.dbotthepony.kstarbound.world.ChunkPos import ru.dbotthepony.kstarbound.world.World +import ru.dbotthepony.kvector.vector.ndouble.Vector2d /** * Интерфейс служит лишь для убирания жёсткой зависимости от класса Entity diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/world/entities/MovementController.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/world/entities/MovementController.kt index b3621e63..358f56a0 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/world/entities/MovementController.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/world/entities/MovementController.kt @@ -1,8 +1,8 @@ package ru.dbotthepony.kstarbound.world.entities -import ru.dbotthepony.kstarbound.math.AABB -import ru.dbotthepony.kstarbound.math.Vector2d import ru.dbotthepony.kstarbound.math.lerp +import ru.dbotthepony.kvector.util2d.AABB +import ru.dbotthepony.kvector.vector.ndouble.Vector2d enum class CollisionResolution { STOP, @@ -62,7 +62,7 @@ abstract class MovementController(val entity: T) { protected fun isSpaceOpen(relative: Vector2d, delta: Double) = !sweepRelative(relative, delta).hitAnything fun dropToFloor() { - val sweep = sweepRelative(Vector2d.DROP_TO_FLOOR, 1.0, CollisionResolution.STOP) + val sweep = sweepRelative(DROP_TO_FLOOR, 1.0, CollisionResolution.STOP) if (!sweep.hitAnything) return @@ -82,12 +82,12 @@ abstract class MovementController(val entity: T) { this.pos += this.velocity * delta if (nextOnGroundUpdate <= world.timer || !onGround) { - onGround = sweep.hitNormal.dotProduct(world.gravity.normalized) <= -0.98 + onGround = sweep.hitNormal.dot(world.gravity.normalized) <= -0.98 groundNormal = sweep.hitNormal if (!onGround) { val sweepGround = sweepRelative(world.gravity * delta, delta) - onGround = sweepGround.hitAnything && sweepGround.hitNormal.dotProduct(world.gravity.normalized) <= -0.98 + onGround = sweepGround.hitAnything && sweepGround.hitNormal.dot(world.gravity.normalized) <= -0.98 groundNormal = sweepGround.hitNormal } } @@ -114,6 +114,10 @@ abstract class MovementController(val entity: T) { protected open fun onTouchSurface(velocity: Vector2d, normal: Vector2d) { entity.onTouchSurface(velocity, normal) } + + companion object { + private val DROP_TO_FLOOR = Vector2d(y = -1_000.0) + } } /** diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/world/entities/PlayerEntity.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/world/entities/PlayerEntity.kt index 8c9b4f1c..4dd3a0ef 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/world/entities/PlayerEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/world/entities/PlayerEntity.kt @@ -1,8 +1,8 @@ package ru.dbotthepony.kstarbound.world.entities -import ru.dbotthepony.kstarbound.math.AABB -import ru.dbotthepony.kstarbound.math.Vector2d import ru.dbotthepony.kstarbound.world.World +import ru.dbotthepony.kvector.util2d.AABB +import ru.dbotthepony.kvector.vector.ndouble.Vector2d class PlayerMovementController(entity: PlayerEntity) : WalkableMovementController(entity) { public override var moveDirection = Move.STAND_STILL diff --git a/src/test/kotlin/ru/dbotthepony/kstarbound/test/MathTests.kt b/src/test/kotlin/ru/dbotthepony/kstarbound/test/MathTests.kt index 1633c4a7..a9d9056f 100644 --- a/src/test/kotlin/ru/dbotthepony/kstarbound/test/MathTests.kt +++ b/src/test/kotlin/ru/dbotthepony/kstarbound/test/MathTests.kt @@ -7,13 +7,12 @@ import ru.dbotthepony.kstarbound.world.CHUNK_SIZE import ru.dbotthepony.kstarbound.world.CHUNK_SIZE_FF import ru.dbotthepony.kstarbound.world.CHUNK_SIZEd import ru.dbotthepony.kstarbound.world.ChunkPos -import ru.dbotthepony.kvector.matrix.adjugateMatrix import ru.dbotthepony.kvector.matrix.multiplyMatrix -import ru.dbotthepony.kvector.matrix.inverseMatrix -import ru.dbotthepony.kvector.matrix.ndouble.MatrixVd -import ru.dbotthepony.kvector.matrix.ndouble.MutableMatrixVd import ru.dbotthepony.kvector.narray.Double2Dimensional -import java.util.* +import ru.dbotthepony.kvector.util2d.AABB +import ru.dbotthepony.kvector.util2d.AABBi +import ru.dbotthepony.kvector.vector.ndouble.Vector2d +import ru.dbotthepony.kvector.vector.nint.Vector2i object MathTests { @Test diff --git a/src/test/kotlin/ru/dbotthepony/kstarbound/test/MatrixTest.kt b/src/test/kotlin/ru/dbotthepony/kstarbound/test/MatrixTest.kt index fc27ccc1..6672c315 100644 --- a/src/test/kotlin/ru/dbotthepony/kstarbound/test/MatrixTest.kt +++ b/src/test/kotlin/ru/dbotthepony/kstarbound/test/MatrixTest.kt @@ -2,25 +2,25 @@ package ru.dbotthepony.kstarbound.test import jdk.jfr.Description import org.junit.jupiter.api.Test -import ru.dbotthepony.kstarbound.math.Matrix3f +import ru.dbotthepony.kvector.matrix.nfloat.Matrix3f object MatrixTest { @Test @Description("Matrix test") fun test() { - val a = Matrix3f( + val a = Matrix3f.rm( 4f, 2f, 0f, 0f, 8f, 1f, 0f, 1f, 0f ) - val b = Matrix3f( + val b = Matrix3f.rm( 4f, 2f, 1f, 2f, 0f, 4f, 9f, 4f, 2f ) - val c = Matrix3f( + val c = Matrix3f.rm( 20f, 8f, 12f, 25f, 4f, 34f, 2f, 0f, 4f