コード例 #1
0
ファイル: CommonOps_FDF2.cs プロジェクト: lulzzz/BraneCloud
        /**
         * <p>
         * Returns the value of the element in the vector that has the minimum value.<br>
         * <br>
         * Min{ a<sub>i</sub> } for all<br>
         * </p>
         *
         * @param a A matrix. Not modified.
         * @return The value of element in the vector with the minimum value.
         */
        public static float elementMin(FMatrix2 a)
        {
            float min = a.a1;

            if (a.a2 < min)
            {
                min = a.a2;
            }

            return(min);
        }
コード例 #2
0
ファイル: CommonOps_FDF2.cs プロジェクト: lulzzz/BraneCloud
        /**
         * <p>
         * Returns the value of the element in the vector that has the largest value.<br>
         * <br>
         * Max{ a<sub>i</sub> } for all i<br>
         * </p>
         *
         * @param a A vector. Not modified.
         * @return The max element value of the matrix.
         */
        public static float elementMax(FMatrix2 a)
        {
            float max = a.a1;

            if (a.a2 > max)
            {
                max = a.a2;
            }

            return(max);
        }
コード例 #3
0
 public static bool isIdentical(FMatrix2 a, FMatrix2 b, float tol)
 {
     if (!MatrixFeatures_FDRM.isIdentical(a.a1, b.a1, tol))
     {
         return(false);
     }
     if (!MatrixFeatures_FDRM.isIdentical(a.a2, b.a2, tol))
     {
         return(false);
     }
     return(true);
 }
コード例 #4
0
 public static bool hasUncountable(FMatrix2 a)
 {
     if (UtilEjml.isUncountable(a.a1))
     {
         return(true);
     }
     if (UtilEjml.isUncountable(a.a2))
     {
         return(true);
     }
     return(false);
 }
コード例 #5
0
ファイル: NormOps_FDF2.cs プロジェクト: lulzzz/BraneCloud
        public static float normF(FMatrix2 M)
        {
            float scale = CommonOps_FDF2.elementMaxAbs(M);

            if (scale == 0.0f)
            {
                return(0.0f);
            }

            float a1 = M.a1 / scale, a2 = M.a2 / scale;
            float sum = a1 * a1 + a2 * a2;

            return(scale * (float)Math.Sqrt(sum));
        }
コード例 #6
0
ファイル: CommonOps_FDF2.cs プロジェクト: lulzzz/BraneCloud
        /**
         * <p>
         * Returns the absolute value of the element in the vector that has the smallest absolute value.<br>
         * <br>
         * Min{ |a<sub>i</sub>| } for all i<br>
         * </p>
         *
         * @param a A matrix. Not modified.
         * @return The max element value of the vector.
         */
        public static float elementMinAbs(FMatrix2 a)
        {
            float min = Math.Abs(a.a1);
            float tmp = Math.Abs(a.a1);

            if (tmp < min)
            {
                min = tmp;
            }
            tmp = Math.Abs(a.a2);
            if (tmp < min)
            {
                min = tmp;
            }

            return(min);
        }
コード例 #7
0
ファイル: CommonOps_FDF2.cs プロジェクト: lulzzz/BraneCloud
        /**
         * <p>
         * Returns the absolute value of the element in the vector that has the largest absolute value.<br>
         * <br>
         * Max{ |a<sub>i</sub>| } for all i<br>
         * </p>
         *
         * @param a A matrix. Not modified.
         * @return The max abs element value of the vector.
         */
        public static float elementMaxAbs(FMatrix2 a)
        {
            float max = Math.Abs(a.a1);
            float tmp = Math.Abs(a.a2);

            if (tmp > max)
            {
                max = tmp;
            }
            tmp = Math.Abs(a.a2);
            if (tmp > max)
            {
                max = tmp;
            }

            return(max);
        }
コード例 #8
0
        /**
         * Converts {@link FMatrixRMaj} into {@link FMatrix2}
         *
         * @param input Input matrix.
         * @param output Output matrix.  If null a new matrix will be declared.
         * @return Converted matrix.
         */
        public static FMatrix2 convert(FMatrixRMaj input, FMatrix2 output)
        {
            if (output == null)
            {
                output = new FMatrix2();
            }

            if (input.getNumRows() != 1 && input.getNumCols() != 1)
            {
                throw new ArgumentException("One row or column must have a length of 1 for it to be a vector");
            }
            int length = Math.Max(input.getNumRows(), input.getNumCols());

            if (length != 2)
            {
                throw new ArgumentException("Length of input vector is not 2.  It is " + length);
            }

            output.a1 = input.data[0];
            output.a2 = input.data[1];

            return(output);
        }
