/// <summary> /// Transforms the specified vector. /// </summary> /// <param name="vector">The vector.</param> /// <param name="resultingVector">The resulting vector.</param> /// <exception cref="System.ArgumentException">The input vector must have the same length as this matrix has columns;vector</exception> public void Transform(IReadableVector vector, ref IWritableVector resultingVector) { if (vector.Length != _columns) { throw new ArgumentException("The input vector must have the same length as this matrix has columns", "vector"); } if (resultingVector.Length != _rows) { throw new ArgumentException("The resulting vector must have the same length as this matrix has rows", "vector"); } // _transformationExpression(this, vector, resultingVector); for (int r = 0; r < Rows; ++r) { double sum = 0; for (int c = 0; c < Columns; ++c) { var m = GetValue(r, c); var v = vector.GetValue(c); sum += m * v; } resultingVector.SetValue(r, sum); } }
/// <summary> /// Transforms the specified vector. /// </summary> /// <param name="vector">The vector.</param> /// <param name="output">The output.</param> public void Transform(IControlVector vector, ref IStateVector output) { IWritableVector result = output; Transform(vector, ref result); }
/// <summary> /// Adds a state vector to this instance and returns the summed vector /// </summary> /// <param name="other">The vector to add</param> /// <param name="output">The output.</param> public void Add(IStateVector other, ref IStateVector output) { IWritableVector result = output; Add(other, ref result); }
/// <summary> /// Transforms the specified vector. /// </summary> /// <param name="vector">The vector.</param> /// <param name="resultingVector">The resulting vector.</param> /// <exception cref="System.ArgumentException">The input vector must have the same length as this matrix has columns;vector</exception> public void Transform(IReadableVector vector, ref IWritableVector resultingVector) { if (vector.Length != _columns) throw new ArgumentException("The input vector must have the same length as this matrix has columns", "vector"); if (resultingVector.Length != _rows) throw new ArgumentException("The resulting vector must have the same length as this matrix has rows", "vector"); // _transformationExpression(this, vector, resultingVector); for (int r = 0; r < Rows; ++r) { double sum = 0; for (int c = 0; c < Columns; ++c) { var m = GetValue(r, c); var v = vector.GetValue(c); sum += m*v; } resultingVector.SetValue(r, sum); } }