![]() One is not necessarily better than the other. ![]() There are different traditions of teaching this stuff. So it's not quite accurate to say that this is "not kosher". simply identifies the ith value of vector k. RR5 RS750:150:3600 for i1:length(RS) k(i)RR.RS(i) end am i not supposed to get the answer k(i) in the form of matrix. ![]() When I studied linear algebra, we started with vectors, not "row vectors" and "column vectors", and I didn't find it confusing. Learn more about matrix multiplication with constant. I believe most of these people come from MATLAB or MATLAB-inspired software which typically doesn't support vectors at all, only row and column matrices. This is all unnecessary complication in Mathematica, which does support proper 1D vectors, as well as N-D tensors. On Mathematica.SE I regularly see people trying to use "row vectors" and "column vectors" and a lot of transposision and complex indexing to try to do simple tasks. I find this implementation much more logical and consistent than what I see in rigidly matrix based systems like MATLAB, which don't even support vectors. Correspondingly, Dot does tensor contraction, not just matrix multiplication. Mathematica was designed to work with tensors of arbitrary dimensions, not just 2-dimensional matrices. But for beginners, I think it would be good not to have any extra quirks or hurdles for them to get over. 1 Answer Sorted by: 6 You are talking about an outer product. I'm assuming that the different forms of bracketing needed in column vectors versus row vectors have some payoff later in terms of being able to use the Dot function with tensors. It is a good feature that I can use oblong matrices to put all my vertices into, so I won't complain too much about these small difficulties. If I have time, I'll try to develop a linear algebra package that lets me use the time-tested traditional notation, from square brackets, to a space meaning matrix multiplication, to always being able to use traditional matrix and vector layout. Even TraditionalForm, doesn't give the expected, traditional list of vectors in column form. But it would be much easier just to have Mathematica convert row and column vectors to lists when they're passed to ParametricPlot, etc.Īlso, couldn't matrices be threaded over lists of vectors, instead of requiring the clutter of mapping the dot-product?Īnd why doesn't MatrixForm applied to the result give me the expected list of matrices, in standard layout. I've figured out that I can just add in a substitution rule to do that, so I guess that's not too much to ask. As such, your function would be simplified to: function C lab11 (mat, vec) rows size (mat, 1) vecmat repmat (vec, rows, 1) C mat. You can do this stacking by using repmat which repeats a vector or matrices a given number of times in any dimension (s) you want. ![]() There are more than three files.One main wish: Anywhere we have what is a vector argument to a function, we should be able to type it as a row or column vector. If you dont need C explicitly - like for iterative solvers - you can define an abstract linear operator that returns the vectorized product Cx. After this, you can do element-by-element multiplication. | Options | C (loop) | Fortran (intrinsic) | Fortran (loop)| I’m curious if anybody has thoughts on the analysis I did - are there other options I should try, other circumstances in which the matmuls are occurring, something I overlooked? Thanks! _summary.md Here I compared the effect of different compiler optimizations in both Fortran and C for a program that multiplies a matrix with a vector. Multiplying vectors through a for loop in Matlab. I compared with both Fortran and C, and got essentially the same top speed but Fortran’s matmul intrinsic was much faster with no optimization turned on (and interestingly gets slowed way down by -O3). Matlab: How to multiply sub vectors of two larger vectors 0. Hi, I’m looking at the impact of different compiler options on the speed of vector matrix multiplication.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |