R-js/blasjs

Bug in isamax and icamax

Schultzer opened this issue · 2 comments

isamax
icmax

Reference BLAS

         IX = 1
         DMAX = DABS(DX(1))
         IX = IX + INCX
         DO I = 2,N
            IF (DABS(DX(IX)).GT.DMAX) THEN
               IDAMAX = I
               DMAX = DABS(DX(IX))
            END IF
            IX = IX + INCX
         END DO
      END IF
      RETURN

They should be
_isamax = i; and _icamax = i;

I found this bug when I did a rewrite of the generate-fixtures to get complete test coverage.

These two test are wrong max should be max: 3.

        case1: {
            desc: 'isamx n=3, incx=2',
            input: {
                n: 3,
                cx: {
                    re: [1, 2, 3, 4, 5, 6]
                },
                incx: 2,
            },
            output: {
                max: 5
            },
        },

        case1: {
            desc: 'icamx n=3, incx=2',
            input: {
                n: 3,
                cx: {
                    re: [1, 2, 3, 4, 5, 6],
                    im: [7, 8, 9, 10, 11, 12]
                },
                incx: 2,
            },
            output: {
                max: 5
            },
        },

Great find,

new version 1.0.13

  • fixed the bugs
  • extended the fortran fixture to cover the complex and real versions of i[x]amax
  • fixed some broken links in the documentation

Fixed in 69c2363