1

What is the difference between integer valued and real valued vectors, in the mathematics and programming senses?

For example, since certain binary operations on vectors, such as "angleBetween()" return a real, does that mean that the type of integer valued vectors is somehow smaller than the type of real valued vectors? I'm looking for a formal discussion of how these types differ.

I see that the programming language R (or S) defines an integer vector type.

Willie Wong
  • 73,139
bootchk
  • 111
  • 1
    No computer can handle $\mathbb{R}$ (except symbolically, but I don't think that's what you're asking). Don't confuse floating point numbers with real numbers; every number on a computer has finitely many digits, and so is in $\mathbb{Q}$. Check out "What every computer scientist should know about floating point arithmetic" at http://www.validlab.com/goldberg/paper.pdf‎ – Eric Tressler Jul 04 '13 at 13:27
  • No computer can handle I either, but Python with infinite precision numbers comes close. But no, I'm asking a question about abstract data types: is there any method that distinguishes real from integer vectors. For example, you could still define a length() method that returned manhattan length (still in the integer domain.) – bootchk Jul 04 '13 at 16:32

2 Answers2

1

While real-valued vectors of some fixed length form a vector space over the field of real numbers, the integer-valued "vectors" (or tuples) form a $\mathbb{Z}$-module or (equivalently) abelian group.

The notion of a module over a ring is a generalization of the vector space concept. As such we lose some of the nice properties of vector spaces, and in particular "dimension" of a vector space can only partially be extended to the setting of modules.

Another topic which is closely related to this generalization is that of linear transformations (for vectors spaces) versus module homomorphisms. When your specific construction is used (tuples of integers), you get something that is naturally embedded in a vector space and which geometrically is "flat" in the sense of its embedding. The more general $\mathbb{Z}$-module or abelian group will have "wrap around" or torsion components. In any case your construction gives a free $\mathbb{Z}$-module, for which a nice notion of rank (agreeing with the length of "vectors") exists, and which is related to homomorphisms of the free $\mathbb{Z}$-module into itself by the structure theorem for finitely generated modules over a principal ideal domain.

A more specialized context for these integer-valued "vectors" is an integer lattice, which should give you another way to research information about these constructions.

hardmath
  • 37,015
0

From a programming perspective, the difference between vectors of integers and vectors of floating point numbers is very much the same as the difference between integers and floating point numbers.

Integers are very easy for computers to handle; numbers involving decimals less so. If you were to dig under the hood of your favorite programming language, you'd find that even the most basic operations (addition/subtraction/multiplication/etc.) are handled differently for the two types - they are even stored differently in memory.

In a theoretical context, there is still a massive amount of difference between vectors of integers and vectors of reals. For instance, vectors of integers don't form a vector space - because they are not closed under scalar multiplication by elements in $\mathbb{R}$ (or $\mathbb{C}$). Further, there is a very real sense in which there are "fewer" vectors of integers: even though bouth $\mathbb{Z}$ and $\mathbb{R}$ are infinite, $\mathbb{Z}$ is countably infinite whereas $\mathbb{R}$ is uncountably infinite. The same can be said of $\mathbb{Z}^n$ vs $\mathbb{R}^n$.

Nick Peterson
  • 32,430
  • Reading vector spaces doesn't say a vector space must include multiplication by scalars outside the domain. Aren't integer vectors closed under multiplication by integer scalars? – bootchk Jul 04 '13 at 16:24
  • 1
    The scalars are generally required to be a field. This is true for a lot of reasons; one of the primary ones is to give the idea of the dimension of a vector space as an invariant. So, you could (for instance) define a vector field where your scalars are the rationals... but not the integers. – Nick Peterson Jul 04 '13 at 16:27
  • @bootchk See, for instance, this similar question. – Nick Peterson Jul 04 '13 at 16:27
  • Thanks, I didn't read carefully enough. The wiki link does say "generally required to be a field" and if I follow the link to field, a field includes a multiplicative inverse (division) which integers are not closed on. (But why "generally" instead of "always?") (And I also need to study why I should care about dimension as an invariant, and read about modules over rings, as also mentioned by another answer.) Is there a good book about abstract algebra or type or module theory (?) that leans toward object oriented programming? – bootchk Jul 05 '13 at 12:46
  • My application is bitmap tracing, using integer vectors, and for those only need the cross product operator, which only requires scalar subtraction and multiplication. I am curious about the class hierarchies in libraries, why an integer vector class might not be defined, or might not have a cross product defined. – bootchk Jul 05 '13 at 12:58