Wolfram ResearchPRODUCTSPURCHASEFOR USERSCOMPANYOUR SITES
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.
Previous section-----Next section

3.7.3 Scalars, Vectors and Matrices

Mathematica represents matrices and vectors using lists. Anything that is not a list Mathematica considers as a scalar.

A vector in Mathematica consists of a list of scalars. A matrix consists of a list of vectors, representing each of its rows. In order to be a valid matrix, all the rows must be the same length, so that the elements of the matrix effectively form a rectangular array.

VectorQ[expr] give True if expr has the form of a vector, and False otherwise
MatrixQ[expr] give True if expr has the form of a matrix, and False otherwise
Dimensions[expr] a list of the dimensions of a vector or matrix

Functions for testing the structure of vectors and matrices.
The list {a, b, c} has the form of a vector.

In[1]:=  VectorQ[ {a, b, c} ]

Out[1]=

Anything that is not manifestly a list is treated as a scalar, so applying VectorQ gives False.

In[2]:=  VectorQ[ x + y ]

Out[2]=

This is a  matrix.

In[3]:=  Dimensions[ {{a, b, c}, {ap, bp, cp}} ]

Out[3]=

For a vector, Dimensions gives a list with a single element equal to the result from Length.

In[4]:=  Dimensions[ {a, b, c} ]

Out[4]=

This object does not count as a matrix because its rows are of different lengths.

In[5]:=  MatrixQ[ {{a, b, c}, {ap, bp}} ]

Out[5]=


Any questions about topics on this page? Click here to get an individual response.Buy NowFree TrialMore Information



 © 2009 Wolfram Research, Inc.  Terms of Use  Privacy Policy |
Sign up for our newsletter: