MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

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

  • To: mathgroup at smc.vnet.net
  • Subject: [mg114840] Re: How can I perform Matrix comparison?Can any one with kindness help
  • From: Bill Rowe <readnews at sbcglobal.net>
  • Date: Sun, 19 Dec 2010 05:11:12 -0500 (EST)

On 12/17/10 at 11:48 PM, readnews at sbcglobal.net (Bill Rowe) wrote:

>On 12/17/10 at 3:29 AM, fmingu at 163.com (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. 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?

>The result of a>b isn't defined in Mathematics when a and b are
>matrices. So, it should be no surprise there isn't a built in
>function or package to do this comparison. But there are a number of
>ways to achieve the desired result. For example:

>In[7]:= And @@ Flatten@Map[Less, Transpose[{a, b}, {1, 3, 2}], {2}]

>Out[7]= True

>or

>In[8]:= And @@ (Greater @@@ Transpose[Flatten /@ {a, b}])

>Out[8]= True

After looking at this again, I realized the Transpose operation
above isn't arranging the elements in a manner to compare
elements of a with elements of b as intended. So, here is
another simple approach:

In[12]:= Total[Sign[a - b], 2] == Times @@ Dimensions[a]

Out[12]= True



  • Prev by Date: Re: Entering full names (without replacement) in the front end
  • Next by Date: Shift-Ctrl-N and Manipulate
  • Previous by thread: Re: How can I perform Matrix comparison?Can any one with kindness help
  • Next by thread: Wolfram Library Archive - kaput?