You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, I know you guys have a vec function that essentially works like this
vec(a::AbstractArray) = reshape(a,length(a))
vec(a::AbstractVector) = a
I find myself having to write an hvec function to create horizontal vectors out of arrays for convenience.
hvec(x::AbstractArray) = reshape(x, 1, :)
Using something like vec(x)' only works if x is numeric. When trying to broadcast an operation to operate on every pair of elements in x and y to form a matrix, it's very helpful to be able to quickly construct a vertical vector for x and a horizontal one for y.
M = some_scalar_operation.( vec(x), hvec(y) )
Do you think it would be reasonable to put hvec into base or make vec(x)' work for vectors of all types?
The text was updated successfully, but these errors were encountered:
Hello, I know you guys have a vec function that essentially works like this
vec(a::AbstractArray) = reshape(a,length(a))
vec(a::AbstractVector) = a
I find myself having to write an hvec function to create horizontal vectors out of arrays for convenience.
hvec(x::AbstractArray) = reshape(x, 1, :)
Using something like vec(x)' only works if x is numeric. When trying to broadcast an operation to operate on every pair of elements in x and y to form a matrix, it's very helpful to be able to quickly construct a vertical vector for x and a horizontal one for y.
M = some_scalar_operation.( vec(x), hvec(y) )
Do you think it would be reasonable to put hvec into base or make vec(x)' work for vectors of all types?
The text was updated successfully, but these errors were encountered: