11
$\begingroup$

I'm from Brazil and I'm involved with programming language teaching for, at least, ten years. I have a background in computer science and my colleagues tend to use the term vector to describe an array in programming languages like C or Java. I particularly HATE this use of the therm vector, since vectors and matrices are mathematical entities that can be added, multiplied and so on, while arrays and multidimensional arrays can't. I know that there are languages that these constructs exists, like MATLAB, but they don't exists natively in the most used general purpose programming languages. In Java there is an data structure called Vector, that is, in fact, a synchronized list that can't be added, for exaxmple. C++ also has a vector data structure/container in STL that is a list too and is not a mathematical vector.

I always explain this for my students, that some people call arrays as vectors and multidimensional arrays as matrices and that this is kinda wrong. I tell them that an array can be used to represent a vector, but that it is not a vector! The same for matrices.

I would like to know what do you think about it! Do you think that is correct or not to call arrays as vectors? If so, why? Is this "missconception" common in your country?

EDIT

I'm sorry if I sounded pedantic. My confusion was introduced by one of my professors during my undergraduate course. He was a mathematician/physicist working with computer science. Maybe this was the reason. I will correct it now, thank you!

$\endgroup$
5
  • 4
    $\begingroup$ Pedantry FTW! I've been "doing" computers for almost forty years (got my CS degree 34 years ago) and never heard them called vectors and matrices. Of course, I've used them as vectors and matrices when having to program mathematical functions like matrix manipulation. In that case, though, I'd "load the matrix into a 2D array". $\endgroup$
    – RonJohn
    Jul 5, 2019 at 2:25
  • $\begingroup$ @RonJohn I think like you! Tks! $\endgroup$ Jul 5, 2019 at 13:55
  • 1
    $\begingroup$ Just to be a tad pedantic myself (and maybe give you another way to think about it).. Doesn't a mathematician call a bunch of scribbled numbers with brackets around them a vector? It's just a list of numbers--it cannot be added, multiplied or operated upon without some external routines that are currently in your head. Couldn't the same thing be said of an array? It has the same properties of that thing you put on paper--a list of numbers with the potential to be operated upon. You can totally add two vectors in a computer--just supply the subroutine. $\endgroup$
    – Bill K
    Jul 5, 2019 at 17:58
  • $\begingroup$ Welcome to CS Educators Stack Exchange! I hope we see more of you. $\endgroup$ Jul 7, 2019 at 14:20
  • $\begingroup$ "vectors and matrices are mathematical entities that can be added, multiplied and so on, while arrays and multidimensional arrays can't" while this may have some theoretical support, the practice is entirely different with hugely popular libraries for sciences like numpy bringing up arrays as mathematical vectors. If students come out of your class with this rigid definition, they will be very confused. $\endgroup$
    – lucasgcb
    Jul 8, 2019 at 12:00

4 Answers 4

8
$\begingroup$

First, see this question on being pedantic. Second, consider the fact that you are teaching Computer Science and not Mathematics. The former is not a subset of the latter. There is some overlap, of course.

Next, I see no issue with being precise about terminology when students might be studying both fields. If you want to clearly distinguish between vector and array, I think that is fine, though you may possibly just be stressing the wrong thing.

Vectors in mathematics are used to understand things. (That is the core of pure math, after all). Arrays, call them what you will, in CS are used to build things that are useful.

But lots of things vary between math and CS. Addition of integers means one thing in math. The fact that it normally means modulo addition (with a fairly large modulus) is seldom stressed initially and is irrelevant for many (not all) purposes. Likewise real values mean quite different things in math and in CS. If you spend too much time on the details of the differences you may not have time for what are, fundamentally, more important issues in novices learning CS.

But, the reason that Matrix isn't a fundamental type in a language like Java is that it isn't needed often enough in the work of professionals to make it part of the infrastructure. You can, of course, build a Matrix class and provide the mathematical operations that might be wanted for some applications, just as Mathematica has done.