コード例 #9
0
ファイル: CommonOps_FDF2.cs プロジェクト: lulzzz/BraneCloud
        /**
         * Extracts the column from the matrix a.
         * @param a Input matrix
         * @param column Which column is to be extracted
         * @param output output. Storage for the extracted column. If null then a new vector will be returned.
         * @return The extracted column.
         */
        public static FMatrix2 extractColumn(FMatrix2x2 a, int column, FMatrix2 output)
        {
            if (output == null)
            {
                output = new FMatrix2();
            }
            switch (column)
            {
            case 0:
                output.a1 = a.a11;
                output.a2 = a.a21;
                break;

            case 1:
                output.a1 = a.a12;
                output.a2 = a.a22;
                break;

            default:
                throw new ArgumentException("Out of bounds column.  column = " + column);
            }
            return(output);
        }
コード例 #10
0
ファイル: CommonOps_FDF2.cs プロジェクト: lulzzz/BraneCloud
        /**
         * Extracts the row from the matrix a.
         * @param a Input matrix
         * @param row Which row is to be extracted
         * @param output output. Storage for the extracted row. If null then a new vector will be returned.
         * @return The extracted row.
         */
        public static FMatrix2 extractRow(FMatrix2x2 a, int row, FMatrix2 output)
        {
            if (output == null)
            {
                output = new FMatrix2();
            }
            switch (row)
            {
            case 0:
                output.a1 = a.a11;
                output.a2 = a.a12;
                break;

            case 1:
                output.a1 = a.a21;
                output.a2 = a.a22;
                break;

            default:
                throw new ArgumentException("Out of bounds row.  row = " + row);
            }
            return(output);
        }
コード例 #11
0
ファイル: CommonOps_FDF2.cs プロジェクト: lulzzz/BraneCloud
 /**
  * <p>
  * Performs an in-place element by element scalar multiplication.<br>
  * <br>
  * a<sub>ij</sub> = &alpha;*a<sub>ij</sub>
  * </p>
  *
  * @param a The vector that is to be scaled.  Modified.
  * @param alpha the amount each element is multiplied by.
  */
 public static void scale(float alpha, FMatrix2 a)
 {
     a.a1 *= alpha;
     a.a2 *= alpha;
 }
コード例 #12
0
ファイル: CommonOps_FDF2.cs プロジェクト: lulzzz/BraneCloud
 /**
  * <p>Performs the following operation:<br>
  * <br>
  * a = a + b <br>
  * a<sub>i</sub> = a<sub>i</sub> + b<sub>i</sub> <br>
  * </p>
  *
  * @param a A Vector. Modified.
  * @param b A Vector. Not modified.
  */
 public static void addEquals(FMatrix2 a, FMatrix2 b)
 {
     a.a1 += b.a1;
     a.a2 += b.a2;
 }
コード例 #13
0
ファイル: CommonOps_FDF2.cs プロジェクト: lulzzz/BraneCloud
 /**
  * <p>Performs an element by element division operation:<br>
  * <br>
  * c<sub>i</sub> = a<sub>i</sub> / b<sub>i</sub> <br>
  * </p>
  * @param a The left vector in the division operation. Not modified.
  * @param b The right vector in the division operation. Not modified.
  * @param c Where the results of the operation are stored. Modified.
  */
 public static void elementDiv(FMatrix2 a, FMatrix2 b, FMatrix2 c)
 {
     c.a1 = a.a1 / b.a1;
     c.a2 = a.a2 / b.a2;
 }
コード例 #14
0
ファイル: CommonOps_FDF2.cs プロジェクト: lulzzz/BraneCloud
 /**
  * <p>Performs vector to matrix multiplication:<br>
  * <br>
  * c = a * b <br>
  * <br>
  * c<sub>j</sub> = &sum;<sub>k=1:n</sub> { b<sub>k</sub> * a<sub>kj</sub> }
  * </p>
  *
  * @param a The left vector in the multiplication operation. Not modified.
  * @param b The right matrix in the multiplication operation. Not modified.
  * @param c Where the results of the operation are stored. Modified.
  */
 public static void mult(FMatrix2 a, FMatrix2x2 b, FMatrix2 c)
 {
     c.a1 = a.a1 * b.a11 + a.a2 * b.a21;
     c.a2 = a.a1 * b.a12 + a.a2 * b.a22;
 }
