5.2 Matrix arithmetic operators
Stan supports the basic matrix operations using infix, prefix and postfix operations. This section lists the operations supported by Stan along with their argument and result types.
5.2.1 Negation prefix operators
vector
operator-
(vector x)
The negation of the vector x.
row_vector
operator-
(row_vector x)
The negation of the row vector x.
matrix
operator-
(matrix x)
The negation of the matrix x.
5.2.2 Infix matrix operators
vector
operator+
(vector x, vector y)
The sum of the vectors x and y.
row_vector
operator+
(row_vector x, row_vector y)
The sum of the row vectors x and y.
matrix
operator+
(matrix x, matrix y)
The sum of the matrices x and y
vector
operator-
(vector x, vector y)
The difference between the vectors x and y.
row_vector
operator-
(row_vector x, row_vector y)
The difference between the row vectors x and y
matrix
operator-
(matrix x, matrix y)
The difference between the matrices x and y
vector
operator*
(real x, vector y)
The product of the scalar x and vector y
row_vector
operator*
(real x, row_vector y)
The product of the scalar x and the row vector y
matrix
operator*
(real x, matrix y)
The product of the scalar x and the matrix y
vector
operator*
(vector x, real y)
The product of the scalar y and vector x
matrix
operator*
(vector x, row_vector y)
The product of the vector x and row vector y
row_vector
operator*
(row_vector x, real y)
The product of the scalar y and row vector x
real
operator*
(row_vector x, vector y)
The product of the row vector x and vector y
row_vector
operator*
(row_vector x, matrix y)
The product of the row vector x and matrix y
matrix
operator*
(matrix x, real y)
The product of the scalar y and matrix x
vector
operator*
(matrix x, vector y)
The product of the matrix x and vector y
matrix
operator*
(matrix x, matrix y)
The product of the matrices x and y
5.2.3 Broadcast infix operators
vector
operator+
(vector x, real y)
The result of adding y to every entry in the vector x
vector
operator+
(real x, vector y)
The result of adding x to every entry in the vector y
row_vector
operator+
(row_vector x, real y)
The result of adding y to every entry in the row vector x
row_vector
operator+
(real x, row_vector y)
The result of adding x to every entry in the row vector y
matrix
operator+
(matrix x, real y)
The result of adding y to every entry in the matrix x
matrix
operator+
(real x, matrix y)
The result of adding x to every entry in the matrix y
vector
operator-
(vector x, real y)
The result of subtracting y from every entry in the vector x
vector
operator-
(real x, vector y)
The result of adding x to every entry in the negation of the vector y
row_vector
operator-
(row_vector x, real y)
The result of subtracting y from every entry in the row vector x
row_vector
operator-
(real x, row_vector y)
The result of adding x to every entry in the negation of the row
vector y
matrix
operator-
(matrix x, real y)
The result of subtracting y from every entry in the matrix x
matrix
operator-
(real x, matrix y)
The result of adding x to every entry in negation of the matrix y
vector
operator/
(vector x, real y)
The result of dividing each entry in the vector x by y
row_vector
operator/
(row_vector x, real y)
The result of dividing each entry in the row vector x by y
matrix
operator/
(matrix x, real y)
The result of dividing each entry in the matrix x by y