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: [mg114811] Re: How can I perform Matrix comparison?Can any one with kindness help
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Fri, 17 Dec 2010 23:47:57 -0500 (EST)

Presumably you want

m1 = Array[x, {2, 2}];
m2 = Array[y, {2, 2}];

And @@ Thread[Flatten /@ (m1 > m2)]

x[1, 1] > y[1, 1] && x[1, 2] > y[1, 2] && x[2, 1] > y[2, 1] && 
 x[2, 2] > y[2, 2]

Alternatively,

And @@ (MapThread[Greater, {m1, m2}, 2] // Flatten)

x[1, 1] > y[1, 1] && x[1, 2] > y[1, 2] && x[2, 1] > y[2, 1] && 
 x[2, 2] > y[2, 2]

In your specific case

a = {{2, 3}, {4, 5}};

b = {{1, 2}, {2, 3}};

And @@ Thread[Flatten /@ (a > b)]

True

And @@ (MapThread[Greater, {a, b}, 2] // Flatten)

True


Bob Hanlon

---- fmingu <fmingu at 163.com> 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?




  • Prev by Date: Re: How can I perform Matrix comparison?Can any one with kindness help
  • Next by Date: Re: Problems with Mathematica 8.0 Solve
  • Previous by thread: Re: How can I perform Matrix comparison?Can any one with kindness help
  • Next by thread: Re: How can I perform Matrix comparison?Can any one with kindness help