@@ -251,6 +251,10 @@ module Vector =
251
251
252
252
let inline apply ( f : Vector < 'a -> 'b , 'n >) ( v : Vector < 'a , 'n >) : Vector < 'b , 'n > = map2 id f v
253
253
254
+ [<MethodImpl( MethodImplOptions.AggressiveInlining) >]
255
+ let join ( vv : Vector < Vector < 'a , 'n >, 'n >): Vector < 'a , 'n > =
256
+ { Items = Array.init ( Array.length vv.Items) ( fun i -> vv.Items.[ i]. Items.[ i]) }
257
+
254
258
let inline norm ( v : Vector < ^a , ^n >) : ^a =
255
259
v |> toArray |> Array.sumBy ( fun x -> x * x) |> sqrt
256
260
let inline maximumNorm ( v : Vector < ^a , ^n >) : ^a =
@@ -327,6 +331,14 @@ module Matrix =
327
331
for j = 0 to Array2D.length2 m1.Items - 1 do
328
332
f i j m1.Items.[ i, j] m2.Items.[ i, j]
329
333
334
+ let inline apply ( f : Matrix < 'a -> 'b , 'm , 'n >) ( m : Matrix < 'a , 'm , 'n >) : Matrix < 'b , 'm , 'n > = map2 id f m
335
+
336
+ [<MethodImpl( MethodImplOptions.AggressiveInlining) >]
337
+ let join ( m : Matrix < Matrix < 'a , 'm , 'n >, 'm , 'n >) : Matrix < 'a , 'm , 'n > =
338
+ { Items =
339
+ Array2D.init ( Array2D.length1 m.Items) ( Array2D.length2 m.Items)
340
+ ( fun i j -> m.Items.[ i, j]. Items.[ i, j] ) }
341
+
330
342
let inline rowLength ( _ : Matrix < 'a , 'm , 'n >) : 'm = Singleton< 'm>
331
343
let inline colLength ( _ : Matrix < 'a , 'm , 'n >) : 'n = Singleton< 'n>
332
344
let inline rowLength ' ( _ : Matrix < 'a , ^m , 'n >) : int = RuntimeValue ( Singleton< ^m >)
@@ -571,8 +583,9 @@ type Matrix<'Item, 'Row, 'Column> with
571
583
572
584
static member inline Return ( x : 'x ) : Matrix < 'x , 'm , 'n > = Matrix.replicate Singleton Singleton x
573
585
static member inline Pure ( x : 'x ) : Matrix < 'x , 'm , 'n > = Matrix.replicate Singleton Singleton x
574
- static member inline ( <*> ) ( f : Matrix < 'x -> 'y , 'm , 'n >, x : Matrix < 'x , 'm , 'n >) = Matrix.map2 id f x
575
- static member inline ( <.> ) ( f : Matrix < 'x -> 'y , 'm , 'n >, x : Matrix < 'x , 'm , 'n >) = Matrix.map2 id f x
586
+ static member inline ( <*> ) ( f : Matrix < 'x -> 'y , 'm , 'n >, x : Matrix < 'x , 'm , 'n >) = Matrix.apply f x
587
+ static member inline ( <.> ) ( f : Matrix < 'x -> 'y , 'm , 'n >, x : Matrix < 'x , 'm , 'n >) = Matrix.apply f x
588
+ static member inline Join ( x : Matrix < Matrix < 'x , 'm , 'n >, 'm , 'n >) = Matrix.join x
576
589
static member inline get_Zero () : Matrix < 'a , 'm , 'n > = Matrix.zero
577
590
static member inline ( + ) ( m1 , m2 ) = Matrix.map2 (+) m1 m2
578
591
static member inline ( - ) ( m1 , m2 ) = Matrix.map2 (-) m1 m2
@@ -607,6 +620,7 @@ type Vector<'Item, 'Length> with
607
620
static member inline Pure ( x : 'x ) : Vector < 'x , 'n > = Vector.replicate Singleton x
608
621
static member inline ( <*> ) ( f : Vector < 'x -> 'y , 'n >, x : Vector < 'x , 'n >) : Vector < 'y , 'n > = Vector.apply f x
609
622
static member inline ( <.> ) ( f : Vector < 'x -> 'y , 'n >, x : Vector < 'x , 'n >) : Vector < 'y , 'n > = Vector.apply f x
623
+ static member inline Join ( x : Vector < Vector < 'x , 'n >, 'n >) : Vector < 'x , 'n > = Vector.join x
610
624
611
625
[<EditorBrowsable( EditorBrowsableState.Never) >]
612
626
static member inline Zip ( x , y ) = Vector.zip x y
0 commit comments