Browse Source

LA: backport matrix of seq without rows/cols count from F# to core

optimization-1
Christoph Ruegg 13 years ago
parent
commit
3e4c215d37
  1. 29
      src/Numerics/LinearAlgebra/Complex/DenseMatrix.cs
  2. 25
      src/Numerics/LinearAlgebra/Complex/SparseMatrix.cs
  3. 29
      src/Numerics/LinearAlgebra/Complex32/DenseMatrix.cs
  4. 25
      src/Numerics/LinearAlgebra/Complex32/SparseMatrix.cs
  5. 29
      src/Numerics/LinearAlgebra/Double/DenseMatrix.cs
  6. 25
      src/Numerics/LinearAlgebra/Double/SparseMatrix.cs
  7. 29
      src/Numerics/LinearAlgebra/Single/DenseMatrix.cs
  8. 25
      src/Numerics/LinearAlgebra/Single/SparseMatrix.cs

29
src/Numerics/LinearAlgebra/Complex/DenseMatrix.cs

@ -28,14 +28,15 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
// </copyright> // </copyright>
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using MathNet.Numerics.Distributions; using MathNet.Numerics.Distributions;
using MathNet.Numerics.LinearAlgebra.Storage; using MathNet.Numerics.LinearAlgebra.Storage;
using MathNet.Numerics.Properties; using MathNet.Numerics.Properties;
using MathNet.Numerics.Providers.LinearAlgebra; using MathNet.Numerics.Providers.LinearAlgebra;
using MathNet.Numerics.Threading; using MathNet.Numerics.Threading;
using System;
using System.Collections.Generic;
using System.Diagnostics;
namespace MathNet.Numerics.LinearAlgebra.Complex namespace MathNet.Numerics.LinearAlgebra.Complex
{ {
@ -162,6 +163,17 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
return new DenseMatrix(DenseColumnMajorMatrixStorage<Complex>.OfColumnMajorEnumerable(rows, columns, columnMajor)); return new DenseMatrix(DenseColumnMajorMatrixStorage<Complex>.OfColumnMajorEnumerable(rows, columns, columnMajor));
} }
/// <summary>
/// Create a new dense matrix as a copy of the given enumerable of enumerable columns.
/// Each enumerable in the master enumerable specifies a column.
/// This new matrix will be independent from the enumerables.
/// A new memory block will be allocated for storing the matrix.
/// </summary>
public static DenseMatrix OfColumns(IEnumerable<IEnumerable<Complex>> data)
{
return OfColumnArrays(data.Select(v => v.ToArray()).ToArray());
}
/// <summary> /// <summary>
/// Create a new dense matrix as a copy of the given enumerable of enumerable columns. /// Create a new dense matrix as a copy of the given enumerable of enumerable columns.
/// Each enumerable in the master enumerable specifies a column. /// Each enumerable in the master enumerable specifies a column.
@ -198,6 +210,17 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
return new DenseMatrix(DenseColumnMajorMatrixStorage<Complex>.OfColumnVectors(storage)); return new DenseMatrix(DenseColumnMajorMatrixStorage<Complex>.OfColumnVectors(storage));
} }
/// <summary>
/// Create a new dense matrix as a copy of the given enumerable of enumerable rows.
/// Each enumerable in the master enumerable specifies a row.
/// This new matrix will be independent from the enumerables.
/// A new memory block will be allocated for storing the matrix.
/// </summary>
public static DenseMatrix OfRows(IEnumerable<IEnumerable<Complex>> data)
{
return OfRowArrays(data.Select(v => v.ToArray()).ToArray());
}
/// <summary> /// <summary>
/// Create a new dense matrix as a copy of the given enumerable of enumerable rows. /// Create a new dense matrix as a copy of the given enumerable of enumerable rows.
/// Each enumerable in the master enumerable specifies a row. /// Each enumerable in the master enumerable specifies a row.

25
src/Numerics/LinearAlgebra/Complex/SparseMatrix.cs

