Browse Source

Minor optimization how we call Array.Copy

Reasoning and motivation see dotnet/corefx#3615
netstandard
Christoph Ruegg 11 years ago
parent
commit
b2e9445a88
  1. 2
      src/Numerics/ArrayExtensions.cs
  2. 26
      src/Numerics/LinearAlgebra/Complex/DiagonalMatrix.cs
  3. 6
      src/Numerics/LinearAlgebra/Complex/Factorization/DenseCholesky.cs
  4. 6
      src/Numerics/LinearAlgebra/Complex/Factorization/DenseLU.cs
  5. 8
      src/Numerics/LinearAlgebra/Complex/SparseVector.cs
  6. 26
      src/Numerics/LinearAlgebra/Complex32/DiagonalMatrix.cs
  7. 6
      src/Numerics/LinearAlgebra/Complex32/Factorization/DenseCholesky.cs
  8. 6
      src/Numerics/LinearAlgebra/Complex32/Factorization/DenseLU.cs
  9. 8
      src/Numerics/LinearAlgebra/Complex32/SparseVector.cs
  10. 14
      src/Numerics/LinearAlgebra/Double/DiagonalMatrix.cs
  11. 6
      src/Numerics/LinearAlgebra/Double/SparseVector.cs
  12. 14
      src/Numerics/LinearAlgebra/Single/DiagonalMatrix.cs
  13. 6
      src/Numerics/LinearAlgebra/Single/SparseVector.cs
  14. 4
      src/Numerics/LinearAlgebra/Storage/DenseColumnMajorMatrixStorage.cs
  15. 2
      src/Numerics/LinearAlgebra/Storage/DenseVectorStorage.cs
  16. 2
      src/Numerics/LinearAlgebra/Storage/DiagonalMatrixStorage.cs
  17. 4
      src/Numerics/LinearAlgebra/Storage/SparseCompressedRowMatrixStorage.cs
  18. 2
      src/Numerics/LinearAlgebra/Storage/SparseVectorStorage.cs
  19. 8
      src/Numerics/Providers/LinearAlgebra/ManagedLinearAlgebraProvider.Complex.cs
  20. 10
      src/Numerics/Providers/LinearAlgebra/ManagedLinearAlgebraProvider.Complex32.cs
  21. 10
      src/Numerics/RootFinding/Broyden.cs
  22. 2
      src/Numerics/Statistics/ArrayStatistics.cs
  23. 6
      src/Numerics/Statistics/MCMC/HybridMC.cs
  24. 2
      src/Numerics/Statistics/Statistics.cs
  25. 2
      src/Numerics/Statistics/StreamingStatistics.cs
  26. 8
      src/UnitTests/LinearAlgebraProviderTests/Complex/LinearAlgebraProviderTests.cs

2
src/Numerics/ArrayExtensions.cs

@ -71,7 +71,7 @@ namespace MathNet.Numerics
{ {
Array.Copy(source, 0, dest, 0, source.Length); Array.Copy(source, 0, dest, 0, source.Length);
} }
/// <summary> /// <summary>
/// Copies the values from on array to another. /// Copies the values from on array to another.
/// </summary> /// </summary>

26
src/Numerics/LinearAlgebra/Complex/DiagonalMatrix.cs

