This is documentation for Mathematica 7, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)

DiamondMatrix

DiamondMatrix[r]
gives a matrix whose elements are 1 in a diamond-shaped region that extends r index positions to each side, and are 0 otherwise.
DiamondMatrix[r, w]
gives a w×w matrix containing a diamond-shaped region of 1s.
DiamondMatrix[{r1, r2, ...}, ...]
yields an array whose elements are 1 in a diamond-shaped region that extends ri index positions in the i^(th) direction.
  • The diamond of 1s is always at the center of the region.
  • The region of 1s is taken to be the best discrete approximation to a diamond-shaped possible given the size of the matrix.
  • DiamondMatrix[All, w] gives a w×w matrix containing a diamond shape that is as large as possible.
  • DiamondMatrix[All, {w1, ..., wn}] gives a w1×...×wn array containing a diamond-shaped region that is as large as possible.
  • The parameter r need not be an integer; in general elements are 1 if their Manhattan distance from the center is not more than |r+1/2|.
This computes and plots a square diamond-shaped matrix of radius 10:
This computes and plots a square diamond-shaped matrix of radius 10:
In[1]:=
Click for copyable input
Out[1]=
Create a rectangular diamond-shaped matrix:
Put a diamond inside a bigger matrix:
Extend the diamond to the boundaries of the matrix:
Automatically choose an odd width to just fit the diamond:
Extend the diamond to the given width, and automatically choose the height:
New in 7