Re: how to build pattern for a square matrix of reals?

• To: mathgroup at smc.vnet.net
• Subject: [mg98402] Re: [mg98379] how to build pattern for a square matrix of reals?
• Date: Thu, 9 Apr 2009 05:52:34 -0400 (EDT)
• References: <200904080903.FAA23145@smc.vnet.net>

```Add an ampersand and a couple of parentheses:

In[1]:= f[(m_)?(MatrixQ[#1, NumericQ] && SameQ @@ Dimensions[#1] & )] :=
"Good!"

In[2]:= f[RandomReal[{-1, 1}, {2, 2}]]
Out[2]= "Good!"

In[3]:= f[RandomReal[{-1, 1}, {2, 3}]]
Out[3]= f[{{0.7458917724579508, -0.9549183202849245, 0.010947478301726044},
{-0.14117283873516007, 0.6198728660624302, 0.07598523139890823}}]

2009/4/8 <sagrailo at gmail.com>

> As in subject: how to build a pattern that will specify that given
> argument of a function has to be square matrix of reals?  Tried with
> following for "square matrix" part:
>  f[x_?MatrixQ[#] && Dimensions[#][[1]] == Dimensions[#][[2]]
> &] := ...
> but it doesn't seem to be working...
>
> Thanks.
>

```

• Prev by Date: Re: how to build pattern for a square matrix of reals?
• Next by Date: Re: Enlarging figure size by Mathematica
• Previous by thread: how to build pattern for a square matrix of reals?
• Next by thread: Re: how to build pattern for a square matrix of reals?