From 892bbe510e889cb2553559865e6f3ade70711787 Mon Sep 17 00:00:00 2001 From: Christoph Ruegg Date: Sun, 25 Nov 2012 11:05:17 +0100 Subject: [PATCH] F#: Simplify and clarify project file structure --- src/FSharp/AssemblyInfo.fs | 2 +- src/FSharp/DenseMatrix.fs | 101 --------------- src/FSharp/DenseVector.fs | 69 ---------- src/FSharp/FSharp.fsproj | 12 +- ...trix.fs => LinearAlgebra.Double.Matrix.fs} | 119 +++++++++++++++++- ...ctor.fs => LinearAlgebra.Double.Vector.fs} | 61 ++++++++- .../{Extensions.fs => LinearAlgebra.fs} | 4 +- src/FSharp/Main.fs | 4 +- src/FSharp/SparseMatrix.fs | 75 ----------- src/FSharp/SparseVector.fs | 48 ------- src/FSharpPortable/FSharpPortable.fsproj | 27 ++-- 11 files changed, 190 insertions(+), 332 deletions(-) delete mode 100644 src/FSharp/DenseMatrix.fs delete mode 100644 src/FSharp/DenseVector.fs rename src/FSharp/{Matrix.fs => LinearAlgebra.Double.Matrix.fs} (66%) rename src/FSharp/{Vector.fs => LinearAlgebra.Double.Vector.fs} (76%) rename src/FSharp/{Extensions.fs => LinearAlgebra.fs} (96%) mode change 100755 => 100644 delete mode 100644 src/FSharp/SparseMatrix.fs delete mode 100644 src/FSharp/SparseVector.fs diff --git a/src/FSharp/AssemblyInfo.fs b/src/FSharp/AssemblyInfo.fs index e64c03b7..66beea9d 100644 --- a/src/FSharp/AssemblyInfo.fs +++ b/src/FSharp/AssemblyInfo.fs @@ -35,7 +35,7 @@ open System.Resources; open System.Runtime.CompilerServices open System.Runtime.InteropServices -[] +[] [] [] [] diff --git a/src/FSharp/DenseMatrix.fs b/src/FSharp/DenseMatrix.fs deleted file mode 100644 index 01497f72..00000000 --- a/src/FSharp/DenseMatrix.fs +++ /dev/null @@ -1,101 +0,0 @@ -// -// Math.NET Numerics, part of the Math.NET Project -// http://mathnet.opensourcedotnet.info -// http://numerics.mathdotnet.com -// http://github.com/mathnet/mathnet-numerics -// http://mathnetnumerics.codeplex.com -// -// Copyright (c) 2009 Math.NET -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. -// - -namespace MathNet.Numerics.LinearAlgebra.Double -open MathNet.Numerics.LinearAlgebra -open MathNet.Numerics.LinearAlgebra.Generic - -/// A module which implements functional dense vector operations. -module DenseMatrix = - - /// Initialize a matrix by calling a construction function for every element. - let inline init (n: int) (m: int) f = - let A = new DenseMatrix(n,m) - for i=0 to n-1 do - for j=0 to m-1 do - A.[i,j] <- f i j - A - - /// Create a matrix from a list of float lists. Every list in the master list specifies a row. - let inline ofList (fll: float list list) = - let n = List.length fll - let m = List.length (List.head fll) - let A = DenseMatrix(n,m) - fll |> List.iteri (fun i fl -> - if (List.length fl) <> m then failwith "Each subrow must be of the same length." else - List.iteri (fun j f -> A.[i,j] <- f) fl) - A - - /// Create a matrix from a list of sequences. Every sequence in the master sequence specifies a row. - let inline ofSeq (fss: #seq<#seq>) = - let n = Seq.length fss - let m = Seq.length (Seq.head fss) - let A = DenseMatrix(n,m) - fss |> Seq.iteri (fun i fs -> - if (Seq.length fs) <> m then failwith "Each subrow must be of the same length." else - Seq.iteri (fun j f -> A.[i,j] <- f) fs) - A - - /// Create a matrix from a 2D array of floating point numbers. - let inline ofArray2 (arr: float[,]) = new DenseMatrix(arr) - - /// Create a matrix with the given entries. - let inline initDense (n: int) (m: int) (es: #seq) = - let A = new DenseMatrix(n,m) - Seq.iter (fun (i,j,f) -> A.[i,j] <- f) es - A - - /// Create a square matrix with constant diagonal entries. - let inline constDiag (n: int) (f: float) = - let A = new DenseMatrix(n,n) - for i=0 to n-1 do - A.[i,i] <- f - A - - /// Create a square matrix with the vector elements on the diagonal. - let inline diag (v: #Vector) = - let n = v.Count - let A = new DenseMatrix(n,n) - for i=0 to n-1 do - A.[i,i] <- v.Item(i) - A - - /// Initialize a matrix by calling a construction function for every row. - let inline initRow (n: int) (m: int) (f: int -> #Vector) = - let A = new DenseMatrix(n,m) - for i=0 to n-1 do A.SetRow(i, f i) - A - - /// Initialize a matrix by calling a construction function for every column. - let inline initCol (n: int) (m: int) (f: int -> #Vector) = - let A = new DenseMatrix(n,m) - for i=0 to m-1 do A.SetColumn(i, f i) - A \ No newline at end of file diff --git a/src/FSharp/DenseVector.fs b/src/FSharp/DenseVector.fs deleted file mode 100644 index 3e56484e..00000000 --- a/src/FSharp/DenseVector.fs +++ /dev/null @@ -1,69 +0,0 @@ -// -// Math.NET Numerics, part of the Math.NET Project -// http://numerics.mathdotnet.com -// http://github.com/mathnet/mathnet-numerics -// http://mathnetnumerics.codeplex.com -// -// Copyright (c) 2009 Math.NET -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. -// - -namespace MathNet.Numerics.LinearAlgebra.Double - -open MathNet.Numerics.LinearAlgebra - -/// A module which implements functional dense vector operations. -module DenseVector = - - /// Initialize a vector by calling a construction function for every element. - let inline init (n: int) f = - let v = new Double.DenseVector(n) - for i=0 to n-1 do - v.[i] <- f i - v - - /// Create a vector from a float list. - let inline ofList (fl: float list) = - let n = List.length fl - let v = Double.DenseVector(n) - fl |> List.iteri (fun i f -> v.[i] <- f) - v - - /// Create a vector from a sequences. - let inline ofSeq (fs: #seq) = - let n = Seq.length fs - let v = DenseVector(n) - fs |> Seq.iteri (fun i f -> v.[i] <- f) - v - - /// Create a vector with evenly spaced entries: e.g. rangef -1.0 0.5 1.0 = [-1.0 -0.5 0.0 0.5 1.0] - let inline rangef (start: float) (step: float) (stop: float) = - let n = (int ((stop - start) / step)) + 1 - let v = new DenseVector(n) - for i=0 to n-1 do - v.[i] <- (float i) * step + start - v - - /// Create a vector with integer entries in the given range. - let inline range (start: int) (stop: int) = - new DenseVector([| for i in [start .. stop] -> float i |]) \ No newline at end of file diff --git a/src/FSharp/FSharp.fsproj b/src/FSharp/FSharp.fsproj index 01ce67bf..558428a4 100644 --- a/src/FSharp/FSharp.fsproj +++ b/src/FSharp/FSharp.fsproj @@ -50,15 +50,11 @@ - - - - - - - - + + + + diff --git a/src/FSharp/Matrix.fs b/src/FSharp/LinearAlgebra.Double.Matrix.fs similarity index 66% rename from src/FSharp/Matrix.fs rename to src/FSharp/LinearAlgebra.Double.Matrix.fs index e25a71e9..81542be8 100644 --- a/src/FSharp/Matrix.fs +++ b/src/FSharp/LinearAlgebra.Double.Matrix.fs @@ -1,10 +1,10 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics // http://mathnetnumerics.codeplex.com // -// Copyright (c) 2009 Math.NET +// Copyright (c) 2009-2012 Math.NET // // Permission is hereby granted, free of charge, to any person // obtaining a copy of this software and associated documentation @@ -30,10 +30,10 @@ namespace MathNet.Numerics.LinearAlgebra.Double -open MathNet.Numerics.LinearAlgebra.Double open MathNet.Numerics.LinearAlgebra.Generic /// A module which implements functional matrix operations. +[] module Matrix = /// Fold a function over all matrix elements. @@ -240,4 +240,115 @@ module Matrix = for i=0 to A.ColumnCount-1 do macc <- f macc (A.Item(k,i)) v.[k] <- macc - v :> Vector \ No newline at end of file + v :> Vector + +/// A module which implements functional dense vector operations. +[] +module DenseMatrix = + + /// Initialize a matrix by calling a construction function for every element. + let inline init (n: int) (m: int) f = + let A = new DenseMatrix(n,m) + for i=0 to n-1 do + for j=0 to m-1 do + A.[i,j] <- f i j + A + + /// Create a matrix from a list of float lists. Every list in the master list specifies a row. + let inline ofList (fll: float list list) = + let n = List.length fll + let m = List.length (List.head fll) + let A = DenseMatrix(n,m) + fll |> List.iteri (fun i fl -> + if (List.length fl) <> m then failwith "Each subrow must be of the same length." else + List.iteri (fun j f -> A.[i,j] <- f) fl) + A + + /// Create a matrix from a list of sequences. Every sequence in the master sequence specifies a row. + let inline ofSeq (fss: #seq<#seq>) = + let n = Seq.length fss + let m = Seq.length (Seq.head fss) + let A = DenseMatrix(n,m) + fss |> Seq.iteri (fun i fs -> + if (Seq.length fs) <> m then failwith "Each subrow must be of the same length." else + Seq.iteri (fun j f -> A.[i,j] <- f) fs) + A + + /// Create a matrix from a 2D array of floating point numbers. + let inline ofArray2 (arr: float[,]) = new DenseMatrix(arr) + + /// Create a matrix with the given entries. + let inline initDense (n: int) (m: int) (es: #seq) = + let A = new DenseMatrix(n,m) + Seq.iter (fun (i,j,f) -> A.[i,j] <- f) es + A + + /// Create a square matrix with constant diagonal entries. + let inline constDiag (n: int) (f: float) = + let A = new DenseMatrix(n,n) + for i=0 to n-1 do + A.[i,i] <- f + A + + /// Create a square matrix with the vector elements on the diagonal. + let inline diag (v: #Vector) = + let n = v.Count + let A = new DenseMatrix(n,n) + for i=0 to n-1 do + A.[i,i] <- v.Item(i) + A + + /// Initialize a matrix by calling a construction function for every row. + let inline initRow (n: int) (m: int) (f: int -> #Vector) = + let A = new DenseMatrix(n,m) + for i=0 to n-1 do A.SetRow(i, f i) + A + + /// Initialize a matrix by calling a construction function for every column. + let inline initCol (n: int) (m: int) (f: int -> #Vector) = + let A = new DenseMatrix(n,m) + for i=0 to m-1 do A.SetColumn(i, f i) + A + +/// A module which implements functional sparse vector operations. +[] +module SparseMatrix = + + /// Create a matrix from a list of float lists. Every list in the master list specifies a row. + let inline ofList (rows: int) (cols: int) (fll: list) = + let A = new SparseMatrix(rows, cols) + fll |> List.iter (fun (i, j, x) -> A.[i,j] <- x) + A + + /// Create a matrix from a list of sequences. Every sequence in the master sequence specifies a row. + let inline ofSeq (rows: int) (cols: int) (fss: #seq) = + let A = new SparseMatrix(rows, cols) + fss |> Seq.iter (fun (i, j, x) -> A.[i,j] <- x) + A + + /// Create a square matrix with constant diagonal entries. + let inline constDiag (n: int) (f: float) = + let A = new SparseMatrix(n,n) + for i=0 to n-1 do + A.[i,i] <- f + A + + /// Create a square matrix with the vector elements on the diagonal. + let inline diag (v: #Vector) = + let n = v.Count + let A = new SparseMatrix(n,n) + for i=0 to n-1 do + A.[i,i] <- v.Item(i) + A + + /// Initialize a matrix by calling a construction function for every row. + let inline initRow (n: int) (m: int) (f: int -> #Vector) = + let A = new SparseMatrix(n,m) + for i=0 to n-1 do A.SetRow(i, f i) + A + + /// Initialize a matrix by calling a construction function for every column. + let inline initCol (n: int) (m: int) (f: int -> #Vector) = + let A = new SparseMatrix(n,m) + for i=0 to m-1 do A.SetColumn(i, f i) + A \ No newline at end of file diff --git a/src/FSharp/Vector.fs b/src/FSharp/LinearAlgebra.Double.Vector.fs similarity index 76% rename from src/FSharp/Vector.fs rename to src/FSharp/LinearAlgebra.Double.Vector.fs index e05a1fe1..cdd2c0a5 100644 --- a/src/FSharp/Vector.fs +++ b/src/FSharp/LinearAlgebra.Double.Vector.fs @@ -1,10 +1,10 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics // http://mathnetnumerics.codeplex.com // -// Copyright (c) 2009 Math.NET +// Copyright (c) 2009-2012 Math.NET // // Permission is hereby granted, free of charge, to any person // obtaining a copy of this software and associated documentation @@ -30,10 +30,10 @@ namespace MathNet.Numerics.LinearAlgebra.Double -open MathNet.Numerics.LinearAlgebra open MathNet.Numerics.LinearAlgebra.Generic /// A module which implements functional vector operations. +[] module Vector = /// Transform a vector into an array. @@ -184,4 +184,57 @@ module Vector = newV.Item(index) <- value for i = index + 1 to v.Count do newV.Item(i) <- v.Item(i - 1) - newV \ No newline at end of file + newV + +/// A module which implements functional dense vector operations. +[] +module DenseVector = + + /// Initialize a vector by calling a construction function for every element. + let inline init (n: int) f = + let v = new DenseVector(n) + for i=0 to n-1 do + v.[i] <- f i + v + + /// Create a vector from a float list. + let inline ofList (fl: float list) = + let n = List.length fl + let v = DenseVector(n) + fl |> List.iteri (fun i f -> v.[i] <- f) + v + + /// Create a vector from a sequences. + let inline ofSeq (fs: #seq) = + let n = Seq.length fs + let v = DenseVector(n) + fs |> Seq.iteri (fun i f -> v.[i] <- f) + v + + /// Create a vector with evenly spaced entries: e.g. rangef -1.0 0.5 1.0 = [-1.0 -0.5 0.0 0.5 1.0] + let inline rangef (start: float) (step: float) (stop: float) = + let n = (int ((stop - start) / step)) + 1 + let v = new DenseVector(n) + for i=0 to n-1 do + v.[i] <- (float i) * step + start + v + + /// Create a vector with integer entries in the given range. + let inline range (start: int) (stop: int) = + new DenseVector([| for i in [start .. stop] -> float i |]) + +/// A module which implements functional sparse vector operations. +[] +module SparseVector = + + /// Create a sparse vector with a given dimension from a list of entry, value pairs. + let inline ofList (dim: int) (fl: list) = + let v = new SparseVector(dim) + fl |> List.iter (fun (i, f) -> v.[i] <- f) + v + + /// Create a sparse vector with a given dimension from a sequence of entry, value pairs. + let inline ofSeq (dim: int) (fs: #seq) = + let v = new SparseVector(dim) + fs |> Seq.iter (fun (i, f) -> v.[i] <- f) + v diff --git a/src/FSharp/Extensions.fs b/src/FSharp/LinearAlgebra.fs old mode 100755 new mode 100644 similarity index 96% rename from src/FSharp/Extensions.fs rename to src/FSharp/LinearAlgebra.fs index 7ca5b7dd..f81ed35e --- a/src/FSharp/Extensions.fs +++ b/src/FSharp/LinearAlgebra.fs @@ -1,10 +1,10 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics // http://mathnetnumerics.codeplex.com // -// Copyright (c) 2009 Math.NET +// Copyright (c) 2009-2012 Math.NET // // Permission is hereby granted, free of charge, to any person // obtaining a copy of this software and associated documentation diff --git a/src/FSharp/Main.fs b/src/FSharp/Main.fs index 9bb5c897..b36c414d 100644 --- a/src/FSharp/Main.fs +++ b/src/FSharp/Main.fs @@ -4,7 +4,7 @@ // http://github.com/mathnet/mathnet-numerics // http://mathnetnumerics.codeplex.com // -// Copyright (c) 2009 Math.NET +// Copyright (c) 2009-2012 Math.NET // // Permission is hereby granted, free of charge, to any person // obtaining a copy of this software and associated documentation @@ -30,8 +30,8 @@ namespace MathNet.Numerics -open MathNet.Numerics.LinearAlgebra.Double open MathNet.Numerics.LinearAlgebra.Generic +open MathNet.Numerics.LinearAlgebra.Double /// A module which implements some F# utility functions. module FSharp = diff --git a/src/FSharp/SparseMatrix.fs b/src/FSharp/SparseMatrix.fs deleted file mode 100644 index 7d996697..00000000 --- a/src/FSharp/SparseMatrix.fs +++ /dev/null @@ -1,75 +0,0 @@ -// -// Math.NET Numerics, part of the Math.NET Project -// http://numerics.mathdotnet.com -// http://github.com/mathnet/mathnet-numerics -// http://mathnetnumerics.codeplex.com -// -// Copyright (c) 2009 Math.NET -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. -// - -namespace MathNet.Numerics.LinearAlgebra.Double - -open MathNet.Numerics.LinearAlgebra -open MathNet.Numerics.LinearAlgebra.Generic -/// A module which implements functional sparse vector operations. -module SparseMatrix = - - /// Create a matrix from a list of float lists. Every list in the master list specifies a row. - let inline ofList (rows: int) (cols: int) (fll: list) = - let A = new Double.SparseMatrix(rows, cols) - fll |> List.iter (fun (i, j, x) -> A.[i,j] <- x) - A - - /// Create a matrix from a list of sequences. Every sequence in the master sequence specifies a row. - let inline ofSeq (rows: int) (cols: int) (fss: #seq) = - let A = new Double.SparseMatrix(rows, cols) - fss |> Seq.iter (fun (i, j, x) -> A.[i,j] <- x) - A - - /// Create a square matrix with constant diagonal entries. - let inline constDiag (n: int) (f: float) = - let A = new Double.SparseMatrix(n,n) - for i=0 to n-1 do - A.[i,i] <- f - A - - /// Create a square matrix with the vector elements on the diagonal. - let inline diag (v: #Vector) = - let n = v.Count - let A = new Double.SparseMatrix(n,n) - for i=0 to n-1 do - A.[i,i] <- v.Item(i) - A - - /// Initialize a matrix by calling a construction function for every row. - let inline initRow (n: int) (m: int) (f: int -> #Vector) = - let A = new Double.SparseMatrix(n,m) - for i=0 to n-1 do A.SetRow(i, f i) - A - - /// Initialize a matrix by calling a construction function for every column. - let inline initCol (n: int) (m: int) (f: int -> #Vector) = - let A = new Double.SparseMatrix(n,m) - for i=0 to m-1 do A.SetColumn(i, f i) - A \ No newline at end of file diff --git a/src/FSharp/SparseVector.fs b/src/FSharp/SparseVector.fs deleted file mode 100644 index e5c748bc..00000000 --- a/src/FSharp/SparseVector.fs +++ /dev/null @@ -1,48 +0,0 @@ -// -// Math.NET Numerics, part of the Math.NET Project -// http://numerics.mathdotnet.com -// http://github.com/mathnet/mathnet-numerics -// http://mathnetnumerics.codeplex.com -// -// Copyright (c) 2009 Math.NET -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. -// - -namespace MathNet.Numerics.LinearAlgebra.Double - -open MathNet.Numerics.LinearAlgebra - -/// A module which implements functional sparse vector operations. -module SparseVector = - - /// Create a sparse vector with a given dimension from a list of entry, value pairs. - let inline ofList (dim: int) (fl: list) = - let v = new Double.SparseVector(dim) - fl |> List.iter (fun (i, f) -> v.[i] <- f) - v - - /// Create a sparse vector with a given dimension from a sequence of entry, value pairs. - let inline ofSeq (dim: int) (fs: #seq) = - let v = new Double.SparseVector(dim) - fs |> Seq.iter (fun (i, f) -> v.[i] <- f) - v \ No newline at end of file diff --git a/src/FSharpPortable/FSharpPortable.fsproj b/src/FSharpPortable/FSharpPortable.fsproj index 8490eca6..a104d832 100644 --- a/src/FSharpPortable/FSharpPortable.fsproj +++ b/src/FSharpPortable/FSharpPortable.fsproj @@ -41,30 +41,21 @@ - - DenseMatrix.fs + + AssemblyInfo.fs - - DenseVector.fs + + LinearAlgebra.fs - - Extensions.fs + + LinearAlgebra.Double.Matrix.fs + + + LinearAlgebra.Double.Vector.fs Main.fs - - Matrix.fs - - - SparseMatrix.fs - - - SparseVector.fs - - - Vector.fs -