@ -4,7 +4,7 @@
// http://github.com/mathnet/mathnet-numerics // http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com // http://mathnetnumerics.codeplex.com
// //
// Copyright (c) 2009-2014 Math.NET // Copyright (c) 2009-2015 Math.NET
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation // obtaining a copy of this software and associated documentation
@ -353,8 +353,8 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
{ {
var thisDataCopy = new Complex[diagonalResult._data.Length]; var thisDataCopy = new Complex[diagonalResult._data.Length];
var otherDataCopy = new Complex[diagonalResult._data.Length]; var otherDataCopy = new Complex[diagonalResult._data.Length];
Array.Copy(_data, thisDataCopy, (diagonalResult._data.Length > _data.Length) ? _data.Length : diagonalResult._data.Length); Array.Copy(_data, 0, thisDataCopy, 0, (diagonalResult._data.Length > _data.Length) ? _data.Length : diagonalResult._data.Length);
Array.Copy(diagonalOther._data, otherDataCopy, (diagonalResult._data.Length > diagonalOther._data.Length) ? diagonalOther._data.Length : diagonalResult._data.Length); Array.Copy(diagonalOther._data, 0, otherDataCopy, 0, (diagonalResult._data.Length > diagonalOther._data.Length) ? diagonalOther._data.Length : diagonalResult._data.Length);
Control.LinearAlgebraProvider.PointWiseMultiplyArrays(thisDataCopy, otherDataCopy, diagonalResult._data); Control.LinearAlgebraProvider.PointWiseMultiplyArrays(thisDataCopy, otherDataCopy, diagonalResult._data);
return; return;
} }
@ -406,8 +406,8 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
{ {
var thisDataCopy = new Complex[diagonalResult._data.Length]; var thisDataCopy = new Complex[diagonalResult._data.Length];
var otherDataCopy = new Complex[diagonalResult._data.Length]; var otherDataCopy = new Complex[diagonalResult._data.Length];
Array.Copy(_data, thisDataCopy, (diagonalResult._data.Length > _data.Length) ? _data.Length : diagonalResult._data.Length); Array.Copy(_data, 0, thisDataCopy, 0, (diagonalResult._data.Length > _data.Length) ? _data.Length : diagonalResult._data.Length);
Array.Copy(diagonalOther._data, otherDataCopy, (diagonalResult._data.Length > diagonalOther._data.Length) ? diagonalOther._data.Length : diagonalResult._data.Length); Array.Copy(diagonalOther._data, 0, otherDataCopy, 0, (diagonalResult._data.Length > diagonalOther._data.Length) ? diagonalOther._data.Length : diagonalResult._data.Length);
Control.LinearAlgebraProvider.PointWiseMultiplyArrays(thisDataCopy, otherDataCopy, diagonalResult._data); Control.LinearAlgebraProvider.PointWiseMultiplyArrays(thisDataCopy, otherDataCopy, diagonalResult._data);
return; return;
} }
@ -450,8 +450,8 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
{ {
var thisDataCopy = new Complex[diagonalResult._data.Length]; var thisDataCopy = new Complex[diagonalResult._data.Length];
var otherDataCopy = new Complex[diagonalResult._data.Length]; var otherDataCopy = new Complex[diagonalResult._data.Length];
Array.Copy(_data, thisDataCopy, (diagonalResult._data.Length > _data.Length) ? _data.Length : diagonalResult._data.Length); Array.Copy(_data, 0, thisDataCopy, 0, (diagonalResult._data.Length > _data.Length) ? _data.Length : diagonalResult._data.Length);
Array.Copy(diagonalOther._data, otherDataCopy, (diagonalResult._data.Length > diagonalOther._data.Length) ? diagonalOther._data.Length : diagonalResult._data.Length); Array.Copy(diagonalOther._data, 0, otherDataCopy, 0, (diagonalResult._data.Length > diagonalOther._data.Length) ? diagonalOther._data.Length : diagonalResult._data.Length);
// TODO: merge/MulByConj // TODO: merge/MulByConj
Control.LinearAlgebraProvider.ConjugateArray(otherDataCopy, otherDataCopy); Control.LinearAlgebraProvider.ConjugateArray(otherDataCopy, otherDataCopy);
Control.LinearAlgebraProvider.PointWiseMultiplyArrays(thisDataCopy, otherDataCopy, diagonalResult._data); Control.LinearAlgebraProvider.PointWiseMultiplyArrays(thisDataCopy, otherDataCopy, diagonalResult._data);
@ -496,8 +496,8 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
{ {
var thisDataCopy = new Complex[diagonalResult._data.Length]; var thisDataCopy = new Complex[diagonalResult._data.Length];
var otherDataCopy = new Complex[diagonalResult._data.Length]; var otherDataCopy = new Complex[diagonalResult._data.Length];
Array.Copy(_data, thisDataCopy, (diagonalResult._data.Length > _data.Length) ? _data.Length : diagonalResult._data.Length); Array.Copy(_data, 0, thisDataCopy, 0, (diagonalResult._data.Length > _data.Length) ? _data.Length : diagonalResult._data.Length);
Array.Copy(diagonalOther._data, otherDataCopy, (diagonalResult._data.Length > diagonalOther._data.Length) ? diagonalOther._data.Length : diagonalResult._data.Length); Array.Copy(diagonalOther._data, 0, otherDataCopy, 0, (diagonalResult._data.Length > diagonalOther._data.Length) ? diagonalOther._data.Length : diagonalResult._data.Length);
Control.LinearAlgebraProvider.PointWiseMultiplyArrays(thisDataCopy, otherDataCopy, diagonalResult._data); Control.LinearAlgebraProvider.PointWiseMultiplyArrays(thisDataCopy, otherDataCopy, diagonalResult._data);
return; return;
} }
@ -549,8 +549,8 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
{ {
var thisDataCopy = new Complex[diagonalResult._data.Length]; var thisDataCopy = new Complex[diagonalResult._data.Length];
var otherDataCopy = new Complex[diagonalResult._data.Length]; var otherDataCopy = new Complex[diagonalResult._data.Length];
Array.Copy(_data, thisDataCopy, (diagonalResult._data.Length > _data.Length) ? _data.Length : diagonalResult._data.Length); Array.Copy(_data, 0, thisDataCopy, 0, (diagonalResult._data.Length > _data.Length) ? _data.Length : diagonalResult._data.Length);
Array.Copy(diagonalOther._data, otherDataCopy, (diagonalResult._data.Length > diagonalOther._data.Length) ? diagonalOther._data.Length : diagonalResult._data.Length); Array.Copy(diagonalOther._data, 0, otherDataCopy, 0, (diagonalResult._data.Length > diagonalOther._data.Length) ? diagonalOther._data.Length : diagonalResult._data.Length);
// TODO: merge/MulByConj // TODO: merge/MulByConj
Control.LinearAlgebraProvider.ConjugateArray(thisDataCopy, thisDataCopy); Control.LinearAlgebraProvider.ConjugateArray(thisDataCopy, thisDataCopy);
Control.LinearAlgebraProvider.PointWiseMultiplyArrays(thisDataCopy, otherDataCopy, diagonalResult._data); Control.LinearAlgebraProvider.PointWiseMultiplyArrays(thisDataCopy, otherDataCopy, diagonalResult._data);
@ -746,7 +746,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
throw new ArgumentException(Resources.ArgumentArraysSameLength, "source"); throw new ArgumentException(Resources.ArgumentArraysSameLength, "source");
} }
Array.Copy(source, _data, source.Length); Array.Copy(source, 0, _data, 0, source.Length);
} }
/// <summary> /// <summary>
@ -772,7 +772,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
throw new ArgumentException(Resources.ArgumentVectorsSameLength, "source"); throw new ArgumentException(Resources.ArgumentVectorsSameLength, "source");
} }
Array.Copy(denseSource.Values, _data, denseSource.Values.Length); Array.Copy(denseSource.Values, 0, _data, 0, denseSource.Values.Length);
} }
/// <summary>Calculates the induced L1 norm of this matrix.</summary> /// <summary>Calculates the induced L1 norm of this matrix.</summary>

6
src/Numerics/LinearAlgebra/Complex/Factorization/DenseCholesky.cs

@ -4,7 +4,7 @@
// http://github.com/mathnet/mathnet-numerics // http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com // http://mathnetnumerics.codeplex.com
// //
// Copyright (c) 2009-2013 Math.NET // Copyright (c) 2009-2015 Math.NET
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation // obtaining a copy of this software and associated documentation
@ -112,7 +112,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization
} }
// Copy the contents of input to result. // Copy the contents of input to result.
Array.Copy(dinput.Values, dresult.Values, dinput.Values.Length); Array.Copy(dinput.Values, 0, dresult.Values, 0, dinput.Values.Length);
// Cholesky solve by overwriting result. // Cholesky solve by overwriting result.
var dfactor = (DenseMatrix) Factor; var dfactor = (DenseMatrix) Factor;
@ -149,7 +149,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization
} }
// Copy the contents of input to result. // Copy the contents of input to result.
Array.Copy(dinput.Values, dresult.Values, dinput.Values.Length); Array.Copy(dinput.Values, 0, dresult.Values, 0, dinput.Values.Length);
// Cholesky solve by overwriting result. // Cholesky solve by overwriting result.
var dfactor = (DenseMatrix) Factor; var dfactor = (DenseMatrix) Factor;

6
src/Numerics/LinearAlgebra/Complex/Factorization/DenseLU.cs

@ -4,7 +4,7 @@
// http://github.com/mathnet/mathnet-numerics // http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com // http://mathnetnumerics.codeplex.com
// //
// Copyright (c) 2009-2013 Math.NET // Copyright (c) 2009-2015 Math.NET
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation // obtaining a copy of this software and associated documentation
@ -131,7 +131,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization
} }
// Copy the contents of input to result. // Copy the contents of input to result.
Array.Copy(dinput.Values, dresult.Values, dinput.Values.Length); Array.Copy(dinput.Values, 0, dresult.Values, 0, dinput.Values.Length);
// LU solve by overwriting result. // LU solve by overwriting result.
var dfactors = (DenseMatrix) Factors; var dfactors = (DenseMatrix) Factors;
@ -180,7 +180,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization
} }
// Copy the contents of input to result. // Copy the contents of input to result.
Array.Copy(dinput.Values, dresult.Values, dinput.Values.Length); Array.Copy(dinput.Values, 0, dresult.Values, 0, dinput.Values.Length);
// LU solve by overwriting result. // LU solve by overwriting result.
var dfactors = (DenseMatrix) Factors; var dfactors = (DenseMatrix) Factors;

8
src/Numerics/LinearAlgebra/Complex/SparseVector.cs

