Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

CXML.DLL routine SAXPY trouble

danial
Beginner
489 Views
Here is my code:
typedef (__stdcall *p)(long*, float*, float[], long*, float[], long*);
p SAXPY;
HINSTANCE hLib;
hLib = LoadLibrary("CXML.DLL");
if (hLib != NULL)
{
SAXPY = (p)GetProcAddress(hLib,"SAXPY");
long n = 3;
long incx = 1;
long incy = 1;
float alpha = 2;
float x[2];
float y[2];
x[0] = 1;
x[1] = 1;
x[2] = 2;
y[0] = 1;
y[1] = 1;
y[2] = 1;
if (SAXPY != NULL)
{
SAXPY(&n, α, x, &incx, y, &incy);
}
FreeLibrary(hLib);
}
This routine is supposed to multiply each value in x() by alpha then add the results to y() and write the answers in to y() such that Yinew() = alpha*Xi() + Yi()
If you change the values of x[2] then y[0] you notice that
it is adding x[2] to y[0]. Is there something I am missing? Furthermore, the alpha =2 is not having the correct effect. It is behaving as if alpha = 1.
Danial.
0 Kudos
1 Reply
danial
Beginner
489 Views
the x and y arrays have the wrong imensions. change them to x[3] and y[3].
0 Kudos
Reply