/** Functions for SCS multiplication operations @file multiplication_scs.c @author Defour David David.Defour@ens-lyon.fr @author Florent de Dinechin Florent.de.Dinechin@ens-lyon.fr This file is part of the SCS library. */ /* Copyright (C) 2002 David Defour and Florent de Dinechin This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "scs.h" #include "scs_private.h" #if 0 /* used to help debugging */ void pr(char* s,double d) { db_number x; x.d=d; printf(s);printf(" "); printf("%8x%8x . 2^%d (%8f %8x %8x) \n", (x.i[HI]&0x000FFFFF)+0x00100000, x.i[LO], (x.i[HI]>>20)-1023, x.d, x.i[HI], x.i[LO]); } #endif /* Compute the carry of r1, remove it from r1, and add it to r0 */ #define SCS_CARRY_PROPAGATE(r1,r0,tmp) \ {tmp = r1>>SCS_NB_BITS; r0 += tmp; r1 -= (tmp<0; i--) SCS_CARRY_PROPAGATE(RES[i],RES[i-1],tmp) SCS_CARRY_PROPAGATE(RES[0],val,tmp) /* Store the result */ if(val != 0){ /* shift all the digits ! */ R_HW[0] = val; for(i=1; i0; i--) SCS_CARRY_PROPAGATE(RES[i],RES[i-1],tmp) SCS_CARRY_PROPAGATE(RES[0],val,tmp) /* Store the result */ if(val != 0){ /* shift all the digits ! */ R_HW[0] = val; for(i=1; i=0; i--){ val += vald * X_HW[i]; SCS_CARRY_PROPAGATE(val, rr, tmp) X_HW[i] = val; val = rr; rr = 0; } if(val != 0){ /* shift all the digits ! */ for(i=(SCS_NB_WORDS-1); i>0; i--) X_HW[i] = X_HW[i-1]; X_HW[0] = (unsigned int)val; X_IND += 1; } return; }