Re: how to build pattern for a square matrix of reals?
- To: mathgroup at smc.vnet.net
- Subject: [mg98401] Re: how to build pattern for a square matrix of reals?
- From: dh <dh at metrohm.com>
- Date: Thu, 9 Apr 2009 05:52:23 -0400 (EDT)
- References: <grhp95$mj7$1@smc.vnet.net>
Hi, you are nearly there. PatternTest (?) takes a function, therefore, you must write a"&": Clear[f]; f[x_?(MatrixQ [#] && Equal @@ Dimensions[#] & )] := Print["Matrix seen"]; Daniel sagrailo at gmail.com wrote: > 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. >