Replace Python program auto-generated for documentation categories
[maxima/cygwin.git] / src / strmac.lisp
blobcd696d396b872675a5f4b47e005e31d445ea9fa9
1 ;;; -*- Mode: Lisp; Package: Maxima; Syntax: Common-Lisp; Base: 10 -*- ;;;;
2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3 ;;; The data in this file contains enhancments. ;;;;;
4 ;;; ;;;;;
5 ;;; Copyright (c) 1984,1987 by William Schelter,University of Texas ;;;;;
6 ;;; All rights reserved ;;;;;
7 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8 ;;; (c) Copyright 1980 Massachusetts Institute of Technology ;;;
9 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
11 (in-package :maxima)
12 (macsyma-module strmac macro)
14 ;; Data Representation macros.
16 ;; Hand coded macros for manipulating data structures in a simple
17 ;; way, yet still preserving some abstraction. Replacement for the mode
18 ;; package. We no longer know the type of things at run-time, so the names
19 ;; of each macro must reflect the type of its operand, e.g.
20 ;; RAT-NUMER versus MRAT-NUMER.
22 (defmacro make-g-rep (operator . operands)
23 `(list (list ,operator) . ,operands))
24 (defmacro make-g-rep-simp (operator . operands)
25 `(list (list ,operator) . ,operands))
27 (defmacro g-rep-operator (exp) `(caar ,exp))
28 (defmacro g-rep-operands (exp) `(cdr ,exp))
29 (defmacro g-rep-first-operand (exp)
30 `(cadr ,exp))
32 (defmacro make-mplus (&rest args) `(list '(mplus) . ,args))
33 (defmacro make-mplus-l (llist) `(cons '(mplus) ,llist))
34 (defmacro make-mplus-simp (&rest args) `(list '(mplus simp) . ,args))
38 (defmacro make-mtimes (&rest args) `(list '(mtimes) . ,args))
39 (defmacro make-mtimes-l (llist) `(cons '(mtimes) ,llist))
40 (defmacro make-mtimes-simp (&rest args) `(list '(mtimes simp) . ,args))
42 ;; losing MACLISP doesn't like BASE as a variable name !!
43 (defmacro make-mexpt (thing-being-raised-to-power expt)
44 `(list '(mexpt) ,thing-being-raised-to-power ,expt))
45 (defmacro make-mexpt-l (llist) `(cons '(mexpt) ,llist))
46 (defmacro make-mexpt-simp (thing-being-raised-to-power expt)
47 `(list '(mexpt simp) ,thing-being-raised-to-power ,expt))
49 (defmacro mexpt-base (mexpt) `(cadr ,mexpt))
50 (defmacro mexpt-expt (mexpt) `(caddr ,mexpt))
52 (defmacro make-mequal (lhs rhs) `(list '(mequal) ,lhs ,rhs))
53 (defmacro make-mequal-l (llist) `(cons '(mequal) ,llist))
54 (defmacro make-mequal-simp (lhs rhs) `(list '(mequal simp) ,lhs ,rhs))
56 (defmacro mequal-lhs (mequal) `(cadr ,mequal))
57 (defmacro mequal-rhs (mequal) `(caddr ,mequal))
59 (defmacro make-mlist (&rest args) `(list '(mlist) . ,args))
60 (defmacro make-mlist-l (llist) `(cons '(mlist) ,llist))
61 (defmacro make-mlist-simp (&rest args) `(list '(mlist simp) . ,args))
63 (defmacro make-mtext (&rest args) `(list '(mtext) . ,args))
65 (defmacro make-rat (&rest args) `(list '(rat) . ,args))
66 (defmacro make-rat-simp (&rest args) `(list '(rat simp) . ,args))
67 (defmacro make-rat-body (numer denom) `(cons ,numer ,denom))
68 (defmacro rat-numer (rat) `(cadr ,rat))
69 (defmacro rat-denom (rat) `(caddr ,rat))
71 ;; Schematic of MRAT form:
72 ;; ((MRAT SIMP <varlist> <genvars>) <numer> . <denom>)
74 ;; Schematic of <numer> and <denom>:
75 ;; (<genvar> <exponent 1> <coefficient 1> ...)
77 ;; Representation for X^2+1:
78 ;; ((MRAT SIMP ($X) (G0001)) (G0001 2 1 0 1) . 1)
80 ;; Representation for X+Y:
81 ;; ((MRAT SIMP ($X $Y) (G0001 G0002)) (G0001 1 1 0 (G0002 1 1)) . 1)
83 (defmacro mrat-body (mrat) `(cdr ,mrat))
84 (defmacro mrat-numer (mrat) `(cadr ,mrat))
85 (defmacro mrat-denom (mrat) `(cddr ,mrat))
87 (defmacro make-mrat (varlist genvars numer denom)
88 `((mrat ,varlist ,genvars) ,numer . ,denom))
90 (defmacro make-mrat-body (numer denom) `(cons ,numer ,denom))
92 ;; Data structures used only in this file.
94 (defmacro trig-cannon (operator) `(get ,operator 'trig-cannon))
96 ;; Linear equation -- cons of linear term and constant term.
98 (defmacro make-lineq (linear constant) `(cons ,linear ,constant))
99 (defmacro lineq-linear (lineq) `(car ,lineq))
100 (defmacro lineq-constant (lineq) `(cdr ,lineq))
102 ;; Solutions -- a pair of polynomial/multiplicity lists
104 (defmacro make-solution (wins losses) `(cons ,wins ,losses))
105 (defmacro solution-wins (solution) `(car ,solution))
106 (defmacro solution-losses (solution) `(cdr ,solution))
108 ;; Polynomials -- these appear in the numerator or denominator
109 ;; of MRAT forms. This doesn't handle the case of a coefficient
110 ;; polynomial.
112 (defmacro make-mrat-poly (var terms) `(cons ,var ,terms))
113 (defmacro poly-var (poly) `(car ,poly))
114 (defmacro poly-terms (poly) `(cdr ,poly))