• To: mathgroup <mathgroup at yoda.physics.unc.edu>, support
• 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)

************************************************************************

Hello Magnus,

I, too, have been frustrated by this apparent inconsistency with the
extensibility of system functions.  I think I submitted a suggestion

suggestions at wri.com

You may also use this address directly when you have suggestions.

I do not know of a way around the problem other than using a different
symbol for the user-defined function.

Apologies,

Robby Villegas
Technical Support

```

• Prev by Date: EPS from v2.0 & v2.2
• Next by Date: Workbench
• Previous by thread: EPS from v2.0 & v2.2