@ -4,7 +4,7 @@
// http://github.com/mathnet/mathnet-numerics // http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com // http://mathnetnumerics.codeplex.com
// //
// Copyright (c) 2009-2013 Math.NET // Copyright (c) 2009-2015 Math.NET
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation // obtaining a copy of this software and associated documentation
@ -397,7 +397,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
sparseResult._storage.Indices = new int[_storage.ValueCount]; sparseResult._storage.Indices = new int[_storage.ValueCount];
Buffer.BlockCopy(_storage.Indices, 0, sparseResult._storage.Indices, 0, _storage.ValueCount*Constants.SizeOfInt); Buffer.BlockCopy(_storage.Indices, 0, sparseResult._storage.Indices, 0, _storage.ValueCount*Constants.SizeOfInt);
sparseResult._storage.Values = new Complex[_storage.ValueCount]; sparseResult._storage.Values = new Complex[_storage.ValueCount];
Array.Copy(_storage.Values, sparseResult._storage.Values, _storage.ValueCount); Array.Copy(_storage.Values, 0, sparseResult._storage.Values, 0, _storage.ValueCount);
} }
Control.LinearAlgebraProvider.ScaleArray(-Complex.One, sparseResult._storage.Values, sparseResult._storage.Values); Control.LinearAlgebraProvider.ScaleArray(-Complex.One, sparseResult._storage.Values, sparseResult._storage.Values);
@ -418,7 +418,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
sparseResult._storage.Indices = new int[_storage.ValueCount]; sparseResult._storage.Indices = new int[_storage.ValueCount];
Buffer.BlockCopy(_storage.Indices, 0, sparseResult._storage.Indices, 0, _storage.ValueCount*Constants.SizeOfInt); Buffer.BlockCopy(_storage.Indices, 0, sparseResult._storage.Indices, 0, _storage.ValueCount*Constants.SizeOfInt);
sparseResult._storage.Values = new Complex[_storage.ValueCount]; sparseResult._storage.Values = new Complex[_storage.ValueCount];
Array.Copy(_storage.Values, sparseResult._storage.Values, _storage.ValueCount); Array.Copy(_storage.Values, 0, sparseResult._storage.Values, 0, _storage.ValueCount);
} }
Control.LinearAlgebraProvider.ConjugateArray(sparseResult._storage.Values, sparseResult._storage.Values); Control.LinearAlgebraProvider.ConjugateArray(sparseResult._storage.Values, sparseResult._storage.Values);
@ -460,7 +460,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
sparseResult._storage.Indices = new int[_storage.ValueCount]; sparseResult._storage.Indices = new int[_storage.ValueCount];
Buffer.BlockCopy(_storage.Indices, 0, sparseResult._storage.Indices, 0, _storage.ValueCount * Constants.SizeOfInt); Buffer.BlockCopy(_storage.Indices, 0, sparseResult._storage.Indices, 0, _storage.ValueCount * Constants.SizeOfInt);
sparseResult._storage.Values = new Complex[_storage.ValueCount]; sparseResult._storage.Values = new Complex[_storage.ValueCount];
Array.Copy(_storage.Values, sparseResult._storage.Values, _storage.ValueCount); Array.Copy(_storage.Values, 0, sparseResult._storage.Values, 0, _storage.ValueCount);
} }
Control.LinearAlgebraProvider.ScaleArray(scalar, sparseResult._storage.Values, sparseResult._storage.Values); Control.LinearAlgebraProvider.ScaleArray(scalar, sparseResult._storage.Values, sparseResult._storage.Values);

26
src/Numerics/LinearAlgebra/Complex32/DiagonalMatrix.cs

@ -4,7 +4,7 @@
// http://github.com/mathnet/mathnet-numerics // http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com // http://mathnetnumerics.codeplex.com
// //
// Copyright (c) 2009-2014 Math.NET // Copyright (c) 2009-2015 Math.NET
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation // obtaining a copy of this software and associated documentation
@ -347,8 +347,8 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
{ {
var thisDataCopy = new Complex32[diagonalResult._data.Length]; var thisDataCopy = new Complex32[diagonalResult._data.Length];
var otherDataCopy = new Complex32[diagonalResult._data.Length]; var otherDataCopy = new Complex32[diagonalResult._data.Length];
Array.Copy(_data, thisDataCopy, (diagonalResult._data.Length > _data.Length) ? _data.Length : diagonalResult._data.Length); Array.Copy(_data, 0, thisDataCopy, 0, (diagonalResult._data.Length > _data.Length) ? _data.Length : diagonalResult._data.Length);
Array.Copy(diagonalOther._data, otherDataCopy, (diagonalResult._data.Length > diagonalOther._data.Length) ? diagonalOther._data.Length : diagonalResult._data.Length); Array.Copy(diagonalOther._data, 0, otherDataCopy, 0, (diagonalResult._data.Length > diagonalOther._data.Length) ? diagonalOther._data.Length : diagonalResult._data.Length);
Control.LinearAlgebraProvider.PointWiseMultiplyArrays(thisDataCopy, otherDataCopy, diagonalResult._data); Control.LinearAlgebraProvider.PointWiseMultiplyArrays(thisDataCopy, otherDataCopy, diagonalResult._data);
return; return;
} }
@ -400,8 +400,8 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
{ {
var thisDataCopy = new Complex32[diagonalResult._data.Length]; var thisDataCopy = new Complex32[diagonalResult._data.Length];
var otherDataCopy = new Complex32[diagonalResult._data.Length]; var otherDataCopy = new Complex32[diagonalResult._data.Length];
Array.Copy(_data, thisDataCopy, (diagonalResult._data.Length > _data.Length) ? _data.Length : diagonalResult._data.Length); Array.Copy(_data, 0, thisDataCopy, 0, (diagonalResult._data.Length > _data.Length) ? _data.Length : diagonalResult._data.Length);
Array.Copy(diagonalOther._data, otherDataCopy, (diagonalResult._data.Length > diagonalOther._data.Length) ? diagonalOther._data.Length : diagonalResult._data.Length); Array.Copy(diagonalOther._data, 0, otherDataCopy, 0, (diagonalResult._data.Length > diagonalOther._data.Length) ? diagonalOther._data.Length : diagonalResult._data.Length);
Control.LinearAlgebraProvider.PointWiseMultiplyArrays(thisDataCopy, otherDataCopy, diagonalResult._data); Control.LinearAlgebraProvider.PointWiseMultiplyArrays(thisDataCopy, otherDataCopy, diagonalResult._data);
return; return;
} }
@ -444,8 +444,8 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
{ {
var thisDataCopy = new Complex32[diagonalResult._data.Length]; var thisDataCopy = new Complex32[diagonalResult._data.Length];
var otherDataCopy = new Complex32[diagonalResult._data.Length]; var otherDataCopy = new Complex32[diagonalResult._data.Length];
Array.Copy(_data, thisDataCopy, (diagonalResult._data.Length > _data.Length) ? _data.Length : diagonalResult._data.Length); Array.Copy(_data, 0, thisDataCopy, 0, (diagonalResult._data.Length > _data.Length) ? _data.Length : diagonalResult._data.Length);
Array.Copy(diagonalOther._data, otherDataCopy, (diagonalResult._data.Length > diagonalOther._data.Length) ? diagonalOther._data.Length : diagonalResult._data.Length); Array.Copy(diagonalOther._data, 0, otherDataCopy, 0, (diagonalResult._data.Length > diagonalOther._data.Length) ? diagonalOther._data.Length : diagonalResult._data.Length);
// TODO: merge/MulByConj // TODO: merge/MulByConj
Control.LinearAlgebraProvider.ConjugateArray(otherDataCopy, otherDataCopy); Control.LinearAlgebraProvider.ConjugateArray(otherDataCopy, otherDataCopy);
Control.LinearAlgebraProvider.PointWiseMultiplyArrays(thisDataCopy, otherDataCopy, diagonalResult._data); Control.LinearAlgebraProvider.PointWiseMultiplyArrays(thisDataCopy, otherDataCopy, diagonalResult._data);
@ -490,8 +490,8 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
{ {
var thisDataCopy = new Complex32[diagonalResult._data.Length]; var thisDataCopy = new Complex32[diagonalResult._data.Length];
var otherDataCopy = new Complex32[diagonalResult._data.Length]; var otherDataCopy = new Complex32[diagonalResult._data.Length];
Array.Copy(_data, thisDataCopy, (diagonalResult._data.Length > _data.Length) ? _data.Length : diagonalResult._data.Length); Array.Copy(_data, 0, thisDataCopy, 0, (diagonalResult._data.Length > _data.Length) ? _data.Length : diagonalResult._data.Length);
Array.Copy(diagonalOther._data, otherDataCopy, (diagonalResult._data.Length > diagonalOther._data.Length) ? diagonalOther._data.Length : diagonalResult._data.Length); Array.Copy(diagonalOther._data, 0, otherDataCopy, 0, (diagonalResult._data.Length > diagonalOther._data.Length) ? diagonalOther._data.Length : diagonalResult._data.Length);
Control.LinearAlgebraProvider.PointWiseMultiplyArrays(thisDataCopy, otherDataCopy, diagonalResult._data); Control.LinearAlgebraProvider.PointWiseMultiplyArrays(thisDataCopy, otherDataCopy, diagonalResult._data);
return; return;
} }
@ -543,8 +543,8 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
{ {
var thisDataCopy = new Complex32[diagonalResult._data.Length]; var thisDataCopy = new Complex32[diagonalResult._data.Length];
var otherDataCopy = new Complex32[diagonalResult._data.Length]; var otherDataCopy = new Complex32[diagonalResult._data.Length];
Array.Copy(_data, thisDataCopy, (diagonalResult._data.Length > _data.Length) ? _data.Length : diagonalResult._data.Length); Array.Copy(_data, 0, thisDataCopy, 0, (diagonalResult._data.Length > _data.Length) ? _data.Length : diagonalResult._data.Length);
Array.Copy(diagonalOther._data, otherDataCopy, (diagonalResult._data.Length > diagonalOther._data.Length) ? diagonalOther._data.Length : diagonalResult._data.Length); Array.Copy(diagonalOther._data, 0, otherDataCopy, 0, (diagonalResult._data.Length > diagonalOther._data.Length) ? diagonalOther._data.Length : diagonalResult._data.Length);
// TODO: merge/MulByConj // TODO: merge/MulByConj
Control.LinearAlgebraProvider.ConjugateArray(thisDataCopy, thisDataCopy); Control.LinearAlgebraProvider.ConjugateArray(thisDataCopy, thisDataCopy);
Control.LinearAlgebraProvider.PointWiseMultiplyArrays(thisDataCopy, otherDataCopy, diagonalResult._data); Control.LinearAlgebraProvider.PointWiseMultiplyArrays(thisDataCopy, otherDataCopy, diagonalResult._data);
@ -740,7 +740,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
throw new ArgumentException(Resources.ArgumentArraysSameLength, "source"); throw new ArgumentException(Resources.ArgumentArraysSameLength, "source");
} }
Array.Copy(source, _data, source.Length); Array.Copy(source, 0, _data, 0, source.Length);
} }
/// <summary> /// <summary>
@ -766,7 +766,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
throw new ArgumentException(Resources.ArgumentVectorsSameLength, "source"); throw new ArgumentException(Resources.ArgumentVectorsSameLength, "source");
} }
Array.Copy(denseSource.Values, _data, denseSource.Values.Length); Array.Copy(denseSource.Values, 0, _data, 0, denseSource.Values.Length);
} }
/// <summary>Calculates the induced L1 norm of this matrix.</summary> /// <summary>Calculates the induced L1 norm of this matrix.</summary>

