How to use error message return values
- To: mathgroup at smc.vnet.net
- Subject: [mg37705] How to use error message return values
- From: "flip" <flip_alpha at safebunch.com>
- Date: Sat, 9 Nov 2002 00:29:10 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
Hello, I have a module which allows a user to definea matrix. This matrix may, of course, have an inverse or not have an inverse. As an example, In[15]:= c = {{5, 17}, {4, 15}}; In[16]:= cinv = Inverse[c, Modulus -> 26] Out[16]= {{17, 5}, {18, 23}} In[17]:= c = {{5, 5}, {5, 5}}; In[18]:= cinv = Inverse[c, Modulus -> 26] Inverse::"sing": "Matrix \!\({\(\({5, 5}\)\), \(\({5, 5}\)\)}\) is singular." Out[18]= Inverse[{{5, 5}, {5, 5}}, Modulus -> 26] How can I have my module fail in the case where an inverse does not exist? I want to end the module and give the user an error message stating to use a new matrix: this one does not have an inverse modulo 26. How can we in general take advantage of error messages or error return values in order to do this? Thanks, Flip Note: remove "_alpha" to send me an email.