Mathematica 9 is now available
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.
Mathematica > Mathematics and Algorithms > Matrices and Linear Algebra > Constructing Matrices >

ConstantArray

Updated In 7 Graphic
ConstantArray[c, n]
generates a list of n copies of the element c.
ConstantArray[c, {n1, n2, ...}]
generates an n_1xn_2x... array of nested lists containing copies of the element c.
Make a vector of 10 c's:
Make a 3×4 array of c's:
Make a vector of 10 c's:
In[1]:=
Click for copyable input
Out[1]=
 
Make a 3×4 array of c's:
In[1]:=
Click for copyable input
Out[1]=
A machine-zero vector:
A vector of exact zeros:
A machine-zero matrix:
A matrix of exact zeros:
A vector of ones:
A machine-number vector of ones:
A deeply nested constant array:
Set up an array to use as storage in a program:
Numerically solve x'[t]Equal1/(t+x[t]^2) using Euler's method:
Find the sum of the elements in a list:
This can also be done with Total:
Use a vector of ones to see the effects of conditioning on the solution of a linear system:
The solution at machine precision has significant errors:
At higher precision, the solution is much better:
ConstantArray[c, dims] has Dimensions[dims]:
ConstantArray[c, dims] is equal to SparseArray[{}, dims, c]:
Normal[s] is identical to ConstantArray[c, dims]:
ConstantArray[c, dims] is equivalent to Apply[Table[c, ##]&, Map[List, dims]]:
New in 6 | Last modified in 7
Ask a question about this page  |  Suggest an improvement  |  Leave a message for the team