6
src/Numerics/LinearAlgebra/Complex32/Factorization/DenseCholesky.cs

@ -4,7 +4,7 @@
// http://github.com/mathnet/mathnet-numerics // http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com // http://mathnetnumerics.codeplex.com
// //
// Copyright (c) 2009-2013 Math.NET // Copyright (c) 2009-2015 Math.NET
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation // obtaining a copy of this software and associated documentation
@ -107,7 +107,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization
} }
// Copy the contents of input to result. // Copy the contents of input to result.
Array.Copy(dinput.Values, dresult.Values, dinput.Values.Length); Array.Copy(dinput.Values, 0, dresult.Values, 0, dinput.Values.Length);
// Cholesky solve by overwriting result. // Cholesky solve by overwriting result.
var dfactor = (DenseMatrix) Factor; var dfactor = (DenseMatrix) Factor;
@ -144,7 +144,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization
} }
// Copy the contents of input to result. // Copy the contents of input to result.
Array.Copy(dinput.Values, dresult.Values, dinput.Values.Length); Array.Copy(dinput.Values, 0, dresult.Values, 0, dinput.Values.Length);
// Cholesky solve by overwriting result. // Cholesky solve by overwriting result.
var dfactor = (DenseMatrix) Factor; var dfactor = (DenseMatrix) Factor;

6
src/Numerics/LinearAlgebra/Complex32/Factorization/DenseLU.cs

@ -4,7 +4,7 @@
// http://github.com/mathnet/mathnet-numerics // http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com // http://mathnetnumerics.codeplex.com
// //
// Copyright (c) 2009-2013 Math.NET // Copyright (c) 2009-2015 Math.NET
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation // obtaining a copy of this software and associated documentation
@ -126,7 +126,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization
} }
// Copy the contents of input to result. // Copy the contents of input to result.
Array.Copy(dinput.Values, dresult.Values, dinput.Values.Length); Array.Copy(dinput.Values, 0, dresult.Values, 0, dinput.Values.Length);
// LU solve by overwriting result. // LU solve by overwriting result.
var dfactors = (DenseMatrix) Factors; var dfactors = (DenseMatrix) Factors;
@ -175,7 +175,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization
} }
// Copy the contents of input to result. // Copy the contents of input to result.
Array.Copy(dinput.Values, dresult.Values, dinput.Values.Length); Array.Copy(dinput.Values, 0, dresult.Values, 0, dinput.Values.Length);
// LU solve by overwriting result. // LU solve by overwriting result.
var dfactors = (DenseMatrix) Factors; var dfactors = (DenseMatrix) Factors;

8
src/Numerics/LinearAlgebra/Complex32/SparseVector.cs

@ -4,7 +4,7 @@
// http://github.com/mathnet/mathnet-numerics // http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com // http://mathnetnumerics.codeplex.com
// //
// Copyright (c) 2009-2013 Math.NET // Copyright (c) 2009-2015 Math.NET
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation // obtaining a copy of this software and associated documentation
@ -392,7 +392,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
sparseResult._storage.Indices = new int[_storage.ValueCount]; sparseResult._storage.Indices = new int[_storage.ValueCount];
Buffer.BlockCopy(_storage.Indices, 0, sparseResult._storage.Indices, 0, _storage.ValueCount*Constants.SizeOfInt); Buffer.BlockCopy(_storage.Indices, 0, sparseResult._storage.Indices, 0, _storage.ValueCount*Constants.SizeOfInt);
sparseResult._storage.Values = new Complex32[_storage.ValueCount]; sparseResult._storage.Values = new Complex32[_storage.ValueCount];
Array.Copy(_storage.Values, sparseResult._storage.Values, _storage.ValueCount); Array.Copy(_storage.Values, 0, sparseResult._storage.Values, 0, _storage.ValueCount);
} }
Control.LinearAlgebraProvider.ScaleArray(-Complex32.One, sparseResult._storage.Values, sparseResult._storage.Values); Control.LinearAlgebraProvider.ScaleArray(-Complex32.One, sparseResult._storage.Values, sparseResult._storage.Values);
@ -413,7 +413,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
sparseResult._storage.Indices = new int[_storage.ValueCount]; sparseResult._storage.Indices = new int[_storage.ValueCount];
Buffer.BlockCopy(_storage.Indices, 0, sparseResult._storage.Indices, 0, _storage.ValueCount*Constants.SizeOfInt); Buffer.BlockCopy(_storage.Indices, 0, sparseResult._storage.Indices, 0, _storage.ValueCount*Constants.SizeOfInt);
sparseResult._storage.Values = new Complex32[_storage.ValueCount]; sparseResult._storage.Values = new Complex32[_storage.ValueCount];
Array.Copy(_storage.Values, sparseResult._storage.Values, _storage.ValueCount); Array.Copy(_storage.Values, 0, sparseResult._storage.Values, 0, _storage.ValueCount);
} }
Control.LinearAlgebraProvider.ConjugateArray(sparseResult._storage.Values, sparseResult._storage.Values); Control.LinearAlgebraProvider.ConjugateArray(sparseResult._storage.Values, sparseResult._storage.Values);
@ -455,7 +455,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
sparseResult._storage.Indices = new int[_storage.ValueCount]; sparseResult._storage.Indices = new int[_storage.ValueCount];
Buffer.BlockCopy(_storage.Indices, 0, sparseResult._storage.Indices, 0, _storage.ValueCount * Constants.SizeOfInt); Buffer.BlockCopy(_storage.Indices, 0, sparseResult._storage.Indices, 0, _storage.ValueCount * Constants.SizeOfInt);
sparseResult._storage.Values = new Complex32[_storage.ValueCount]; sparseResult._storage.Values = new Complex32[_storage.ValueCount];
Array.Copy(_storage.Values, sparseResult._storage.Values, _storage.ValueCount); Array.Copy(_storage.Values, 0, sparseResult._storage.Values, 0, _storage.ValueCount);
} }
Control.LinearAlgebraProvider.ScaleArray(scalar, sparseResult._storage.Values, sparseResult._storage.Values); Control.LinearAlgebraProvider.ScaleArray(scalar, sparseResult._storage.Values, sparseResult._storage.Values);

14
src/Numerics/LinearAlgebra/Double/DiagonalMatrix.cs

@ -4,7 +4,7 @@
// http://github.com/mathnet/mathnet-numerics // http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com // http://mathnetnumerics.codeplex.com
// //
// Copyright (c) 2009-2014 Math.NET // Copyright (c) 2009-2015 Math.NET
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation // obtaining a copy of this software and associated documentation
@ -326,8 +326,8 @@ namespace MathNet.Numerics.LinearAlgebra.Double
{ {
var thisDataCopy = new double[diagonalResult._data.Length]; var thisDataCopy = new double[diagonalResult._data.Length];
var otherDataCopy = new double[diagonalResult._data.Length]; var otherDataCopy = new double[diagonalResult._data.Length];
Array.Copy(_data, thisDataCopy, (diagonalResult._data.Length > _data.Length) ? _data.Length : diagonalResult._data.Length); Array.Copy(_data, 0, thisDataCopy, 0, (diagonalResult._data.Length > _data.Length) ? _data.Length : diagonalResult._data.Length);
Array.Copy(diagonalOther._data, otherDataCopy, (diagonalResult._data.Length > diagonalOther._data.Length) ? diagonalOther._data.Length : diagonalResult._data.Length); Array.Copy(diagonalOther._data, 0, otherDataCopy, 0, (diagonalResult._data.Length > diagonalOther._data.Length) ? diagonalOther._data.Length : diagonalResult._data.Length);
Control.LinearAlgebraProvider.PointWiseMultiplyArrays(thisDataCopy, otherDataCopy, diagonalResult._data); Control.LinearAlgebraProvider.PointWiseMultiplyArrays(thisDataCopy, otherDataCopy, diagonalResult._data);
return; return;
} }
@ -379,8 +379,8 @@ namespace MathNet.Numerics.LinearAlgebra.Double
{ {
var thisDataCopy = new double[diagonalResult._data.Length]; var thisDataCopy = new double[diagonalResult._data.Length];
var otherDataCopy = new double[diagonalResult._data.Length]; var otherDataCopy = new double[diagonalResult._data.Length];
Array.Copy(_data, thisDataCopy, (diagonalResult._data.Length > _data.Length) ? _data.Length : diagonalResult._data.Length); Array.Copy(_data, 0, thisDataCopy, 0, (diagonalResult._data.Length > _data.Length) ? _data.Length : diagonalResult._data.Length);
Array.Copy(diagonalOther._data, otherDataCopy, (diagonalResult._data.Length > diagonalOther._data.Length) ? diagonalOther._data.Length : diagonalResult._data.Length); Array.Copy(diagonalOther._data, 0, otherDataCopy, 0, (diagonalResult._data.Length > diagonalOther._data.Length) ? diagonalOther._data.Length : diagonalResult._data.Length);
Control.LinearAlgebraProvider.PointWiseMultiplyArrays(thisDataCopy, otherDataCopy, diagonalResult._data); Control.LinearAlgebraProvider.PointWiseMultiplyArrays(thisDataCopy, otherDataCopy, diagonalResult._data);
return; return;
} }
@ -423,8 +423,8 @@ namespace MathNet.Numerics.LinearAlgebra.Double
{ {
var thisDataCopy = new double[diagonalResult._data.Length]; var thisDataCopy = new double[diagonalResult._data.Length];
var otherDataCopy = new double[diagonalResult._data.Length]; var otherDataCopy = new double[diagonalResult._data.Length];
Array.Copy(_data, thisDataCopy, (diagonalResult._data.Length > _data.Length) ? _data.Length : diagonalResult._data.Length); Array.Copy(_data, 0, thisDataCopy, 0, (diagonalResult._data.Length > _data.Length) ? _data.Length : diagonalResult._data.Length);
Array.Copy(diagonalOther._data, otherDataCopy, (diagonalResult._data.Length > diagonalOther._data.Length) ? diagonalOther._data.Length : diagonalResult._data.Length); Array.Copy(diagonalOther._data, 0, otherDataCopy, 0, (diagonalResult._data.Length > diagonalOther._data.Length) ? diagonalOther._data.Length : diagonalResult._data.Length);
Control.LinearAlgebraProvider.PointWiseMultiplyArrays(thisDataCopy, otherDataCopy, diagonalResult._data); Control.LinearAlgebraProvider.PointWiseMultiplyArrays(thisDataCopy, otherDataCopy, diagonalResult._data);
return; return;
} }

