-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Manipulating matrices and vectors of polyvar #139
Comments
Yes, but if you use julia> @polyvar r[1:num, 6];
julia> size(r)
(4,)
julia> @polyvar r[1:num, 1:6];
julia> size(r)
(4, 6) |
Thanks @blegat !
But the final shape is (2,) not (2,3,3) as expected |
You need julia> a = [[1, 2], [3, 4]]
2-element Vector{Vector{Int64}}:
[1, 2]
[3, 4]
julia> hcat(a)
2×1 Matrix{Vector{Int64}}:
[1, 2]
[3, 4]
julia> reduce(hcat, a)
2×2 Matrix{Int64}:
1 3
2 4
julia> reduce(vcat, a)
4-element Vector{Int64}:
1
2
3
4 |
Thanks @blegat I ran into an edge case, potentially where matrix-matrix multiplication is failing. Any insight here?
|
It seems matrix-vec multiplication is supported but matrix-matrix is not.
|
The first matrix has |
Hi,
Thanks for the great library!
I'm wondering how I can operate on matrices or vectors of polynomials. I have tried this:
@polyvar rot_mat_flat_var_original[1:num_internal_bodies, 6]
creating what (I think) should be a (num_internal_bodies, 6) shaped array, but it does not function like matrix or vector.
For example, I cannot call any
length
orsize
after indexing into it and getting a new 'vector' out.More concretely, here is something that works, and something that doesn't.
Works:
The above code successfully converts an array containing lower triangular components, described as:
PolyVar{true}[r1₁, r1₂, r1₃, r1₄, r1₅, r1₆]
, into a symmetric matrix.However, suppose I am storing a bunch of such arrays into this matrix, of shape (n x 6) instead of shape (6,) as before.
Indexing into this matrix does not function as expected. Indexing into this matrix, I would assume, gives me a vector of shape (1, 6) or (6,) that I can input into convertlowertri_tomat(...), but that is not the case.
the above code errors with:
ERROR: LoadError: MethodError: no method matching length(::PolyVar{true})
meaning indexing into the "matrix" does not give me a "vector".
In my mind, a @PolyVar defined with extra dimensions can be treated just like a tensor, to be indexed at will, but this seems not the case.
Any clue how I can fix my code so that I can store a matrix of polyvars, index into its first dimension, and have it work with
convertlowertri_tomat
?Additionally, when I print out
rot_mat_flat_var_original[1]
, it gives this:PolyVar{true}
which does not look like the vector data typePolyVar{true}[r1₁, r1₂, r1₃, r1₄, r1₅, r1₆]
from before.The text was updated successfully, but these errors were encountered: