/// @return DhbMatrixAlgebra.SymmetricMatrix
 public DhbVector[] Eigenvectors()
 {
     int n = _rows.GetLength(0);
     DhbVector[] eigenvectors = new DhbVector[n];
     double[] temp = new double[n];
     for (int i = 0; i < n; i++)
     {
         for (int j = 0; j < n; j++)
             temp[j] = _transform[j, i];
         eigenvectors[i] = new DhbVector(temp);
     }
     return eigenvectors;
 }
 /// @return double
 /// @param x double
 public double Error(double x)
 {
     int n = this.Degree + 1;
     double[] errors = new double[n];
     errors[0] = 1;
     for (int i = 1; i < n; i++)
         errors[i] = errors[i - 1] * x;
     DhbVector errorVector = new DhbVector(errors);
     double answer;
     try
     {
         answer = errorVector * (_errorMatrix * errorVector);
     }
     catch (DhbIllegalDimension) { answer = double.NaN; } ;
     return System.Math.Sqrt(answer);
 }
 /// @return double[]
 /// @param c double[]
 public DhbVector Solve(DhbVector c)
 {
     double[] components = Solve(c.Components);
     return components == null ? null : new DhbVector(components);
 }
 /// Construct a system of linear equation Ax = y.
 /// @param a MatrixAlgebra.Matrix	matrix A
 /// @param y MatrixAlgebra.DhbVector	vector y
 /// @exception MatrixAlgebra.DhbIllegalDimension
 ///								if the system's matrix is not square
 ///								if vector dimension does not match
 ///											that of the matrix
 public LinearEquations(Matrix a, DhbVector y)
     : this(a.Components, y.Components)
 {
 }
Exemple #5
0
 /// Compute the scalar product (or dot product) of two vectors.
 /// No dimension checking is made.
 /// @return double the scalar product of the receiver with the argument
 /// @param v DHBmatrixAlgebra.DhbVector
 protected internal double SecureProduct(DhbVector v)
 {
     double sum = 0;
     for (int i = 0; i < _components.Length; i++)
         sum += _components[i] * v._components[i];
     return sum;
 }
 /// Computes the solution for constant vector p applying
 /// backsubstitution.
 /// @param p int
 /// @exception ArithmeticException if one diagonal element
 ///									of the triangle matrix is zero.
 private void BackSubstitution(int p)
 {
     int n = _rows.GetLength(0);
     double[] answer = new double[n];
     double x;
     for (int i = n - 1; i >= 0; i--)
     {
         x = _rows[i, n + p];
         for (int j = i + 1; j < n; j++)
             x -= answer[j] * _rows[i, j];
         answer[i] = x / _rows[i, i];
     }
     _solutions[p] = new DhbVector(answer);
 }
Exemple #7
0
 /// @return MatrixAlgebra.Matrix	tensor product with the specified
 ///																vector
 /// @param v MatrixAlgebra.DhbVector	second vector to build tensor
 ///														product with.
 public Matrix TensorProduct(DhbVector v)
 {
     int n = _components.Length;
     int m = v.Dimension;
     double[,] newComponents = new double[n, m];
     for (int i = 0; i < n; i++)
     {
         for (int j = 0; j < m; j++)
             newComponents[i, j] = _components[i] * v._components[j];
     }
     return n == m ? new SymmetricMatrix(newComponents)
                           : new Matrix(newComponents);
 }
Exemple #8
0
 /// @return true if the supplied vector is equal to the receiver
 /// @param v DHBmatrixAlgebra.DhbVector
 public bool Equals(DhbVector v)
 {
     if (v.Dimension != _components.Length)
         return false;
     for (int i = 0; i < _components.Length; i++)
     {
         if (v._components[i] != _components[i])
             return false;
     }
     return true;
 }
Exemple #9
0
 /// @param v DhbMatrixAlgebra.DhbVector
 /// @exception DhbMatrixAlgebra.DhbIllegalDimension if the vector
 /// and supplied vector do not have the same dimension.
 public void AccumulateNegated(DhbVector v)
 {
     AccumulateNegated(v._components);
 }
Exemple #10
0
 /// @param v DhbMatrixAlgebra.DhbVector
 /// @exception DhbMatrixAlgebra.DhbIllegalDimension if the vector
 /// and supplied vector do not have the same dimension.
 public void Accumulate(DhbVector v)
 {
     Accumulate(v._components);
 }
Exemple #11
0
 /// Computes the product of the matrix with a vector.
 /// @return DHBmatrixAlgebra.DhbVector
 /// @param v DHBmatrixAlgebra.DhbVector
 protected internal DhbVector SecureProduct(DhbVector v)
 {
     int n = this.Rows;
     int m = this.Columns;
     double[] vectorComponents = new double[n];
     for (int i = 0; i < n; i++)
     {
         vectorComponents[i] = 0;
         for (int j = 0; j < m; j++)
             vectorComponents[i] += _components[i, j] * v.Components[j];
     }
     return new DhbVector(vectorComponents);
 }