🔒 Locked
🎮 Unity
matrix manipulation
Advertisement
Original Post
hi everyone, I have a vector u=(x y z) and I would like to transform it (by some linear manipulations) into the following matrix: (x 0 0) (0 y 0) (0 0 z) in matlab notation: [x 0 0; 0 y 0; 0 0 z] Concretely I would like to find some matrices A and B, for example, such that: [x 0 0; 0 y 0; 0 z 0]=A*[x y z]*B I know that there exists the function diag() in matlab but I would like to use some linear relations to build such a matrix. Is there somebody that could help me? Thank you very much JC
well, as you know, using some loops "for" is time consuming. At the contrary, if you use some dedicated optimized matrix manipulation algorithms, you can manipulate and create your matrices much more quickly (in execution time point of view). I am trying to develop such libraries to deal with my complex physic model more simply!
Edit: Nothing to see here.
Quote:
Original post by jyk Quote:I don't think this is what the OP is looking for (the product of a 3x3 matrix and a 3x1 matrix is a 3x1 matrix, not a 3x3 matrix).
Original post by Driv3MeFar [ 1 0 0 ] [ x ] [ x 0 0 ][ 0 1 0 ] x [ y ] = [ 0 y 0 ][ 0 0 1 ] [ z ] [ 0 0 z ]
Haha, oops. You're right, of course.
I fiddled around with this for a little bit and I'm starting to think it might not be possible. If you have a 3x1 or a 1x3 then you'll need a 1x3 or 3x1 respectively so you can get it to be a 3x3. assuming you'll use [1 1 1] you'll end up with something like:
From there I'm stumped. It appears that you'd need to be able to do the same multiplication and get different answers. Perhaps I am missing something though....This would be trivial if you used a third rank tensor...
[x x x] [x y z][y y y] or [x y z] depending on whether you use row or column vectors[z z z] [x y z]From there I'm stumped. It appears that you'd need to be able to do the same multiplication and get different answers. Perhaps I am missing something though....This would be trivial if you used a third rank tensor...
Quote:
Original post by Alrecenk
Perhaps I am missing something though....This would be trivial if you used a third rank tensor...
Or just copy Vectori to Matrixi, i, and fill the rest with zeros.
Why try for something complicated when there's a simple, well-known, O(n2) algorithm.
Quote:
Original post by Anthony Serrano Quote:
Original post by Alrecenk
Perhaps I am missing something though....This would be trivial if you used a third rank tensor...
Or just copy Vectori to Matrixi, i, and fill the rest with zeros.
Why try for something complicated when there's a simple, well-known, O(n2) algorithm.
That's also going to be a lot faster than any series of linear transforms due to lack of multiplications.
Quote:
Original post by Alrecenk
I fiddled around with this for a little bit and I'm starting to think it might not be possible. If you have a 3x1 or a 1x3 then you'll need a 1x3 or 3x1 respectively so you can get it to be a 3x3. assuming you'll use [1 1 1] you'll end up with something like:
*** Source Snippet Removed ***
From there I'm stumped. It appears that you'd need to be able to do the same multiplication and get different answers. Perhaps I am missing something though....This would be trivial if you used a third rank tensor...
what would be the advantage of a third rank tensor? I habe no idea what it is^^
I hope you can help me
A 3x3x3 tensor would contain enough values to define every element of the matrix as a linear combination of every element of the vector. However, I really meant that as a joke as it would require 27 multiplications and 18 additions, and you could do what your doing without any multiplications or additions.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement