Reputation: 570
Are there any analogs to Matlab's horzcat() and vertcat() functions in F#? Because what I'm doing now seems asinine. There is a related question here but it seems pretty dated.
let arr = Array.init 5 (fun i -> 1.)
let xMat = DenseMatrix.init l 2 (fun r c -> if c = 0 then 1. else arr.[r])
There is an Array.concat but it seems to work only vertically.
Upvotes: 0
Views: 1287
Reputation: 243096
As far as I know, there is no built-in function to do this for F# arrays, but in your code you are ultimately working with matrices from Math.NET Numerics and Math.NET has functions to append matrices vertically and horizontally:
let m1 = DenseMatrix.init 5 1 (fun _ _ -> 1.)
let m2 = DenseMatrix.init 5 1 (fun _ _ -> 2.)
DenseMatrix.append [m1; m2] // Append matrices horizontally
DenseMatrix.stack [m1; m2] // Append matrices vertically
Upvotes: 5