Re: How can I perform Matrix comparison? Can any one with kindness help

• To: mathgroup at smc.vnet.net
• Subject: [mg114808] Re: How can I perform Matrix comparison? Can any one with kindness help
• From: "Nasser M. Abbasi" <nma at 12000.org>
• Date: Fri, 17 Dec 2010 06:21:47 -0500 (EST)

```On 12/17/2010 12:29 AM, fmingu wrote:
> I am using mathematica for practical purpose.
> I wonder how can I perform Matrix comparison.
> For instance:
> a={{2,3},{4,5}}; b={{1,2},{2,3}};
> a>b
> I want the result is True.

Based on what definition?

Mathematica uses ">" for numbers, but you have a matrices to compare.

> But it seems that Mathematica can not recognize it.
> I do not know how I can solve it? Are there any additional package to be added?
> Can any one with kindness help me?

Normally one uses a matrix norm to compare matrices, but if
you use element by element compare, you can use
Map or Thread of one of those functions to compare
corresponding elements.

But one way I've done this before is by making a
list of the corresponding elements of each matrix, then
Map the operator on them. Using your example:

lis=Inner[List,Flatten[a],Flatten[b],List]

{{2,1},{3,2},{4,2},{5,3}}

Map[Greater,lis]

{True,True,True,True}

There is I am sure a shorter way to do this without even
making a list first.

--Nasser

```

• Prev by Date: Entering full names (without replacement) in the front end
• Next by Date: Re: Obtaining information about function definitions
• Previous by thread: Re: Entering full names (without replacement) in the front end
• Next by thread: Re: How can I perform Matrix comparison? Can any one with kindness help