6
src/Numerics/LinearAlgebra/Double/SparseVector.cs

@ -4,7 +4,7 @@
// http://github.com/mathnet/mathnet-numerics // http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com // http://mathnetnumerics.codeplex.com
// //
// Copyright (c) 2009-2013 Math.NET // Copyright (c) 2009-2015 Math.NET
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation // obtaining a copy of this software and associated documentation
@ -392,7 +392,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
sparseResult._storage.Indices = new int[_storage.ValueCount]; sparseResult._storage.Indices = new int[_storage.ValueCount];
Buffer.BlockCopy(_storage.Indices, 0, sparseResult._storage.Indices, 0, _storage.ValueCount * Constants.SizeOfInt); Buffer.BlockCopy(_storage.Indices, 0, sparseResult._storage.Indices, 0, _storage.ValueCount * Constants.SizeOfInt);
sparseResult._storage.Values = new double[_storage.ValueCount]; sparseResult._storage.Values = new double[_storage.ValueCount];
Array.Copy(_storage.Values, sparseResult._storage.Values, _storage.ValueCount); Array.Copy(_storage.Values, 0, sparseResult._storage.Values, 0, _storage.ValueCount);
} }
Control.LinearAlgebraProvider.ScaleArray(-1.0d, sparseResult._storage.Values, sparseResult._storage.Values); Control.LinearAlgebraProvider.ScaleArray(-1.0d, sparseResult._storage.Values, sparseResult._storage.Values);
@ -426,7 +426,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
sparseResult._storage.Indices = new int[_storage.ValueCount]; sparseResult._storage.Indices = new int[_storage.ValueCount];
Buffer.BlockCopy(_storage.Indices, 0, sparseResult._storage.Indices, 0, _storage.ValueCount * Constants.SizeOfInt); Buffer.BlockCopy(_storage.Indices, 0, sparseResult._storage.Indices, 0, _storage.ValueCount * Constants.SizeOfInt);
sparseResult._storage.Values = new double[_storage.ValueCount]; sparseResult._storage.Values = new double[_storage.ValueCount];
Array.Copy(_storage.Values, sparseResult._storage.Values, _storage.ValueCount); Array.Copy(_storage.Values, 0, sparseResult._storage.Values, 0, _storage.ValueCount);
} }
Control.LinearAlgebraProvider.ScaleArray(scalar, sparseResult._storage.Values, sparseResult._storage.Values); Control.LinearAlgebraProvider.ScaleArray(scalar, sparseResult._storage.Values, sparseResult._storage.Values);

14
src/Numerics/LinearAlgebra/Single/DiagonalMatrix.cs

@ -4,7 +4,7 @@
// http://github.com/mathnet/mathnet-numerics // http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com // http://mathnetnumerics.codeplex.com
// //
// Copyright (c) 2009-2014 Math.NET // Copyright (c) 2009-2015 Math.NET
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation // obtaining a copy of this software and associated documentation
@ -326,8 +326,8 @@ namespace MathNet.Numerics.LinearAlgebra.Single
{ {
var thisDataCopy = new float[diagonalResult._data.Length]; var thisDataCopy = new float[diagonalResult._data.Length];
var otherDataCopy = new float[diagonalResult._data.Length]; var otherDataCopy = new float[diagonalResult._data.Length];
Array.Copy(_data, thisDataCopy, (diagonalResult._data.Length > _data.Length) ? _data.Length : diagonalResult._data.Length); Array.Copy(_data, 0, thisDataCopy, 0, (diagonalResult._data.Length > _data.Length) ? _data.Length : diagonalResult._data.Length);
Array.Copy(diagonalOther._data, otherDataCopy, (diagonalResult._data.Length > diagonalOther._data.Length) ? diagonalOther._data.Length : diagonalResult._data.Length); Array.Copy(diagonalOther._data, 0, otherDataCopy, 0, (diagonalResult._data.Length > diagonalOther._data.Length) ? diagonalOther._data.Length : diagonalResult._data.Length);
Control.LinearAlgebraProvider.PointWiseMultiplyArrays(thisDataCopy, otherDataCopy, diagonalResult._data); Control.LinearAlgebraProvider.PointWiseMultiplyArrays(thisDataCopy, otherDataCopy, diagonalResult._data);
return; return;
} }
@ -379,8 +379,8 @@ namespace MathNet.Numerics.LinearAlgebra.Single
{ {
var thisDataCopy = new float[diagonalResult._data.Length]; var thisDataCopy = new float[diagonalResult._data.Length];
var otherDataCopy = new float[diagonalResult._data.Length]; var otherDataCopy = new float[diagonalResult._data.Length];
Array.Copy(_data, thisDataCopy, (diagonalResult._data.Length > _data.Length) ? _data.Length : diagonalResult._data.Length); Array.Copy(_data, 0, thisDataCopy, 0, (diagonalResult._data.Length > _data.Length) ? _data.Length : diagonalResult._data.Length);
Array.Copy(diagonalOther._data, otherDataCopy, (diagonalResult._data.Length > diagonalOther._data.Length) ? diagonalOther._data.Length : diagonalResult._data.Length); Array.Copy(diagonalOther._data, 0, otherDataCopy, 0, (diagonalResult._data.Length > diagonalOther._data.Length) ? diagonalOther._data.Length : diagonalResult._data.Length);
Control.LinearAlgebraProvider.PointWiseMultiplyArrays(thisDataCopy, otherDataCopy, diagonalResult._data); Control.LinearAlgebraProvider.PointWiseMultiplyArrays(thisDataCopy, otherDataCopy, diagonalResult._data);
return; return;
} }
@ -423,8 +423,8 @@ namespace MathNet.Numerics.LinearAlgebra.Single
{ {
var thisDataCopy = new float[diagonalResult._data.Length]; var thisDataCopy = new float[diagonalResult._data.Length];
var otherDataCopy = new float[diagonalResult._data.Length]; var otherDataCopy = new float[diagonalResult._data.Length];
Array.Copy(_data, thisDataCopy, (diagonalResult._data.Length > _data.Length) ? _data.Length : diagonalResult._data.Length); Array.Copy(_data, 0, thisDataCopy, 0, (diagonalResult._data.Length > _data.Length) ? _data.Length : diagonalResult._data.Length);
Array.Copy(diagonalOther._data, otherDataCopy, (diagonalResult._data.Length > diagonalOther._data.Length) ? diagonalOther._data.Length : diagonalResult._data.Length); Array.Copy(diagonalOther._data, 0, otherDataCopy, 0, (diagonalResult._data.Length > diagonalOther._data.Length) ? diagonalOther._data.Length : diagonalResult._data.Length);
Control.LinearAlgebraProvider.PointWiseMultiplyArrays(thisDataCopy, otherDataCopy, diagonalResult._data); Control.LinearAlgebraProvider.PointWiseMultiplyArrays(thisDataCopy, otherDataCopy, diagonalResult._data);
return; return;
} }

6
src/Numerics/LinearAlgebra/Single/SparseVector.cs

