2

Im almost finishing part one of the course such that I know, matrices, transformations, determinants, span, basis, dimensions etc...

I think that I do not fully understand when and why I should organize the vectors in a matrix as rows and when and why as columns. At the beginning we kind of put them as columns to check for linear independent, but then while we reached spans and basis of a space we started put the vectors as a rows to find the basis. But at both scenarios we try to find the vectors that are dependent and to get rid out of them... Then the coordinate vectors appeared and the definition is to organize them as a columns - I kind of think that I understand why as it's because the way to multiply matrices, so if it would be a row you wont able to multiply on the basis vectors. But then again you can turn basis vectors to be as columns and coordinate vector to be as row properties, so I got confused.

For instance is it possible to put the span vectors as col, and do elementary operations on the columns? So the internal col space wont be affected, as I understood this is the reason for find put the span vectors as rows so it won't affect the space.

So im kind of trying to understand and make a rules to my self when I solve questions, whether I should choose this or that.

Sorry for the amount of information I just want to be able to express for you guys my knowledge.

Thanks!

BOB123
  • 105
  • 1
    Thing is,$$\mathbf{M} \mathbf{v} = \left(\mathbf{v}^T \mathbf{M}^T\right)^T$$This means that if you use row vectors, the vector is on the right side of the matrix in matrix-vector multiplication; with column vectors, the vector is on the left side, and the matrix is also transposed. In a very real sense, whether you choose row or column vectors, is arbitrary; as long as you use the same convention throughout. Many texts forget to mention it explicitly, so you need to be careful. – Nominal Animal Dec 30 '18 at 06:51
  • @NominalAnimal I think your comment is kind of an answer. Care to convert it into a formal answer? I think the OP is not the only one who has the problem. I, too, had this issue when I first learned Linear algebra. – Nobody Dec 30 '18 at 07:00
  • 1
    @scaaahu: I've had this issue when I started 3D programming, and I didn't even know linear algebra then; only basic vector algebra, and matrix-vector (right) multiplication. Drove me absolutely bonkers, until I found out that the convention (row or column vectors) varies, and affects the math! That was in the paper-book era, just before Internet, too. Lots of library visits... I'm not sure if my answer answers what OP is asking for, but I wrote what I hope somebody had told me when I was learning the basics of this stuff. :) – Nominal Animal Dec 31 '18 at 06:30
  • Seems like a duplicate of https://math.stackexchange.com/q/607741/265466 – amd Jan 01 '19 at 07:57

1 Answers1

1

I do not fully understand when and why I should organize the vectors in a matrix as rows and when and why as columns.

