-
Notifications
You must be signed in to change notification settings - Fork 99
/
Copy pathtype-matrix.fsx
74 lines (48 loc) · 1.25 KB
/
type-matrix.fsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
(*** 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.
#r @"../../src/FSharpPlus/bin/Release/net8.0/FSharpPlus.dll"
#r @"../../src/FSharpPlus.TypeLevel/bin/Release/net8.0/FSharpPlus.TypeLevel.dll"
(**
Matrix<'NumType,'Rows,'Cols>
========================================
This is a fixed size matrix of a (typically) numeric type.
Related Tyes
------------
- [Vector](type-vector.html): Similar but for vectors
Abstractions
------------
- [Semigroup](abstraction-semigroup.html)
- [Monoid](abstraction-monoid.html)
- [Functor](abstraction-functor.html)
- [Applicative](abstraction-applicative.html)
Examples
--------
*)
(**
```f#
#r @"nuget: FSharpPlus"
#r @"nuget: FSharpPlus.TypeLevel"
```
*)
open FSharpPlus
open FSharpPlus.Data
let matrix3x4_1 =
matrix (
(1, 0, 0, 0),
(0, 1, 0, 0),
(0, 0, 0, 0)
)
let matrix3x4_2 =
matrix (
(10, 0, 100, 0),
(30, 1, 100, 0),
(60, 0, 100, 0)
)
// Add two matrices
let matrix3x4_sum = matrix3x4_1 + matrix3x4_2
// Add a scalar
let matrix3x4_3 = matrix3x4_1 + result 5
// Another way
open FSharpPlus.Math.Generic
let vector3d_4 = matrix3x4_1 + 5G