charlierabbit

primitiveFECInitializePolyFieldSizeCoefficientsOop

Jun 14th, 2021 (edited)
689
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.77 KB | None | 0 0
  1.     /* RSPlugin>>#fecOopInitializePolyFieldSize:coefficients:coefficientsCount: */
  2. static sqInt
  3. fecOopInitializePolyFieldSizecoefficientscoefficientsCount(sqInt fieldSize, unsigned char *coefficients, sqInt coefficientsCount)
  4. {
  5.     sqInt coefficientsLength;
  6.     sqInt firstNonZero;
  7.     sqInt index;
  8.     unsigned char *mutableCoefficients;
  9.     sqInt mutableCoefficientsCount;
  10.     sqInt mutableCoefficientsOop;
  11.  
  12.     coefficientsLength = coefficientsCount;
  13.     if (!((coefficientsLength > 1) && ((coefficients[0]) == 0))) {
  14.         mutableCoefficientsCount = coefficientsCount;
  15.         mutableCoefficientsOop = instantiateClassindexableSize(classByteArray(), mutableCoefficientsCount);
  16.         /* begin arrayFromOop: */
  17.         mutableCoefficients = firstIndexableField(mutableCoefficientsOop);
  18.         for (index = 0; index < mutableCoefficientsCount; index += 1) {
  19.             mutableCoefficients[index] = (coefficients[index]);
  20.             return mutableCoefficientsOop;
  21.         }
  22.     }
  23.     firstNonZero = 2;
  24.     while ((firstNonZero <= coefficientsLength)
  25.      && ((coefficients[firstNonZero]) == 0)) {
  26.         firstNonZero += 1;
  27.     }
  28.     if (firstNonZero > coefficientsLength) {
  29.         mutableCoefficientsCount = 1;
  30.         mutableCoefficientsOop = instantiateClassindexableSize(classByteArray(), mutableCoefficientsCount);
  31.         /* begin arrayFromOop: */
  32.         mutableCoefficients = firstIndexableField(mutableCoefficientsOop);
  33.     }
  34.     else {
  35.         mutableCoefficientsCount = coefficientsLength - firstNonZero;
  36.         mutableCoefficientsOop = instantiateClassindexableSize(classByteArray(), mutableCoefficientsCount);
  37.         /* begin arrayFromOop: */
  38.         mutableCoefficients = firstIndexableField(mutableCoefficientsOop);
  39.         for (index = 0; index < coefficientsLength; index += 1) {
  40.             mutableCoefficients[index] = (coefficients[index + firstNonZero]);
  41.         }
  42.     }
  43.     return mutableCoefficientsOop;
  44. }
  45.  
Advertisement
Add Comment
Please, Sign In to add comment