Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Joe Riel Newsgroups: comp.soft-sys.math.maple Subject: Re: Test for Matrix type Date: Fri, 23 Sep 2011 07:45:17 -0700 Organization: A noiseless patient Spider Lines: 39 Message-ID: <87fwjn2u82.fsf@san.rr.com> References: <9e32joFto3U1@mid.individual.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx04.eternal-september.org; posting-host="7daQ3AF9ALJlnU9jGWSG5Q"; logging-data="15449"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18j3HT9Shjuj7SvhPZfeZct" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) Cancel-Lock: sha1:SHUybXfNdWg3I4mMGZ4GkUnSKbY= sha1:OpKhemy8h7HuhDOlqn2jo6Fdy84= Xref: x330-a1.tempe.blueboxinc.net comp.soft-sys.math.maple:248 rouben@shady.(none) (Rouben Rostamian) writes: > In article <9e32joFto3U1@mid.individual.net>, > Rainer Rosenthal wrote: >>restart: >>with(LinearAlgebra): >>A := Matrix([[1,2],[3,4]]); >>if type(A,integer) then >> print("I'd be suprised"); >>else >> print("I thought so."); >>fi; >>if type(A,MatrixType) then >> print("I'd be glad"); >>else >> print("Oops, why not?"); >>fi; >> >>Is there a nice substitute for "MatrixType"? > > Yes, try "Matrix", as in: > > if type(A,Matrix) then > print("I'd be glad"); > else > print("Oops, why not?"); > fi; For the first conditional, use the following form (see ?type,Matrix): if type(A,'Matrix(integer)') then print("I'd be suprised"); else print("I thought so."); fi; "I'd be surprised" -- Joe Riel