コード例 #15
0
ファイル: CommonOps_FDF2.cs プロジェクト: lulzzz/BraneCloud
 /**
  * <p>
  * Sets every element in the vector to the specified value.<br>
  * <br>
  * a<sub>i</sub> = value
  * <p>
  *
  * @param a A vector whose elements are about to be set. Modified.
  * @param v The value each element will have.
  */
 public static void fill(FMatrix2 a, float v)
 {
     a.a1 = v;
     a.a2 = v;
 }
コード例 #16
0
ファイル: NormOps_FDF2.cs プロジェクト: lulzzz/BraneCloud
        public static float fastNormF(FMatrix2 M)
        {
            float sum = M.a1 * M.a1 + M.a2 * M.a2;

            return((float)Math.Sqrt(sum));
        }
コード例 #17
0
ファイル: CommonOps_FDF2.cs プロジェクト: lulzzz/BraneCloud
 /**
  * <p>Performs the following operation:<br>
  * <br>
  * c = a - b <br>
  * c<sub>i</sub> = a<sub>i</sub> - b<sub>i</sub> <br>
  * </p>
  *
  * <p>
  * Vector C can be the same instance as Vector A and/or B.
  * </p>
  *
  * @param a A Vector. Not modified.
  * @param b A Vector. Not modified.
  * @param c A Vector where the results are stored. Modified.
  */
 public static void subtract(FMatrix2 a, FMatrix2 b, FMatrix2 c)
 {
     c.a1 = a.a1 - b.a1;
     c.a2 = a.a2 - b.a2;
 }
コード例 #18
0
ファイル: CommonOps_FDF2.cs プロジェクト: lulzzz/BraneCloud
 /**
  * <p>Performs the following operation:<br>
  * <br>
  * c = a + b <br>
  * c<sub>i</sub> = a<sub>i</sub> + b<sub>i</sub> <br>
  * </p>
  *
  * <p>
  * Vector C can be the same instance as Vector A and/or B.
  * </p>
  *
  * @param a A Vector. Not modified.
  * @param b A Vector. Not modified.
  * @param c A Vector where the results are stored. Modified.
  */
 public static void add(FMatrix2 a, FMatrix2 b, FMatrix2 c)
 {
     c.a1 = a.a1 + b.a1;
     c.a2 = a.a2 + b.a2;
 }
コード例 #19
0
ファイル: CommonOps_FDF2.cs プロジェクト: lulzzz/BraneCloud
 /**
  * <p>
  * Extracts all diagonal elements from 'input' and places them inside the 'output' vector. Elements
  * are in sequential order.
  * </p>
  *
  *
  * @param input Matrix.  Not modified.
  * @param output Vector containing diagonal elements.  Modified.
  */
 public static void diag(FMatrix2x2 input, FMatrix2 output)
 {
     output.a1 = input.a11;
     output.a2 = input.a22;
 }
コード例 #20
0
ファイル: CommonOps_FDF2.cs プロジェクト: lulzzz/BraneCloud
 /**
  * <p>Performs the vector dot product:<br>
  * <br>
  * c = a * b <br>
  * <br>
  * c &ge; &sum;<sub>k=1:n</sub> { b<sub>k</sub> * a<sub>k</sub> }
  * </p>
  *
  * @param a The left vector in the multiplication operation. Not modified.
  * @param b The right matrix in the multiplication operation. Not modified.
  * @return The dot product
  */
 public static float dot(FMatrix2 a, FMatrix2 b)
 {
     return(a.a1 * b.a1 + a.a2 * b.a2);
 }
コード例 #21
0
ファイル: CommonOps_FDF2.cs プロジェクト: lulzzz/BraneCloud
 /**
  * <p>
  * Performs an element by element scalar multiplication.<br>
  * <br>
  * b<sub>i</sub> = &alpha;*a<sub>i</sub>
  * </p>
  *
  * @param alpha the amount each element is multiplied by.
  * @param a The vector that is to be scaled.  Not modified.
  * @param b Where the scaled matrix is stored. Modified.
  */
 public static void scale(float alpha, FMatrix2 a, FMatrix2 b)
 {
     b.a1 = a.a1 * alpha;
     b.a2 = a.a2 * alpha;
 }