@ -28,10 +28,11 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
// </copyright> // </copyright>
using MathNet.Numerics.LinearAlgebra.Storage;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Linq;
using MathNet.Numerics.LinearAlgebra.Storage;
namespace MathNet.Numerics.LinearAlgebra.Complex namespace MathNet.Numerics.LinearAlgebra.Complex
{ {
@ -151,6 +152,17 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
return new SparseMatrix(SparseCompressedRowMatrixStorage<Complex>.OfColumnMajorList(rows, columns, columnMajor)); return new SparseMatrix(SparseCompressedRowMatrixStorage<Complex>.OfColumnMajorList(rows, columns, columnMajor));
} }
/// <summary>
/// Create a new sparse matrix as a copy of the given enumerable of enumerable columns.
/// Each enumerable in the master enumerable specifies a column.
/// This new matrix will be independent from the enumerables.
/// A new memory block will be allocated for storing the matrix.
/// </summary>
public static SparseMatrix OfColumns(IEnumerable<IEnumerable<Complex>> data)
{
return OfColumnArrays(data.Select(v => v.ToArray()).ToArray());
}
/// <summary> /// <summary>
/// Create a new sparse matrix as a copy of the given enumerable of enumerable columns. /// Create a new sparse matrix as a copy of the given enumerable of enumerable columns.
/// Each enumerable in the master enumerable specifies a column. /// Each enumerable in the master enumerable specifies a column.
@ -187,6 +199,17 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
return new SparseMatrix(SparseCompressedRowMatrixStorage<Complex>.OfColumnVectors(storage)); return new SparseMatrix(SparseCompressedRowMatrixStorage<Complex>.OfColumnVectors(storage));
} }
/// <summary>
/// Create a new sparse matrix as a copy of the given enumerable of enumerable rows.
/// Each enumerable in the master enumerable specifies a row.
/// This new matrix will be independent from the enumerables.
/// A new memory block will be allocated for storing the matrix.
/// </summary>
public static SparseMatrix OfRows(IEnumerable<IEnumerable<Complex>> data)
{
return OfRowArrays(data.Select(v => v.ToArray()).ToArray());
}
/// <summary> /// <summary>
/// Create a new sparse matrix as a copy of the given enumerable of enumerable rows. /// Create a new sparse matrix as a copy of the given enumerable of enumerable rows.
/// Each enumerable in the master enumerable specifies a row. /// Each enumerable in the master enumerable specifies a row.

29
src/Numerics/LinearAlgebra/Complex32/DenseMatrix.cs

@ -28,14 +28,15 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
// </copyright> // </copyright>
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using MathNet.Numerics.Distributions; using MathNet.Numerics.Distributions;
using MathNet.Numerics.LinearAlgebra.Storage; using MathNet.Numerics.LinearAlgebra.Storage;
using MathNet.Numerics.Properties; using MathNet.Numerics.Properties;
using MathNet.Numerics.Providers.LinearAlgebra; using MathNet.Numerics.Providers.LinearAlgebra;
using MathNet.Numerics.Threading; using MathNet.Numerics.Threading;
using System;
using System.Collections.Generic;
using System.Diagnostics;
namespace MathNet.Numerics.LinearAlgebra.Complex32 namespace MathNet.Numerics.LinearAlgebra.Complex32
{ {
@ -157,6 +158,17 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
return new DenseMatrix(DenseColumnMajorMatrixStorage<Complex32>.OfColumnMajorEnumerable(rows, columns, columnMajor)); return new DenseMatrix(DenseColumnMajorMatrixStorage<Complex32>.OfColumnMajorEnumerable(rows, columns, columnMajor));
} }
/// <summary>
/// Create a new dense matrix as a copy of the given enumerable of enumerable columns.
/// Each enumerable in the master enumerable specifies a column.
/// This new matrix will be independent from the enumerables.
/// A new memory block will be allocated for storing the matrix.
/// </summary>
public static DenseMatrix OfColumns(IEnumerable<IEnumerable<Complex32>> data)
{
return OfColumnArrays(data.Select(v => v.ToArray()).ToArray());
}
/// <summary> /// <summary>
/// Create a new dense matrix as a copy of the given enumerable of enumerable columns. /// Create a new dense matrix as a copy of the given enumerable of enumerable columns.
/// Each enumerable in the master enumerable specifies a column. /// Each enumerable in the master enumerable specifies a column.
@ -193,6 +205,17 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
return new DenseMatrix(DenseColumnMajorMatrixStorage<Complex32>.OfColumnVectors(storage)); return new DenseMatrix(DenseColumnMajorMatrixStorage<Complex32>.OfColumnVectors(storage));
} }
/// <summary>
/// Create a new dense matrix as a copy of the given enumerable of enumerable rows.
/// Each enumerable in the master enumerable specifies a row.
/// This new matrix will be independent from the enumerables.
/// A new memory block will be allocated for storing the matrix.
/// </summary>
public static DenseMatrix OfRows(IEnumerable<IEnumerable<Complex32>> data)
{
return OfRowArrays(data.Select(v => v.ToArray()).ToArray());
}
/// <summary> /// <summary>
/// Create a new dense matrix as a copy of the given enumerable of enumerable rows. /// Create a new dense matrix as a copy of the given enumerable of enumerable rows.
/// Each enumerable in the master enumerable specifies a row. /// Each enumerable in the master enumerable specifies a row.

25
src/Numerics/LinearAlgebra/Complex32/SparseMatrix.cs

@ -28,10 +28,11 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
// </copyright> // </copyright>
using MathNet.Numerics.LinearAlgebra.Storage;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Linq;
using MathNet.Numerics.LinearAlgebra.Storage;
namespace MathNet.Numerics.LinearAlgebra.Complex32 namespace MathNet.Numerics.LinearAlgebra.Complex32
{ {
@ -146,6 +147,17 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
return new SparseMatrix(SparseCompressedRowMatrixStorage<Complex32>.OfColumnMajorList(rows, columns, columnMajor)); return new SparseMatrix(SparseCompressedRowMatrixStorage<Complex32>.OfColumnMajorList(rows, columns, columnMajor));
} }
/// <summary>
/// Create a new sparse matrix as a copy of the given enumerable of enumerable columns.
/// Each enumerable in the master enumerable specifies a column.
/// This new matrix will be independent from the enumerables.
/// A new memory block will be allocated for storing the matrix.
/// </summary>
public static SparseMatrix OfColumns(IEnumerable<IEnumerable<Complex32>> data)
{
return OfColumnArrays(data.Select(v => v.ToArray()).ToArray());
}
/// <summary> /// <summary>
/// Create a new sparse matrix as a copy of the given enumerable of enumerable columns. /// Create a new sparse matrix as a copy of the given enumerable of enumerable columns.
/// Each enumerable in the master enumerable specifies a column. /// Each enumerable in the master enumerable specifies a column.
@ -182,6 +194,17 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
return new SparseMatrix(SparseCompressedRowMatrixStorage<Complex32>.OfColumnVectors(storage)); return new SparseMatrix(SparseCompressedRowMatrixStorage<Complex32>.OfColumnVectors(storage));
} }
/// <summary>
/// Create a new sparse matrix as a copy of the given enumerable of enumerable rows.
/// Each enumerable in the master enumerable specifies a row.
/// This new matrix will be independent from the enumerables.
/// A new memory block will be allocated for storing the matrix.
/// </summary>
public static SparseMatrix OfRows(IEnumerable<IEnumerable<Complex32>> data)
{
return OfRowArrays(data.Select(v => v.ToArray()).ToArray());
}
/// <summary> /// <summary>
/// Create a new sparse matrix as a copy of the given enumerable of enumerable rows. /// Create a new sparse matrix as a copy of the given enumerable of enumerable rows.
/// Each enumerable in the master enumerable specifies a row. /// Each enumerable in the master enumerable specifies a row.

29
src/Numerics/LinearAlgebra/Double/DenseMatrix.cs

@ -28,14 +28,15 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
// </copyright> // </copyright>
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using MathNet.Numerics.Distributions; using MathNet.Numerics.Distributions;
using MathNet.Numerics.LinearAlgebra.Storage; using MathNet.Numerics.LinearAlgebra.Storage;
using MathNet.Numerics.Properties; using MathNet.Numerics.Properties;
using MathNet.Numerics.Providers.LinearAlgebra; using MathNet.Numerics.Providers.LinearAlgebra;
using MathNet.Numerics.Threading; using MathNet.Numerics.Threading;
using System;
using System.Collections.Generic;
using System.Diagnostics;
namespace MathNet.Numerics.LinearAlgebra.Double namespace MathNet.Numerics.LinearAlgebra.Double
{ {
@ -155,6 +156,17 @@ namespace MathNet.Numerics.LinearAlgebra.Double
return new DenseMatrix(DenseColumnMajorMatrixStorage<double>.OfColumnMajorEnumerable(rows, columns, columnMajor)); return new DenseMatrix(DenseColumnMajorMatrixStorage<double>.OfColumnMajorEnumerable(rows, columns, columnMajor));
} }
/// <summary>
/// Create a new dense matrix as a copy of the given enumerable of enumerable columns.
/// Each enumerable in the master enumerable specifies a column.
/// This new matrix will be independent from the enumerables.
/// A new memory block will be allocated for storing the matrix.
/// </summary>
public static DenseMatrix OfColumns(IEnumerable<IEnumerable<double>> data)
{
return OfColumnArrays(data.Select(v => v.ToArray()).ToArray());
}
/// <summary> /// <summary>
/// Create a new dense matrix as a copy of the given enumerable of enumerable columns. /// Create a new dense matrix as a copy of the given enumerable of enumerable columns.
/// Each enumerable in the master enumerable specifies a column. /// Each enumerable in the master enumerable specifies a column.
@ -191,6 +203,17 @@ namespace MathNet.Numerics.LinearAlgebra.Double
return new DenseMatrix(DenseColumnMajorMatrixStorage<double>.OfColumnVectors(storage)); return new DenseMatrix(DenseColumnMajorMatrixStorage<double>.OfColumnVectors(storage));
} }
/// <summary>
/// Create a new dense matrix as a copy of the given enumerable of enumerable rows.
/// Each enumerable in the master enumerable specifies a row.
/// This new matrix will be independent from the enumerables.
/// A new memory block will be allocated for storing the matrix.
/// </summary>
public static DenseMatrix OfRows(IEnumerable<IEnumerable<double>> data)
{
return OfRowArrays(data.Select(v => v.ToArray()).ToArray());
}
/// <summary> /// <summary>
/// Create a new dense matrix as a copy of the given enumerable of enumerable rows. /// Create a new dense matrix as a copy of the given enumerable of enumerable rows.
/// Each enumerable in the master enumerable specifies a row. /// Each enumerable in the master enumerable specifies a row.

25
src/Numerics/LinearAlgebra/Double/SparseMatrix.cs

@ -28,10 +28,11 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
// </copyright> // </copyright>
using MathNet.Numerics.LinearAlgebra.Storage;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Linq;
using MathNet.Numerics.LinearAlgebra.Storage;
namespace MathNet.Numerics.LinearAlgebra.Double namespace MathNet.Numerics.LinearAlgebra.Double
{ {
@ -144,6 +145,17 @@ namespace MathNet.Numerics.LinearAlgebra.Double
return new SparseMatrix(SparseCompressedRowMatrixStorage<double>.OfColumnMajorList(rows, columns, columnMajor)); return new SparseMatrix(SparseCompressedRowMatrixStorage<double>.OfColumnMajorList(rows, columns, columnMajor));
} }
/// <summary>
/// Create a new sparse matrix as a copy of the given enumerable of enumerable columns.
/// Each enumerable in the master enumerable specifies a column.
/// This new matrix will be independent from the enumerables.
/// A new memory block will be allocated for storing the matrix.
/// </summary>
public static SparseMatrix OfColumns(IEnumerable<IEnumerable<double>> data)
{
return OfColumnArrays(data.Select(v => v.ToArray()).ToArray());
}
/// <summary> /// <summary>
/// Create a new sparse matrix as a copy of the given enumerable of enumerable columns. /// Create a new sparse matrix as a copy of the given enumerable of enumerable columns.
/// Each enumerable in the master enumerable specifies a column. /// Each enumerable in the master enumerable specifies a column.
@ -180,6 +192,17 @@ namespace MathNet.Numerics.LinearAlgebra.Double
return new SparseMatrix(SparseCompressedRowMatrixStorage<double>.OfColumnVectors(storage)); return new SparseMatrix(SparseCompressedRowMatrixStorage<double>.OfColumnVectors(storage));
} }
/// <summary>
/// Create a new sparse matrix as a copy of the given enumerable of enumerable rows.
/// Each enumerable in the master enumerable specifies a row.
/// This new matrix will be independent from the enumerables.
/// A new memory block will be allocated for storing the matrix.
/// </summary>
public static SparseMatrix OfRows(IEnumerable<IEnumerable<double>> data)
{
return OfRowArrays(data.Select(v => v.ToArray()).ToArray());
}
/// <summary> /// <summary>
/// Create a new sparse matrix as a copy of the given enumerable of enumerable rows. /// Create a new sparse matrix as a copy of the given enumerable of enumerable rows.
/// Each enumerable in the master enumerable specifies a row. /// Each enumerable in the master enumerable specifies a row.

29
src/Numerics/LinearAlgebra/Single/DenseMatrix.cs

