[BACK]Return to PDM.c CVS log [TXT][DIR] Up to [local] / OpenXM_contrib2 / asir2018 / engine

Annotation of OpenXM_contrib2/asir2018/engine/PDM.c, Revision 1.1

1.1     ! noro        1: /*
        !             2:  * Copyright (c) 1994-2000 FUJITSU LABORATORIES LIMITED
        !             3:  * All rights reserved.
        !             4:  *
        !             5:  * FUJITSU LABORATORIES LIMITED ("FLL") hereby grants you a limited,
        !             6:  * non-exclusive and royalty-free license to use, copy, modify and
        !             7:  * redistribute, solely for non-commercial and non-profit purposes, the
        !             8:  * computer program, "Risa/Asir" ("SOFTWARE"), subject to the terms and
        !             9:  * conditions of this Agreement. For the avoidance of doubt, you acquire
        !            10:  * only a limited right to use the SOFTWARE hereunder, and FLL or any
        !            11:  * third party developer retains all rights, including but not limited to
        !            12:  * copyrights, in and to the SOFTWARE.
        !            13:  *
        !            14:  * (1) FLL does not grant you a license in any way for commercial
        !            15:  * purposes. You may use the SOFTWARE only for non-commercial and
        !            16:  * non-profit purposes only, such as academic, research and internal
        !            17:  * business use.
        !            18:  * (2) The SOFTWARE is protected by the Copyright Law of Japan and
        !            19:  * international copyright treaties. If you make copies of the SOFTWARE,
        !            20:  * with or without modification, as permitted hereunder, you shall affix
        !            21:  * to all such copies of the SOFTWARE the above copyright notice.
        !            22:  * (3) An explicit reference to this SOFTWARE and its copyright owner
        !            23:  * shall be made on your publication or presentation in any form of the
        !            24:  * results obtained by use of the SOFTWARE.
        !            25:  * (4) In the event that you modify the SOFTWARE, you shall notify FLL by
        !            26:  * e-mail at risa-admin@sec.flab.fujitsu.co.jp of the detailed specification
        !            27:  * for such modification or the source code of the modified part of the
        !            28:  * SOFTWARE.
        !            29:  *
        !            30:  * THE SOFTWARE IS PROVIDED AS IS WITHOUT ANY WARRANTY OF ANY KIND. FLL
        !            31:  * MAKES ABSOLUTELY NO WARRANTIES, EXPRESSED, IMPLIED OR STATUTORY, AND
        !            32:  * EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS
        !            33:  * FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT OF THIRD PARTIES'
        !            34:  * RIGHTS. NO FLL DEALER, AGENT, EMPLOYEES IS AUTHORIZED TO MAKE ANY
        !            35:  * MODIFICATIONS, EXTENSIONS, OR ADDITIONS TO THIS WARRANTY.
        !            36:  * UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, TORT, CONTRACT,
        !            37:  * OR OTHERWISE, SHALL FLL BE LIABLE TO YOU OR ANY OTHER PERSON FOR ANY
        !            38:  * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, PUNITIVE OR CONSEQUENTIAL
        !            39:  * DAMAGES OF ANY CHARACTER, INCLUDING, WITHOUT LIMITATION, DAMAGES
        !            40:  * ARISING OUT OF OR RELATING TO THE SOFTWARE OR THIS AGREEMENT, DAMAGES
        !            41:  * FOR LOSS OF GOODWILL, WORK STOPPAGE, OR LOSS OF DATA, OR FOR ANY
        !            42:  * DAMAGES, EVEN IF FLL SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF
        !            43:  * SUCH DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY. EVEN IF A PART
        !            44:  * OF THE SOFTWARE HAS BEEN DEVELOPED BY A THIRD PARTY, THE THIRD PARTY
        !            45:  * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE,
        !            46:  * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE.
        !            47:  *
        !            48:  * $OpenXM$
        !            49: */
        !            50: #ifndef MODULAR
        !            51: #define MODULAR
        !            52: #endif
        !            53:
        !            54: #include "b.h"
        !            55: #include "ca.h"
        !            56:
        !            57: #include "polydiv.c"
        !            58:
        !            59: int divtmp(VL vl,int mod,P p1,P p2,P *q)
        !            60: {
        !            61:   register int i,j;
        !            62:   register DCP dc1,dc2,dc;
        !            63:   P m,m1,s,dvr,t;
        !            64:   P *pq,*pr,*pd;
        !            65:   V v1,v2;
        !            66:   Z deg1,deg2;
        !            67:   int d1,d2,sgn;
        !            68:
        !            69:   if ( !p1 ) {
        !            70:     *q = 0;
        !            71:     return 1;
        !            72:   } else if ( NUM(p2) ) {
        !            73:     divsmp(vl,mod,p1,p2,q);
        !            74:     return 1;
        !            75:   } else if ( NUM(p1) ) {
        !            76:     *q = 0;
        !            77:     return 0;
        !            78:   } else if ( ( v1 = VR(p1) ) == ( v2 = VR(p2) ) ) {
        !            79:     dc1 = DC(p1); dc2 = DC(p2);
        !            80:     deg1 = DEG(dc1); deg2 = DEG(dc2);
        !            81:     sgn = cmpz(deg1,deg2);
        !            82:     if ( sgn == 0 )
        !            83:       if ( !divtmp(vl,mod,COEF(dc1),COEF(dc2),&m) ) {
        !            84:         *q = 0;
        !            85:         return 0;
        !            86:       } else {
        !            87:         mulmp(vl,mod,p2,m,&m1); submp(vl,mod,p1,m1,&s);
        !            88:         if ( !s ) {
        !            89:           *q = m;
        !            90:           return 1;
        !            91:         } else {
        !            92:           *q = 0;
        !            93:           return 0;
        !            94:         }
        !            95:       }
        !            96:     else if ( sgn < 0 ) {
        !            97:       *q = 0;
        !            98:       return 0;
        !            99:     } else {
        !           100:       if ( !smallz(deg1) ) {
        !           101:         error("divtmp : invalid input");
        !           102:         *q = 0;
        !           103:         return ( 0 );
        !           104:       }
        !           105:       d1 = QTOS(deg1); d2 = QTOS(deg2);
        !           106:       W_CALLOC(d1-d2,P,pq); W_CALLOC(d1,P,pr); W_CALLOC(d2,P,pd);
        !           107:       for ( dc = dc1; dc; dc = NEXT(dc) )
        !           108:         pr[QTOS(DEG(dc))] = COEF(dc);
        !           109:       for ( dc = dc2; dc; dc = NEXT(dc) )
        !           110:         pd[QTOS(DEG(dc))] = COEF(dc);
        !           111:       for ( dvr = COEF(dc2), i = d1 - d2; i >= 0; i-- )
        !           112:         if ( !pr[i+d2] )
        !           113:           continue;
        !           114:         else if ( !divtmp(vl,mod,pr[i+d2],dvr,&m) ) {
        !           115:           *q = 0;
        !           116:           return 0;
        !           117:         } else {
        !           118:           pq[i] = m;
        !           119:           for ( j = d2; j >= 0; j-- ) {
        !           120:             mulmp(vl,mod,pq[i],pd[j],&m);
        !           121:             submp(vl,mod,pr[i + j],m,&s); pr[i + j] = s;
        !           122:           }
        !           123:         }
        !           124:       plisttop(pq,v1,d1 - d2,&m); plisttop(pr,v1,d1 - 1,&t);
        !           125:       if ( t ) {
        !           126:         *q = 0;
        !           127:         return 0;
        !           128:       } else {
        !           129:         *q = m;
        !           130:         return 1;
        !           131:       }
        !           132:     }
        !           133:   } else {
        !           134:     for ( ; (v1 != vl->v) && (v2 != vl->v); vl = NEXT(vl) );
        !           135:     if ( v2 == vl->v ) {
        !           136:       *q = 0;
        !           137:       return 0;
        !           138:     } else
        !           139:       return divtdcmp(vl,mod,p1,p2,q);
        !           140:   }
        !           141: }
        !           142:
        !           143: int divtdcmp(VL vl,int mod,P p1,P p2,P *q)
        !           144: {
        !           145:
        !           146:   P m;
        !           147:   register DCP dc,dcr,dcr0;
        !           148:
        !           149:   for ( dc = DC(p1), dcr0 = 0; dc; dc = NEXT(dc) )
        !           150:     if ( !divtmp(vl,mod,COEF(dc),p2,&m) ) {
        !           151:       *q = 0;
        !           152:       return 0;
        !           153:     } else {
        !           154:       NEXTDC(dcr0,dcr); DEG(dcr) = DEG(dc); COEF(dcr) = m; NEXT(dcr) = 0;
        !           155:     }
        !           156:   MKP(VR(p1),dcr0,*q);
        !           157:   return 1;
        !           158: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>