views:

108

answers:

3

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

+3  A: 

The matrix A with all the elements negated.

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

Edit: here's the source from 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
Grandpa
Let's say we have a matrix such that:A=| 1 2 || 3 4 |Is -A =| -1 -2 || -3 -4 |?
Ahmet Alp Balkan
Yes, since A + (-A) == 0.
Grandpa
But (| 1 2 |\n| 3 4 |))+ |-1 -2 |\n|-3 -4 |) is not 0 ? (\n=newline)
Ahmet Alp Balkan
Maybe I'm getting confused by your formatting, but I think it is...
Grandpa
the point is that 0 = | 0 0| \n | 0 0|
Brian Postow
+1  A: 

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

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

tom greene
+1  A: 

"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.

Paul