Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1993
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1993

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

Search the Archive

Adding options to system functions

  • To: mathgroup <mathgroup at yoda.physics.unc.edu>
  • Subject: Adding options to system functions
  • From: Magnus Nordborg <magnus at fisher.stanford.edu>
  • Date: Sat, 15 May 93 15:32:53 -0700

A question and a suggestion:

How do I go about adding an option to a system rule?  Roman Maeder explains  
well how to add new rules, but adding options in a manner consistent with the  
way other options work seems more difficult. I tried the following:

FilterOutOption[ evil_Symbol, opts___ ] :=
	Sequence @@ Select[ {opts}, FreeQ[#,evil]& ]

Unprotect[Det]

Options[Det] = {HoldElements->False} ~Join~ Options[Det]

Det[m_?SquareMatrixQ, opts__Rule] :=
If[ HoldElements /. {opts} /. Options[Det],
	Det[Array[a,Dimensions[m]]] /. a[i_,j_] :> m[[i,j]],
(* else *)
	Det[ m, FilterOutOption[HoldElements,opts] ]
] /; !FreeQ[{opts},HoldElements]

Protect[Det]

The reason for this option, if it is not clear, is to make Det give me the  
determinant without even trying to do any clever things. I use it with symbolic  
matrices that are so ugly that Mathematica will never be able to figure out the  
determinant in a reasonable amount of time if it attempts to reduce the matrix.   
MACSYMA seems to do determinants in this way; it instantly spits out answers  
for ugly 3 by 3 matrices and then lets me use other tricks to make some sense  
of them, whereas Mathematica just grinds for a day or so until the swap space  
is full...  I hereby suggest that an option like the one I am trying to define  
be added to the system Det.

Anyway, back to the question: The above does not work because the system Det  
seems to be annoyed by my added option.  This can be verified as follows:

(using a new kernel)

(Gregor) In[1]:= Unprotect[Det]
(Gregor) Out[1]= {Det}
(Gregor) In[2]:= Options[Det] = {HoldElements->False} ~Join~ Options[Det]
(Gregor) Out[2]= {HoldElements -> False, Modulus -> 0}
(Gregor) In[3]:= Det[{{1,2},{3,4}}]
Det::optx: Unknown option HoldElements in Options[Det].
(Gregor) Out[3]= Det[{{1, 2}, {3, 4}}]

Thus, there is no way my function will work.  This is annoying.  Is there a  
workaround for these situations, or do I have to use a MyDet (and a MyListPlot,  
and a MySum, etc...)?

Thanks,
---
Magnus Nordborg					magnus at fisher.stanford.edu
Department of Biological Sciences		(NeXT mail preferred)
Stanford University				+1 (415) 723-4952 (office)
Stanford, CA 94305-5020				+1 (415) 948-7321 (home)





  • Prev by Date: InverseErf
  • Next by Date: Mathematica servers in Europe
  • Previous by thread: Adding options to system functions
  • Next by thread: Workbench