@ -4,7 +4,7 @@
// http://github.com/mathnet/mathnet-numerics // http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com // http://mathnetnumerics.codeplex.com
// //
// Copyright (c) 2009-2013 Math.NET // Copyright (c) 2009-2015 Math.NET
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation // obtaining a copy of this software and associated documentation
@ -393,7 +393,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
sparseResult._storage.Indices = new int[_storage.ValueCount]; sparseResult._storage.Indices = new int[_storage.ValueCount];
Buffer.BlockCopy(_storage.Indices, 0, sparseResult._storage.Indices, 0, _storage.ValueCount * Constants.SizeOfInt); Buffer.BlockCopy(_storage.Indices, 0, sparseResult._storage.Indices, 0, _storage.ValueCount * Constants.SizeOfInt);
sparseResult._storage.Values = new float[_storage.ValueCount]; sparseResult._storage.Values = new float[_storage.ValueCount];
Array.Copy(_storage.Values, sparseResult._storage.Values, _storage.ValueCount); Array.Copy(_storage.Values, 0, sparseResult._storage.Values, 0, _storage.ValueCount);
} }
Control.LinearAlgebraProvider.ScaleArray(-1.0f, sparseResult._storage.Values, sparseResult._storage.Values); Control.LinearAlgebraProvider.ScaleArray(-1.0f, sparseResult._storage.Values, sparseResult._storage.Values);
@ -427,7 +427,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
sparseResult._storage.Indices = new int[_storage.ValueCount]; sparseResult._storage.Indices = new int[_storage.ValueCount];
Buffer.BlockCopy(_storage.Indices, 0, sparseResult._storage.Indices, 0, _storage.ValueCount * Constants.SizeOfInt); Buffer.BlockCopy(_storage.Indices, 0, sparseResult._storage.Indices, 0, _storage.ValueCount * Constants.SizeOfInt);
sparseResult._storage.Values = new float[_storage.ValueCount]; sparseResult._storage.Values = new float[_storage.ValueCount];
Array.Copy(_storage.Values, sparseResult._storage.Values, _storage.ValueCount); Array.Copy(_storage.Values, 0, sparseResult._storage.Values, 0, _storage.ValueCount);
} }
Control.LinearAlgebraProvider.ScaleArray(scalar, sparseResult._storage.Values, sparseResult._storage.Values); Control.LinearAlgebraProvider.ScaleArray(scalar, sparseResult._storage.Values, sparseResult._storage.Values);

4
src/Numerics/LinearAlgebra/Storage/DenseColumnMajorMatrixStorage.cs

@ -332,7 +332,7 @@ namespace MathNet.Numerics.LinearAlgebra.Storage
if (arrayData != null) if (arrayData != null)
{ {
var copy = new T[arrayData.Length]; var copy = new T[arrayData.Length];
Array.Copy(arrayData, copy, arrayData.Length); Array.Copy(arrayData, 0, copy, 0, arrayData.Length);
return new DenseColumnMajorMatrixStorage<T>(rows, columns, copy); return new DenseColumnMajorMatrixStorage<T>(rows, columns, copy);
} }
@ -588,7 +588,7 @@ namespace MathNet.Numerics.LinearAlgebra.Storage
public override T[] ToColumnMajorArray() public override T[] ToColumnMajorArray()
{ {
var ret = new T[Data.Length]; var ret = new T[Data.Length];
Array.Copy(Data, ret, Data.Length); Array.Copy(Data, 0, ret, 0, Data.Length);
return ret; return ret;
} }

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

@ -158,7 +158,7 @@ namespace MathNet.Numerics.LinearAlgebra.Storage
if (arrayData != null) if (arrayData != null)
{ {
var copy = new T[arrayData.Length]; var copy = new T[arrayData.Length];
Array.Copy(arrayData, copy, arrayData.Length); Array.Copy(arrayData, 0, copy, 0, arrayData.Length);
return new DenseVectorStorage<T>(copy.Length, copy); return new DenseVectorStorage<T>(copy.Length, copy);
} }

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

@ -228,7 +228,7 @@ namespace MathNet.Numerics.LinearAlgebra.Storage
if (arrayData != null) if (arrayData != null)
{ {
var copy = new T[arrayData.Length]; var copy = new T[arrayData.Length];
Array.Copy(arrayData, copy, arrayData.Length); Array.Copy(arrayData, 0, copy, 0, arrayData.Length);
return new DiagonalMatrixStorage<T>(rows, columns, copy); return new DiagonalMatrixStorage<T>(rows, columns, copy);
} }

4
src/Numerics/LinearAlgebra/Storage/SparseCompressedRowMatrixStorage.cs

@ -880,7 +880,7 @@ namespace MathNet.Numerics.LinearAlgebra.Storage
if (ValueCount != 0) if (ValueCount != 0)
{ {
Array.Copy(Values, target.Values, ValueCount); Array.Copy(Values, 0, target.Values, 0, ValueCount);
Buffer.BlockCopy(ColumnIndices, 0, target.ColumnIndices, 0, ValueCount*Constants.SizeOfInt); Buffer.BlockCopy(ColumnIndices, 0, target.ColumnIndices, 0, ValueCount*Constants.SizeOfInt);
Buffer.BlockCopy(RowPointers, 0, target.RowPointers, 0, (RowCount + 1)*Constants.SizeOfInt); Buffer.BlockCopy(RowPointers, 0, target.RowPointers, 0, (RowCount + 1)*Constants.SizeOfInt);
} }
@ -2037,7 +2037,7 @@ namespace MathNet.Numerics.LinearAlgebra.Storage
{ {
if (!ReferenceEquals(state, target)) if (!ReferenceEquals(state, target))
{ {
Array.Copy(state, target, state.Length); Array.Copy(state, 0, target, 0, state.Length);
} }
if (zeros == Zeros.AllowSkip) if (zeros == Zeros.AllowSkip)
{ {

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

@ -463,7 +463,7 @@ namespace MathNet.Numerics.LinearAlgebra.Storage
if (ValueCount != 0) if (ValueCount != 0)
{ {
Array.Copy(Values, target.Values, ValueCount); Array.Copy(Values, 0, target.Values, 0, ValueCount);
Buffer.BlockCopy(Indices, 0, target.Indices, 0, ValueCount * Constants.SizeOfInt); Buffer.BlockCopy(Indices, 0, target.Indices, 0, ValueCount * Constants.SizeOfInt);
} }
} }

8
src/Numerics/Providers/LinearAlgebra/ManagedLinearAlgebraProvider.Complex.cs

@ -1794,7 +1794,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra
var sol = new Complex[b.Length]; var sol = new Complex[b.Length];
// Copy B matrix to "sol", so B data will not be changed // Copy B matrix to "sol", so B data will not be changed
Array.Copy(b, sol, b.Length); Array.Copy(b, 0, sol, 0, b.Length);
// Compute Y = transpose(Q)*B // Compute Y = transpose(Q)*B
var column = new Complex[rowsA]; var column = new Complex[rowsA];
@ -1896,7 +1896,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra
} }
var work = new Complex[rowsA]; var work = new Complex[rowsA];
const int maxiter = 1000; const int maxiter = 1000;
var e = new Complex[columnsA]; var e = new Complex[columnsA];
@ -2507,7 +2507,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra
// Copy stemp to s with size adjustment. We are using ported copy of linpack's svd code and it uses // Copy stemp to s with size adjustment. We are using ported copy of linpack's svd code and it uses
// a singular vector of length rows+1 when rows < columns. The last element is not used and needs to be removed. // a singular vector of length rows+1 when rows < columns. The last element is not used and needs to be removed.
// We should port lapack's svd routine to remove this problem. // We should port lapack's svd routine to remove this problem.
Array.Copy(stemp, s, Math.Min(rowsA, columnsA)); Array.Copy(stemp, 0, s, 0, Math.Min(rowsA, columnsA));
} }
/// <summary> /// <summary>
@ -2704,7 +2704,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra
throw new ArgumentException(String.Format(Resources.ArgumentArrayWrongLength, order*order), "matrixD"); throw new ArgumentException(String.Format(Resources.ArgumentArrayWrongLength, order*order), "matrixD");
} }
var matrixCopy = new Complex[matrix.Length]; var matrixCopy = new Complex[matrix.Length];
Array.Copy(matrix, matrixCopy, matrix.Length); Array.Copy(matrix, 0, matrixCopy, 0, matrix.Length);
if (isSymmetric) if (isSymmetric)
{ {

10
src/Numerics/Providers/LinearAlgebra/ManagedLinearAlgebraProvider.Complex32.cs

@ -1499,7 +1499,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra
} }
var work = new Complex32[rowsA*columnsA]; var work = new Complex32[rowsA*columnsA];
var minmn = Math.Min(rowsA, columnsA); var minmn = Math.Min(rowsA, columnsA);
for (var i = 0; i < minmn; i++) for (var i = 0; i < minmn; i++)
{ {
@ -1789,7 +1789,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra
var sol = new Complex32[b.Length]; var sol = new Complex32[b.Length];
// Copy B matrix to "sol", so B data will not be changed // Copy B matrix to "sol", so B data will not be changed
Array.Copy(b, sol, b.Length); Array.Copy(b, 0, sol, 0, b.Length);
// Compute Y = transpose(Q)*B // Compute Y = transpose(Q)*B
var column = new Complex32[rowsA]; var column = new Complex32[rowsA];
@ -1891,7 +1891,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra
} }
var work = new Complex32[rowsA]; var work = new Complex32[rowsA];
const int maxiter = 1000; const int maxiter = 1000;
var e = new Complex32[columnsA]; var e = new Complex32[columnsA];
@ -2502,7 +2502,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra
// Copy stemp to s with size adjustment. We are using ported copy of linpack's svd code and it uses // Copy stemp to s with size adjustment. We are using ported copy of linpack's svd code and it uses
// a singular vector of length rows+1 when rows < columns. The last element is not used and needs to be removed. // a singular vector of length rows+1 when rows < columns. The last element is not used and needs to be removed.
// We should port lapack's svd routine to remove this problem. // We should port lapack's svd routine to remove this problem.
Array.Copy(stemp, s, Math.Min(rowsA, columnsA)); Array.Copy(stemp, 0, s, 0, Math.Min(rowsA, columnsA));
} }
/// <summary> /// <summary>
@ -2700,7 +2700,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra
} }
var matrixCopy = new Complex32[matrix.Length]; var matrixCopy = new Complex32[matrix.Length];
Array.Copy(matrix, matrixCopy, matrix.Length); Array.Copy(matrix, 0, matrixCopy, 0, matrix.Length);
var v = new DenseVector(order); var v = new DenseVector(order);
if (isSymmetric) if (isSymmetric)
{ {

10
src/Numerics/RootFinding/Broyden.cs

@ -3,9 +3,9 @@
// http://numerics.mathdotnet.com // http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics // http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com // http://mathnetnumerics.codeplex.com
// //
// Copyright (c) 2009-2013 Math.NET // Copyright (c) 2009-2013 Math.NET
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation // obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without // files (the "Software"), to deal in the Software without
@ -14,10 +14,10 @@
// copies of the Software, and to permit persons to whom the // copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following // Software is furnished to do so, subject to the following
// conditions: // conditions:
// //
// The above copyright notice and this permission notice shall be // The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software. // included in all copies or substantial portions of the Software.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@ -130,7 +130,7 @@ namespace MathNet.Numerics.RootFinding
var B = new DenseMatrix(dim); var B = new DenseMatrix(dim);
var x = new double[dim]; var x = new double[dim];
Array.Copy(x0, x, dim); Array.Copy(x0, 0, x, 0, dim);
for (int j = 0; j < dim; j++) for (int j = 0; j < dim; j++)
{ {

2
src/Numerics/Statistics/ArrayStatistics.cs

@ -4,7 +4,7 @@
// http://github.com/mathnet/mathnet-numerics // http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com // http://mathnetnumerics.codeplex.com
// //
// Copyright (c) 2009-2014 Math.NET // Copyright (c) 2009-2015 Math.NET
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation // obtaining a copy of this software and associated documentation

6
src/Numerics/Statistics/MCMC/HybridMC.cs

@ -203,7 +203,7 @@ namespace MathNet.Numerics.Statistics.Mcmc
protected override double[] Copy(double[] source) protected override double[] Copy(double[] source)
{ {
var destination = new double[_length]; var destination = new double[_length];
Array.Copy(source, destination, _length); Array.Copy(source, 0, destination, 0, _length);
return destination; return destination;
} }
@ -270,8 +270,8 @@ namespace MathNet.Numerics.Statistics.Mcmc
var increment = new double[length]; var increment = new double[length];
var decrement = new double[length]; var decrement = new double[length];
Array.Copy(x, increment, length); Array.Copy(x, 0, increment, 0, length);
Array.Copy(x, decrement, length); Array.Copy(x, 0, decrement, 0, length);
for (int i = 0; i < length; i++) for (int i = 0; i < length; i++)
{ {

2
src/Numerics/Statistics/Statistics.cs

@ -4,7 +4,7 @@
// http://github.com/mathnet/mathnet-numerics // http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com // http://mathnetnumerics.codeplex.com
// //
// Copyright (c) 2009-2014 Math.NET // Copyright (c) 2009-2015 Math.NET
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation // obtaining a copy of this software and associated documentation

2
src/Numerics/Statistics/StreamingStatistics.cs

@ -4,7 +4,7 @@
// http://github.com/mathnet/mathnet-numerics // http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com // http://mathnetnumerics.codeplex.com
// //
// Copyright (c) 2009-2014 Math.NET // Copyright (c) 2009-2015 Math.NET
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation // obtaining a copy of this software and associated documentation

8
src/UnitTests/LinearAlgebraProviderTests/Complex/LinearAlgebraProviderTests.cs

@ -3,9 +3,9 @@
// http://numerics.mathdotnet.com // http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics // http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com // http://mathnetnumerics.codeplex.com
// //
// Copyright (c) 2009-2015 Math.NET // Copyright (c) 2009-2015 Math.NET
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation // obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without // files (the "Software"), to deal in the Software without
@ -14,10 +14,10 @@
// copies of the Software, and to permit persons to whom the // copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following // Software is furnished to do so, subject to the following
// conditions: // conditions:
// //
// The above copyright notice and this permission notice shall be // The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software. // included in all copies or substantial portions of the Software.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND

Loading…
Cancel
Save