But, mathematics is like CS language structure in a lot of ways. In math the Peano axioms are, for example, enough to define the structure of the natural numbers. Other things can be defined and built on top of that structure. Likewise in Java, a Vector of Objects is a (somewhat) simple bit of infrastructure that can be used as the basis of more complicated and useful things. So, in both, one has a simple basis that can be extended for the purpose at hand.

I'll note also, that few general purpose programming languages have anything like a matrix as a primitive. Normally a two dimensional structure is more like an array of arrays (vector of vectors) and so in the second dimension the index limits can vary. But OO languages can, of course, control that and have "true" matrices, though a "row" and a "column" in such a structure are quite different in the implementation. But, again, in mathematics the row and the column are ideas, and in CS they are implementations (built things).

Well... I suppose that any Turing Complete language is "general purpose" in some sense.

$\endgroup$
0
7
$\begingroup$

I believe that the CS notion of a vector is not related to the concept of a vector as a fixed size set of components, and rather comes from the idea of a rank 1 tensor (which is also called a vector). A rank 1 tensor is simply a list of elements that is indexed linearly, so you only need one coordinate to retrieve an element (as opposed to a matrix, which is a rank 2 tensor, which requires two coordinates to locate an element).

Here is a link to Wolfram MathWorld about tensor rank

Also, I think that I'd take some issue with your definition of matricies and vectors as "mathematical entities that can be added, multiplied and so on." Matricies and vectors in mathematics each are defined based on their structures, and from those structures we can define convenient operations/properties such as multiplication, addition, etc. Thus matricies and vectors in CS are both still fundamentally the same as mathematical matricies and vectors because they share the same structure. However (for non-numerical types) they will not have the same properties as we have with numbers in mathematics.

$\endgroup$
7
$\begingroup$

You are correct and incorrect at the same time. Nomenclature is important when teaching, and when programming. Being pedantic about nomenclature is a slipper slope and a morass. As noted by @Buffy in another answer, that's been addressed here as well.

In the case of vector and matrix they have specific meaning, usage, and properties in mathematics. They also have many other meanings, in different fields. (See matrix and vector in Wiktionary.) There is a similar problem with many words used in CS; 'table' (a flat surface for food or work) and 'case' (an enclosure for holding or carrying things) are two examples I can think of.

When teaching something it is important to ensure that the students understand the terms you are using. If they have prior knowledge of some terms from another field, it can help to compare and contrast the usage in CS and the other field. It is also important for the students to understand that what a term means in this field may not be the same, or even close, as the same term in a different field. Unfortunately, mathematics and computer science are very close, often intertwined, and the terms are often very close, and that can make correct usage of nomenclature much harder.

I suppose it becomes even more difficult when the language used in the field is also a foreign language to the students. The key is to correctly use the terms from the field you are working with, even if Java has the data structure Vector which doesn't behave the same as a "vector" in mathematics. The mathematics "vector" also has no correlation to the "vector" which is the carrier of a disease-causing agent. Neither is more correct, nor less so. When used correctly in their field they are understood. When used outside their field, they can be easily confused. Focus on what it means, here and now, in your course, not what it might mean somewhere else. After all, the CS field cannot just create new words for everything merely because all the words are already taken.

$\endgroup$
6
$\begingroup$

When introducing terms that have different meanings in different fields, first, accept that both uses are correct. As others have alluded, this is a case of two different fields using the same term in two different ways based on a similarity to a root idea. Disparaging the use of the language to your students might make them feel worse about the usage, or might make them feel worse about you, but it won't change the accepted term of art in the field, so there is no benefit to your complaint.

Second, don't skip past it. Mention both uses to your class, and remind them that they will need to keep context in mind when they encounter the term in the future, as it has two different accepted meanings.

Hopefully your students, as a result of your instruction, have less confusion than you did. If so, congratulations on a job well done!

$\endgroup$
1
  • $\begingroup$ Thanks! My confusion was introduced by one of my professors during my undergraduate course. He was a mathematician working with computer science. Maybe this was the reason. I will correct it now, thank you! $\endgroup$ Jul 5, 2019 at 0:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.