Linear Algebra, row vs col vectors












2












$begingroup$


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 yo express for you guys my knowledge, it might be weak at the moment so an explanation for a retard might be the best.



Thanks!










share|cite|improve this question











$endgroup$








  • 1




    $begingroup$
    Thing is,$$mathbf{M} mathbf{v} = left(mathbf{v}^T mathbf{M}^Tright)^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.
    $endgroup$
    – Nominal Animal
    Dec 30 '18 at 6:51










  • $begingroup$
    @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.
    $endgroup$
    – scaaahu
    Dec 30 '18 at 7:00








  • 1




    $begingroup$
    @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. :)
    $endgroup$
    – Nominal Animal
    Dec 31 '18 at 6:30












  • $begingroup$
    Seems like a duplicate of math.stackexchange.com/q/607741/265466
    $endgroup$
    – amd
    Jan 1 at 7:57
















2












$begingroup$


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 yo express for you guys my knowledge, it might be weak at the moment so an explanation for a retard might be the best.



Thanks!










share|cite|improve this question











$endgroup$








  • 1




    $begingroup$
    Thing is,$$mathbf{M} mathbf{v} = left(mathbf{v}^T mathbf{M}^Tright)^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.
    $endgroup$
    – Nominal Animal
    Dec 30 '18 at 6:51










  • $begingroup$
    @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.
    $endgroup$
    – scaaahu
    Dec 30 '18 at 7:00








  • 1




    $begingroup$
    @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. :)
    $endgroup$
    – Nominal Animal
    Dec 31 '18 at 6:30












  • $begingroup$
    Seems like a duplicate of math.stackexchange.com/q/607741/265466
    $endgroup$
    – amd
    Jan 1 at 7:57














2












2








2


0



$begingroup$


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 yo express for you guys my knowledge, it might be weak at the moment so an explanation for a retard might be the best.



Thanks!










share|cite|improve this question











$endgroup$




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 yo express for you guys my knowledge, it might be weak at the moment so an explanation for a retard might be the best.



Thanks!







linear-algebra matrices vector-spaces vectors






share|cite|improve this question















share|cite|improve this question













share|cite|improve this question




share|cite|improve this question








edited Dec 31 '18 at 10:50









Martin Sleziak

44.9k10122275




44.9k10122275










asked Dec 30 '18 at 5:53









OO1OO1

173




173








  • 1




    $begingroup$
    Thing is,$$mathbf{M} mathbf{v} = left(mathbf{v}^T mathbf{M}^Tright)^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.
    $endgroup$
    – Nominal Animal
    Dec 30 '18 at 6:51










  • $begingroup$
    @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.
    $endgroup$
    – scaaahu
    Dec 30 '18 at 7:00








  • 1




    $begingroup$
    @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. :)
    $endgroup$
    – Nominal Animal
    Dec 31 '18 at 6:30












  • $begingroup$
    Seems like a duplicate of math.stackexchange.com/q/607741/265466
    $endgroup$
    – amd
    Jan 1 at 7:57














  • 1




    $begingroup$
    Thing is,$$mathbf{M} mathbf{v} = left(mathbf{v}^T mathbf{M}^Tright)^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.
    $endgroup$
    – Nominal Animal
    Dec 30 '18 at 6:51










  • $begingroup$
    @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.
    $endgroup$
    – scaaahu
    Dec 30 '18 at 7:00








  • 1




    $begingroup$
    @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. :)
    $endgroup$
    – Nominal Animal
    Dec 31 '18 at 6:30












  • $begingroup$
    Seems like a duplicate of math.stackexchange.com/q/607741/265466
    $endgroup$
    – amd
    Jan 1 at 7:57








1




1




$begingroup$
Thing is,$$mathbf{M} mathbf{v} = left(mathbf{v}^T mathbf{M}^Tright)^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.
$endgroup$
– Nominal Animal
Dec 30 '18 at 6:51




$begingroup$
Thing is,$$mathbf{M} mathbf{v} = left(mathbf{v}^T mathbf{M}^Tright)^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.
$endgroup$
– Nominal Animal
Dec 30 '18 at 6:51












$begingroup$
@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.
$endgroup$
– scaaahu
Dec 30 '18 at 7:00






$begingroup$
@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.
$endgroup$
– scaaahu
Dec 30 '18 at 7:00






1




1




$begingroup$
@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. :)
$endgroup$
– Nominal Animal
Dec 31 '18 at 6:30






$begingroup$
@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. :)
$endgroup$
– Nominal Animal
Dec 31 '18 at 6:30














$begingroup$
Seems like a duplicate of math.stackexchange.com/q/607741/265466
$endgroup$
– amd
Jan 1 at 7:57




$begingroup$
Seems like a duplicate of math.stackexchange.com/q/607741/265466
$endgroup$
– amd
Jan 1 at 7:57










1 Answer
1






active

oldest

votes


















1












$begingroup$


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.






share|cite|improve this answer









$endgroup$













    Your Answer





    StackExchange.ifUsing("editor", function () {
    return StackExchange.using("mathjaxEditing", function () {
    StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
    StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
    });
    });
    }, "mathjax-editing");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "69"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    noCode: true, onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3056541%2flinear-algebra-row-vs-col-vectors%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1












    $begingroup$


    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.






    share|cite|improve this answer









    $endgroup$


















      1












      $begingroup$


      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.






      share|cite|improve this answer









      $endgroup$
















        1












        1








        1





        $begingroup$


        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.






        share|cite|improve this answer









        $endgroup$




        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.







        share|cite|improve this answer












        share|cite|improve this answer



        share|cite|improve this answer










        answered Dec 31 '18 at 6:27









        Nominal AnimalNominal Animal

        7,1232617




        7,1232617






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Mathematics Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            Use MathJax to format equations. MathJax reference.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3056541%2flinear-algebra-row-vs-col-vectors%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Tonle Sap (See)

            I get strange results when I access the Sqlitedatabase with Unity C# via XAMPP

            Guatemaltekische Davis-Cup-Mannschaft