@ -28,14 +28,15 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
// </copyright> // </copyright>
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using MathNet.Numerics.Distributions; using MathNet.Numerics.Distributions;
using MathNet.Numerics.LinearAlgebra.Storage; using MathNet.Numerics.LinearAlgebra.Storage;
using MathNet.Numerics.Properties; using MathNet.Numerics.Properties;
using MathNet.Numerics.Providers.LinearAlgebra; using MathNet.Numerics.Providers.LinearAlgebra;
using MathNet.Numerics.Threading; using MathNet.Numerics.Threading;
using System;
using System.Collections.Generic;
using System.Diagnostics;
namespace MathNet.Numerics.LinearAlgebra.Single namespace MathNet.Numerics.LinearAlgebra.Single
{ {
@ -155,6 +156,17 @@ namespace MathNet.Numerics.LinearAlgebra.Single
return new DenseMatrix(DenseColumnMajorMatrixStorage<float>.OfColumnMajorEnumerable(rows, columns, columnMajor)); return new DenseMatrix(DenseColumnMajorMatrixStorage<float>.OfColumnMajorEnumerable(rows, columns, columnMajor));
} }
/// <summary>
/// Create a new dense matrix as a copy of the given enumerable of enumerable columns.
/// Each enumerable in the master enumerable specifies a column.
/// This new matrix will be independent from the enumerables.
/// A new memory block will be allocated for storing the matrix.
/// </summary>
public static DenseMatrix OfColumns(IEnumerable<IEnumerable<float>> data)
{
return OfColumnArrays(data.Select(v => v.ToArray()).ToArray());
}
/// <summary> /// <summary>
/// Create a new dense matrix as a copy of the given enumerable of enumerable columns. /// Create a new dense matrix as a copy of the given enumerable of enumerable columns.
/// Each enumerable in the master enumerable specifies a column. /// Each enumerable in the master enumerable specifies a column.
@ -191,6 +203,17 @@ namespace MathNet.Numerics.LinearAlgebra.Single
return new DenseMatrix(DenseColumnMajorMatrixStorage<float>.OfColumnVectors(storage)); return new DenseMatrix(DenseColumnMajorMatrixStorage<float>.OfColumnVectors(storage));
} }
/// <summary>
/// Create a new dense matrix as a copy of the given enumerable of enumerable rows.
/// Each enumerable in the master enumerable specifies a row.
/// This new matrix will be independent from the enumerables.
/// A new memory block will be allocated for storing the matrix.
/// </summary>
public static DenseMatrix OfRows(IEnumerable<IEnumerable<float>> data)
{
return OfRowArrays(data.Select(v => v.ToArray()).ToArray());
}
/// <summary> /// <summary>
/// Create a new dense matrix as a copy of the given enumerable of enumerable rows. /// Create a new dense matrix as a copy of the given enumerable of enumerable rows.
/// Each enumerable in the master enumerable specifies a row. /// Each enumerable in the master enumerable specifies a row.

25
src/Numerics/LinearAlgebra/Single/SparseMatrix.cs

@ -28,10 +28,11 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
// </copyright> // </copyright>
using MathNet.Numerics.LinearAlgebra.Storage;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Linq;
using MathNet.Numerics.LinearAlgebra.Storage;
namespace MathNet.Numerics.LinearAlgebra.Single namespace MathNet.Numerics.LinearAlgebra.Single
{ {
@ -143,6 +144,17 @@ namespace MathNet.Numerics.LinearAlgebra.Single
{ {
return new SparseMatrix(SparseCompressedRowMatrixStorage<float>.OfColumnMajorList(rows, columns, columnMajor)); return new SparseMatrix(SparseCompressedRowMatrixStorage<float>.OfColumnMajorList(rows, columns, columnMajor));
} }
/// <summary>
/// Create a new sparse matrix as a copy of the given enumerable of enumerable columns.
/// Each enumerable in the master enumerable specifies a column.
/// This new matrix will be independent from the enumerables.
/// A new memory block will be allocated for storing the matrix.
/// </summary>
public static SparseMatrix OfColumns(IEnumerable<IEnumerable<float>> data)
{
return OfColumnArrays(data.Select(v => v.ToArray()).ToArray());
}
/// <summary> /// <summary>
/// Create a new sparse matrix as a copy of the given enumerable of enumerable columns. /// Create a new sparse matrix as a copy of the given enumerable of enumerable columns.
@ -180,6 +192,17 @@ namespace MathNet.Numerics.LinearAlgebra.Single
return new SparseMatrix(SparseCompressedRowMatrixStorage<float>.OfColumnVectors(storage)); return new SparseMatrix(SparseCompressedRowMatrixStorage<float>.OfColumnVectors(storage));
} }
/// <summary>
/// Create a new sparse matrix as a copy of the given enumerable of enumerable rows.
/// Each enumerable in the master enumerable specifies a row.
/// This new matrix will be independent from the enumerables.
/// A new memory block will be allocated for storing the matrix.
/// </summary>
public static SparseMatrix OfRows(IEnumerable<IEnumerable<float>> data)
{
return OfRowArrays(data.Select(v => v.ToArray()).ToArray());
}
/// <summary> /// <summary>
/// Create a new sparse matrix as a copy of the given enumerable of enumerable rows. /// Create a new sparse matrix as a copy of the given enumerable of enumerable rows.
/// Each enumerable in the master enumerable specifies a row. /// Each enumerable in the master enumerable specifies a row.

Loading…
Cancel
Save