Browse Source

LA: Fix arg validation bug in routine to copy a vector into a sub-row of a matrix

optimization-1
Christoph Ruegg 13 years ago
parent
commit
a803ebf44b
  1. 2
      src/Numerics/LinearAlgebra/Builder.cs
  2. 2
      src/Numerics/LinearAlgebra/Storage/VectorStorage.cs
  3. 10
      src/Numerics/LinearAlgebra/Vector.cs

2
src/Numerics/LinearAlgebra/Builder.cs

@ -1005,7 +1005,7 @@ namespace MathNet.Numerics.LinearAlgebra
/// This new vector will be independent from the enumerable. /// This new vector will be independent from the enumerable.
/// A new memory block will be allocated for storing the vector. /// A new memory block will be allocated for storing the vector.
/// </summary> /// </summary>
public Vector<T> SparseVectorOfIndexedEnumerable(int length, IEnumerable<Tuple<int, T>> enumerable) public Vector<T> SparseVectorOfIndexed(int length, IEnumerable<Tuple<int, T>> enumerable)
{ {
return SparseVector(SparseVectorStorage<T>.OfIndexedEnumerable(length, enumerable)); return SparseVector(SparseVectorStorage<T>.OfIndexedEnumerable(length, enumerable));
} }

2
src/Numerics/LinearAlgebra/Storage/VectorStorage.cs

@ -318,7 +318,7 @@ namespace MathNet.Numerics.LinearAlgebra.Storage
throw new ArgumentNullException("target"); throw new ArgumentNullException("target");
} }
ValidateSubRowRange(target, rowIndex, targetColumnIndex, sourceColumnIndex, columnCount); ValidateSubRowRange(target, rowIndex, sourceColumnIndex, targetColumnIndex, columnCount);
CopyToSubRowUnchecked(target, rowIndex, sourceColumnIndex, targetColumnIndex, columnCount, skipClearing); CopyToSubRowUnchecked(target, rowIndex, sourceColumnIndex, targetColumnIndex, columnCount, skipClearing);
} }

10
src/Numerics/LinearAlgebra/Vector.cs

@ -58,7 +58,7 @@ namespace MathNet.Numerics.LinearAlgebra
Count = storage.Length; Count = storage.Length;
} }
public static readonly Builder<T> Builder = BuilderInstance<T>.Instance; public static readonly Builder<T> Build = BuilderInstance<T>.Instance;
/// <summary> /// <summary>
/// Gets the raw vector data storage. /// Gets the raw vector data storage.
@ -141,8 +141,8 @@ namespace MathNet.Numerics.LinearAlgebra
public Matrix<T> CreateMatrix(int rows, int columns) public Matrix<T> CreateMatrix(int rows, int columns)
{ {
return Storage.IsDense return Storage.IsDense
? Builder.DenseMatrix(rows, columns) ? Build.DenseMatrix(rows, columns)
: Builder.SparseMatrix(rows, columns); : Build.SparseMatrix(rows, columns);
} }
/// <summary> /// <summary>
@ -153,8 +153,8 @@ namespace MathNet.Numerics.LinearAlgebra
public Vector<T> CreateVector(int size) public Vector<T> CreateVector(int size)
{ {
return Storage.IsDense return Storage.IsDense
? Builder.DenseVector(size) ? Build.DenseVector(size)
: Builder.SparseVector(size); : Build.SparseVector(size);
} }
/// <summary> /// <summary>

Loading…
Cancel
Save