MathGroup Archive 2009

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

Search the Archive

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


f[m : {{_Real ..} ..} /; 
   Length[Dimensions[m]] == 2 \[And] 
    Equal @@ 
     Dimensions[m]] := "You have entered a real square matrix."

f[{{1, 2}, {3, 4}} // N]

f[{{1, 2}, {3, 4, 5}} // N]

f[{{1, 2}, {3, 4}}]


David Park
djmpark at comcast.net
http://home.comcast.net/~djmpark/  


From: sagrailo at gmail.com [mailto: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: ListContourPlot3D
  • Next by Date: Re: how to build pattern for a square matrix of reals?
  • Previous by thread: Re: how to build pattern for a square matrix of reals?
  • Next by thread: Re: how to build pattern for a square matrix of reals?