Skip to content

Commit

Permalink
Add matrix and vector docs
Browse files Browse the repository at this point in the history
  • Loading branch information
muehlhaus committed Jan 22, 2017
1 parent 9763dd9 commit 1b7fce7
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 1 deletion.
1 change: 1 addition & 0 deletions FSharp.Stats.sln
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "content", "content", "{8E6D5255-776D-4B61-85F9-73C37AA1FB9A}"
ProjectSection(SolutionItems) = preProject
docs\content\index.fsx = docs\content\index.fsx
docs\content\Matrix_Vector.fsx = docs\content\Matrix_Vector.fsx
docs\content\tutorial.fsx = docs\content\tutorial.fsx
EndProjectSection
EndProject
Expand Down
63 changes: 63 additions & 0 deletions docs/content/Matrix_Vector.fsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
(*** hide ***)
// This block of code is omitted in the generated HTML documentation. Use
// it to define helpers that you do not want to show in the documentation.
//#I "../../bin"

(**
dfdf
*)
#r "D:/Source/FSharp.Stats/bin/FSharp.Stats.dll"
//#r "FSharp.Stats.dll"
//open FSharp
open Microsoft.FSharp.Math




// http://fdatamining.blogspot.de/2010/03/matrix-and-linear-algebra-in-f-part-i-f.html
// 1.9.7.8.
// http://fdatamining.blogspot.de/search/label/linear%20algebra

let A =
matrix [ [ 1.0; 7.0; 2.0 ]
[ 1.0; 3.0; 1.0 ]
[ 2.0; 9.0; 1.0 ] ]

let B =
matrix [ [ 10.0; 70.0; 20.0 ]
[ 10.0; 30.0; 10.0 ]
[ 20.0; 90.0; 10.0 ] ]


let v =
vector [|2.0; 20.0; 1.|]


let rv =
rowvec [|2.0; 20.0; 1.|]



A+B
A-B
A*B // matrix product
A.*B // element-wise product
A * 2.0 // scalar product
2.0 * A // this is also ok
-A // negation of a matrix

// matrix-vector product
A * v

Matrix.dot A B



// F# Numerics Interface
// http://fdatamining.blogspot.de/2010/03/f-inumerics-interface-and-matrix-class.html


// Service Provider model pattern
//
// http://blog.ploeh.dk/2011/04/27/Providerisnotapattern/
// http://blog.ploeh.dk/2011/04/27/Providerisnotapattern/
2 changes: 1 addition & 1 deletion src/FSharp.Stats/Algebra/Matrix.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2554,7 +2554,7 @@ namespace Microsoft.FSharp.Math
member x.ToArray() = RowVector.Generic.toArray x
member x.Copy () = RowVector.Generic.copy x


[<AutoOpen>]
module MatrixTopLevelOperators =

let matrix ll = Matrix.ofSeq ll
Expand Down

0 comments on commit 1b7fce7

Please sign in to comment.