- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
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.
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
the x and y arrays have the wrong imensions. change them to x[3] and y[3].

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page