\n\n\n\norg.jscience.mathematics.vector\n\n\n\n\n\n\n\n
\n\n\n\n\n
\n
\n
\n\n\n
\n

# Package org.jscience.mathematics.vector

\n
\n
Provides support for linear algebra\n in the form of `matrices` and \n `vectors`.
\n
\n

See: Description

\n
\n
\n
\n\n\n\n

## Package org.jscience.mathematics.vector Description

\n

Provides support for linear algebra\n in the form of `matrices` and \n `vectors`.

\n \n

With the `Matrix` class,\n you should be able to resolve linear systems of equations\n involving any kind of elements such as \n `Rational`,\n `ModuloInteger` (modulo operations),\n `Complex`,\n `RationalFunction`, etc.\n The main requirement being that your element class implements the mathematical\n `Field` interface.

\n \n

Most `numbers` and even invertible matrices\n themselves may implement this interface. Non-commutative multiplication is supported which\n allows for the resolution of systems of equations with invertible matrix coefficients (matrices of matrices).

\n\n

For classes embedding automatic error calculation (e.g.\n `Real` or `Amount`),\n the error on the solution obtained tells you if can trust that solution or not \n (e.g. system close to singularity). The following example illustrates this point.

\n \n

Let\'s say you have a simple electric circuit composed of 2 resistors in series\n with a battery. You want to know the voltage (U1, U2) at the nodes of the\n resistors and the current (I) traversing the circuit.

``\n    import static org.jscience.physics.units.SI.*;\n    \n            Amount<ElectricResistance> R1 = Amount.valueOf(100, 1, OHM); // 1% precision. \n            Amount<ElectricResistance> R2 = Amount.valueOf(300, 3, OHM); // 1% precision.\n            Amount<ElectricPotential> U0 = Amount.valueOf(28, 0.01, VOLT); // \xc2\xb10.01 V fluctuation.\n\n            // Equations:  U0 = U1 + U2       |1  1  0 |   |U1|   |U0|\n            //             U1 = R1 * I    =>  |-1 0  R1| * |U2| = |0 |\n            //             U2 = R2 * I        |0 -1  R2|   |I |   |0 |\n            //\n            //                                    A      *  X   =  B\n            //\n            DenseMatrix<Amount<?>> A = DenseMatrix.valueOf(new Amount<?>[][] {\n                { Amount.ONE,            Amount.ONE,            Amount.valueOf(0, OHM) },\n                { Amount.ONE.opposite(), Amount.ZERO,           R1 },\n                { Amount.ZERO,           Amount.ONE.opposite(), R2 } });\n            DenseVector<Amount<?>> B = DenseVector.valueOf(new Amount<?>[] \n                { U0, Amount.valueOf(0, VOLT), Amount.valueOf(0, VOLT) });\n            Vector<Amount<?>> X = A.solve(B);\n            System.out.println(X);\n            System.out.println(X.get(2).to(MILLI(AMPERE)));\n\n        > {(7.0 \xc2\xb1 1.6E-1) V, (21.0 \xc2\xb1 1.5E-1) V, (7.0E-2 \xc2\xb1 7.3E-4) V/\xce\xa9}\n        > (70.0 \xc2\xb1 7.3E-1) mA\n        ``
\n \n Because the `Amount` class guarantees \n the accuracy/precision of its calculations. As long as the input resistances, voltage\n stay within their specification range then the current is guaranteed\n to be `(70.0 \xc2\xb1 7.3E-1) mA`. When the inputs have no error specified, \n the error on the result corresponds to calculations numeric errors only\n (which might increase significantly if the matrix is close to singularity).

\n
\n\n
\n\n\n\n\n
\n
\n
\n\n\n

SCaVis 1.0 © jWork.org

\n\n\n