Annotation of OpenXM_contrib2/asir2018/engine/vect.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: #include "ca.h"
! 51:
! 52: void addvect(vl,a,b,c)
! 53: VL vl;
! 54: VECT a,b,*c;
! 55: {
! 56: int len,i;
! 57: VECT t;
! 58: pointer *ab,*bb,*tb;
! 59:
! 60: if ( !a )
! 61: *c = b;
! 62: else if ( !b )
! 63: *c = a;
! 64: else if ( a->len != b->len ) {
! 65: *c = 0; error("addvect : size mismatch");
! 66: } else {
! 67: len = a->len;
! 68: MKVECT(t,len);
! 69: for ( i = 0, ab = BDY(a), bb = BDY(b), tb = BDY(t); i < len; i++ )
! 70: arf_add(vl,(Obj)ab[i],(Obj)bb[i],(Obj *)&tb[i]);
! 71: *c = t;
! 72: }
! 73: }
! 74:
! 75: void subvect(vl,a,b,c)
! 76: VL vl;
! 77: VECT a,b,*c;
! 78: {
! 79: int len,i;
! 80: VECT t;
! 81: pointer *ab,*bb,*tb;
! 82:
! 83: if ( !a )
! 84: chsgnvect(b,c);
! 85: else if ( !b )
! 86: *c = a;
! 87: else if (a->len != b->len ) {
! 88: *c = 0; error("subvect : size mismatch");
! 89: } else {
! 90: len = a->len;
! 91: MKVECT(t,len);
! 92: for ( i = 0, ab = BDY(a), bb = BDY(b), tb = BDY(t);
! 93: i < len; i++ )
! 94: arf_sub(vl,(Obj)ab[i],(Obj)bb[i],(Obj *)&tb[i]);
! 95: *c = t;
! 96: }
! 97: }
! 98:
! 99: void mulvect(vl,a,b,c)
! 100: VL vl;
! 101: Obj a,b,*c;
! 102: {
! 103: if ( !a || !b )
! 104: *c = 0;
! 105: else if ( OID(a) <= O_R || OID(a) == O_DP )
! 106: mulrvect(vl,a,(VECT)b,(VECT *)c);
! 107: else if ( OID(b) <= O_R || OID(b) == O_DP )
! 108: mulrvect(vl,b,(VECT)a,(VECT *)c);
! 109: else
! 110: notdef(vl,a,b,c);
! 111: }
! 112:
! 113: void divvect(vl,a,b,c)
! 114: VL vl;
! 115: Obj a,b,*c;
! 116: {
! 117: Obj t;
! 118:
! 119: if ( !b )
! 120: error("divvect : division by 0");
! 121: else if ( !a )
! 122: *c = 0;
! 123: else if ( OID(b) > O_R )
! 124: notdef(vl,a,b,c);
! 125: else {
! 126: arf_div(vl,(Obj)ONE,b,&t); mulrvect(vl,(Obj)t,(VECT)a,(VECT *)c);
! 127: }
! 128: }
! 129:
! 130: void chsgnvect(a,b)
! 131: VECT a,*b;
! 132: {
! 133: VECT t;
! 134: int len,i;
! 135: pointer *ab,*tb;
! 136:
! 137: if ( !a )
! 138: *b = 0;
! 139: else {
! 140: len = a->len;
! 141: MKVECT(t,len);
! 142: for ( i = 0, ab = BDY(a), tb = BDY(t);
! 143: i < len; i++ )
! 144: arf_chsgn((Obj)ab[i],(Obj *)&tb[i]);
! 145: *b = t;
! 146: }
! 147: }
! 148:
! 149: void mulrvect(vl,a,b,c)
! 150: VL vl;
! 151: Obj a;
! 152: VECT b,*c;
! 153: {
! 154: int len,i;
! 155: VECT t;
! 156: pointer *bb,*tb;
! 157:
! 158: if ( !a || !b )
! 159: *c = 0;
! 160: else {
! 161: len = b->len;
! 162: MKVECT(t,len);
! 163: for ( i = 0, bb = BDY(b), tb = BDY(t); i < len; i++ )
! 164: arf_mul(vl,a,(Obj)bb[i],(Obj *)&tb[i]);
! 165: *c = t;
! 166: }
! 167: }
! 168:
! 169: int compvect(vl,a,b)
! 170: VL vl;
! 171: VECT a,b;
! 172: {
! 173: int i,len,t;
! 174:
! 175: if ( !a )
! 176: return b?-1:0;
! 177: else if ( !b )
! 178: return 1;
! 179: else if ( a->len != b->len )
! 180: return a->len>b->len ? 1 : -1;
! 181: else {
! 182: for ( i = 0, len = a->len; i < len; i++ )
! 183: if ( t = arf_comp(vl,(Obj)BDY(a)[i],(Obj)BDY(b)[i]) )
! 184: return t;
! 185: return 0;
! 186: }
! 187: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>