As long as you use the same logical convention throughout, the choice is arbitrary, because $$\bbox[#ffffef, 1em]{ \mathbf{M} \mathbf{v} = \left( \mathbf{v}^T \mathbf{M}^T \right)^T }$$ That is, if you use column vectors, the vector is on the right and the matrix on the left in matrix-vector multiplication; if you use row vectors, the vector is on the left and the matrix transposed. The result only differs by transpose.

Thus, it is only a matter of convention; mathematically, you can use either one.

Do remember to ensure you use the same convention throughout, however. In most practical use cases, we use math to model phenomena or operations; as a language to describe the problem and the solution we would like to find. If we change the convention midway through, we break the mapping between the model and its mathematical description. Breakage ensues.

However, it is completely okay to switch conventions between problems. In fact, it is a good idea to choose the convention based on the context, and ease of notation.

For example, we do Gaussian elimination as "row reduction", because that yields nice, compact representation using our typical mathematical notation. You can do it transposed, as "column reduction", but the notation will be messier. In fact, if you do need to do column reduction, it is easier to first take the transpose of the matrix, then do row reduction (Gaussian elimination), and transpose the result!


This is a very common issue for programmers learning how to implement 3D transforms and projection using linear algebra. For simplicity and efficiency, 3D coordinates are usually described using homogenous coordinates, with an implicit fourth component always being 1. If we use column vectors, then $$\bbox{ \mathbf{M} = \left [ \begin{matrix} x_x & y_x & z_x & t_x \\ x_y & y_y & z_y & t_y \\ x_z & y_z & z_z & t_z \\ 0 & 0 & 0 & 1 \end{matrix} \right ]}, \quad \bbox{ \vec{v} = \left [ \begin{matrix} x \\ y \\ z \\ 1 \end{matrix} \right ]}, \quad \bbox{ \mathbf{M} \vec{v} = \left [ \begin{matrix} x_x x + y_x y + z_x z + t_x \\ x_y x + y_y y + z_y z + t_y \\ x_z x + y_z y + z_z z + t_z \\ 1 \end{matrix} \right ]}$$ which can be described as a transformation and translation by $$\bbox { \hat{e}_x = \left [ \begin{matrix} x_x \\ x_y \\ x_z \end{matrix} \right ] }, \quad \bbox { \hat{e}_y = \left [ \begin{matrix} y_x \\ y_y \\ y_z \end{matrix} \right ] }, \quad \bbox { \hat{e}_z = \left [ \begin{matrix} z_x \\ z_y \\ z_z \end{matrix} \right ] }, \quad \bbox { \hat{t} = \left [ \begin{matrix} t_x \\ t_y \\ t_z \end{matrix} \right ] }$$ where $x$, $y$, and $z$ axes are transformed to $\hat{e}_x$, $\hat{e}_y$, $\hat{e}_z$, and the result translated by $\hat{t}$.

However, the above applies to column vectors. This convention is common in linear algebra books and tutorials, but for example OpenGL uses row vectors instead. Then, $$\bbox { \vec{v} = \left [ \begin{matrix} x & y & z & 1 \end{matrix} \right ] }, \quad \bbox { \mathbf{M} = \left [ \begin{matrix} x_x & x_y & x_z & 0 \\ y_x & y_y & y_z & 0 \\ z_x & z_y & z_z & 0 \\ t_x & t_y & t_z & 1 \end{matrix} \right ] }, \quad \bbox { \vec{v} \mathbf{M} = \left [ \begin{matrix} x_x x + y_x y + z_x z + t_x & x_y x + y_y y + z_y z + t_y & x_z x + y_z y + z_z z + t_z & 1 \end{matrix} \right ] }$$ Note how these conventions only differ by the transpose: $$\bbox { \begin{aligned} \hat{e}_x &= \left [ \begin{matrix} x_x & x_y & x_z \end{matrix} \right ] \\ \hat{e}_y &= \left [ \begin{matrix} y_x & y_y & y_z \end{matrix} \right ] \\ \hat{e}_z &= \left [ \begin{matrix} z_x & z_y & z_z \end{matrix} \right ] \\ \hat{t} &= \left [ \begin{matrix} t_x & t_y & t_z \end{matrix} \right ] \\ \end{aligned} }$$ The interpretation of the vectors and the matrix stays exactly the same. Only the notation differs (by transpose, and whether vector is to the left or to the right of the matrix in matrix-vector multiplication).


A further tripping point is that the upper left 3×3 part of the transformations (the rotation/reflection part) is very often a pure rotation, and therefore orthonormal: $$\bbox { \begin{aligned} \hat{e}_x \cdot \hat{e}_x &= 1 \\ \hat{e}_y \cdot \hat{e}_y &= 1 \\ \hat{e}_z \cdot \hat{e}_z &= 1 \\ \hat{e}_x \cdot \hat{e}_y &= 0 \\ \hat{e}_x \cdot \hat{e}_z &= 0 \\ \hat{e}_y \cdot \hat{e}_z &= 0 \\ \end{aligned} } \quad \quad \bbox { \begin{aligned} \hat{e}_x \times \hat{e}_y &= \hat{e}_z \\ \hat{e}_y \times \hat{e}_z &= \hat{e}_x \\ \hat{e}_z \times \hat{e}_x &= \hat{e}_y \\ \hat{e}_x \times \hat{e}_z &= -\hat{e}_y \\ \hat{e}_z \times \hat{e}_y &= -\hat{e}_x \\ \hat{e}_y \times \hat{e}_x &= -\hat{e}_z \\ \end{aligned} }$$ In that case, the inverse of that 3×3 matrix is its transpose! In other words, if we have a pure 3×3 rotation matrix $\mathbf{R}$, $$\bbox { \mathbf{R} = \left [ \begin{matrix} x_x & y_x & z_x \\ x_y & y_y & z_y \\ x_z & y_z & z_z \\ \end{matrix} \right ] }, \quad \bbox { \mathbf{R}^{-1} = \mathbf{R}^T = \left [ \begin{matrix} x_x & x_y & x_z \\ y_x & y_y & y_z \\ z_x & z_y & z_z \\ \end{matrix} \right ] }$$ Because of this, if you have a pure rotation transform, and you get the convention (of whether row or column vectors are used) wrong, you get inverse rotations of what you expected.

It is an especially annoying tripping point for programmers, because the first reaction is obviously to suspect a programming error, perhaps a sign inversion.

Even when the transform is not a pure rotation, the basis vectors tend to be orthogonal to each other (their pairwise dot products zero), in which case there is a scaling factor applied to each axis, but otherwise the same applies.