Question

When we're talking about matrices or a matrix, what does "unary minus" stand for as an arithmetic operator?

Was it helpful?

Solution

The matrix A with all the elements negated.

That way, A + (-A) == 0.

Edit: here's the source from http://math.nist.gov/javanumerics/jama/">JAMA:

/**  Unary minus
@return    -A
 */
public Matrix uminus () {
   Matrix X = new Matrix(m,n);
   double[][] C = X.getArray();
   for (int i = 0; i < m; i++) {
      for (int j = 0; j < n; j++) {
         C[i][j] = -A[i][j];
      }
   }
   return X;
}

Edit 2: if A is

1 2
3 4

then unary minus of A is

-1 -2
-3 -4

OTHER TIPS

If M is your matrix, -M is the new matrix where unary minus has been applied

(-M)[i, j] = - (M [i, j])

"unary minus" for a matrix is an element by element negation as others has said.

More generally, in computer science, a "unary operator" is one that operates on a single operand. Other common examples from C include the '++' or '=*' unary operators.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top