Annotation of OpenXM_contrib2/asir2000/builtin/user.c, Revision 1.1
1.1 ! noro 1: /* $OpenXM$ */
! 2:
! 3: /* a sample file for adding builtin functions */
! 4:
! 5: #include "ca.h"
! 6: #include "parse.h"
! 7:
! 8: void Ppartial_derivative();
! 9: void partial_derivative(VL vl,P p,V v,P *r);
! 10:
! 11: struct ftab user_tab[] = {
! 12: /*
! 13: {"partial_derivative",Ppartial_derivative,2},
! 14: */
! 15: {0,0,0},
! 16: };
! 17:
! 18: /*
! 19: void Ppartial_derivative(NODE arg,P *rp)
! 20: {
! 21: asir_assert(ARG0(arg),O_P,"partial_derivative");
! 22: asir_assert(ARG1(arg),O_P,"partial_derivative");
! 23: partial_derivative(CO,(P)ARG0(arg),((P)ARG1(arg))->v,rp);
! 24: }
! 25:
! 26: void partial_derivative(VL vl,P p,V v,P *r)
! 27: {
! 28: P t;
! 29: DCP dc,dcr,dcr0;
! 30:
! 31: if ( !p || NUM(p) ) *r = 0;
! 32: else if ( v == p->v ) {
! 33: for ( dc = p->dc, dcr0 = 0; dc && dc->d; dc = dc->next ) {
! 34: mulp(vl,dc->c,(P)dc->d,&t);
! 35: if ( t ) {
! 36: NEXTDC(dcr0,dcr); subq(dc->d,ONE,&dcr->d); dcr->c = t;
! 37: }
! 38: }
! 39: if ( !dcr0 ) *r = 0;
! 40: else { dcr->next = 0; MKP(v,dcr0,*r); }
! 41: } else {
! 42: for ( dc = p->dc, dcr0 = 0; dc; dc = dc->next ) {
! 43: partial_derivative(vl,dc->c,v,&t);
! 44: if ( t ) { NEXTDC(dcr0,dcr); dcr->d = dc->d; dcr->c = t; }
! 45: }
! 46: if ( !dcr0 ) *r = 0;
! 47: else { dcr->next = 0; MKP(p->v,dcr0,*r); }
! 48: }
! 49: }
! 50: */
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>