コード例 #22
0
ファイル: CommonOps_FDF2.cs プロジェクト: lulzzz/BraneCloud
 /**
  * <p>
  * Performs an in-place element by element scalar division. Scalar denominator.<br>
  * <br>
  * a<sub>i</sub> = a<sub>i</sub>/&alpha;
  * </p>
  *
  * @param a The vector whose elements are to be divided.  Modified.
  * @param alpha the amount each element is divided by.
  */
 public static void divide(FMatrix2 a, float alpha)
 {
     a.a1 /= alpha;
     a.a2 /= alpha;
 }
コード例 #23
0
ファイル: CommonOps_FDF2.cs プロジェクト: lulzzz/BraneCloud
 /**
  * <p>
  * Changes the sign of every element in the vector.<br>
  * <br>
  * a<sub>i</sub> = -a<sub>i</sub>
  * </p>
  *
  * @param a A vector. Modified.
  */
 public static void changeSign(FMatrix2 a)
 {
     a.a1 = -a.a1;
     a.a2 = -a.a2;
 }
コード例 #24
0
ファイル: NormOps_FDF2.cs プロジェクト: lulzzz/BraneCloud
        public static void normalizeF(FMatrix2 M)
        {
            float val = normF(M);

            CommonOps_FDF2.divide(M, val);
        }
コード例 #25
0
ファイル: CommonOps_FDF2.cs プロジェクト: lulzzz/BraneCloud
 /**
  * <p>Performs an element by element multiplication operation:<br>
  * <br>
  * a<sub>i</sub> = a<sub>i</sub> * b<sub>i</sub> <br>
  * </p>
  * @param a The left vector in the multiplication operation. Modified.
  * @param b The right vector in the multiplication operation. Not modified.
  */
 public static void elementMult(FMatrix2 a, FMatrix2 b)
 {
     a.a1 *= b.a1;
     a.a2 *= b.a2;
 }
コード例 #26
0
ファイル: CommonOps_FDF2.cs プロジェクト: lulzzz/BraneCloud
 /**
  * <p>Performs an element by element multiplication operation:<br>
  * <br>
  * c<sub>i</sub> = a<sub>i</sub> * b<sub>j</sub> <br>
  * </p>
  * @param a The left vector in the multiplication operation. Not modified.
  * @param b The right vector in the multiplication operation. Not modified.
  * @param c Where the results of the operation are stored. Modified.
  */
 public static void elementMult(FMatrix2 a, FMatrix2 b, FMatrix2 c)
 {
     c.a1 = a.a1 * b.a1;
     c.a2 = a.a2 * b.a2;
 }
コード例 #27
0
ファイル: CommonOps_FDF2.cs プロジェクト: lulzzz/BraneCloud
 /**
  * <p>Performs an element by element division operation:<br>
  * <br>
  * a<sub>i</sub> = a<sub>i</sub> / b<sub>i</sub> <br>
  * </p>
  * @param a The left vector in the division operation. Modified.
  * @param b The right vector in the division operation. Not modified.
  */
 public static void elementDiv(FMatrix2 a, FMatrix2 b)
 {
     a.a1 /= b.a1;
     a.a2 /= b.a2;
 }
コード例 #28
0
ファイル: CommonOps_FDF2.cs プロジェクト: lulzzz/BraneCloud
 /**
  * <p>
  * Performs an element by element scalar division.  Scalar denominator.<br>
  * <br>
  * b<sub>i</sub> = a<sub>i</sub> /&alpha;
  * </p>
  *
  * @param alpha the amount each element is divided by.
  * @param a The vector whose elements are to be divided.  Not modified.
  * @param b Where the results are stored. Modified.
  */
 public static void divide(FMatrix2 a, float alpha, FMatrix2 b)
 {
     b.a1 = a.a1 / alpha;
     b.a2 = a.a2 / alpha;
 }
コード例 #29
0
ファイル: CommonOps_FDF2.cs プロジェクト: lulzzz/BraneCloud
 /**
  * <p>Performs the following operation:<br>
  * <br>
  * a = a - b <br>
  * a<sub>i</sub> = a<sub>i</sub> - b<sub>i</sub> <br>
  * </p>
  *
  * @param a A Vector. Modified.
  * @param b A Vector. Not modified.
  */
 public static void subtractEquals(FMatrix2 a, FMatrix2 b)
 {
     a.a1 -= b.a1;
     a.a2 -= b.a2;
 }