Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -302,3 +302,6 @@ hheei <hheei@users.noreply.github.com>

* Nathan Moinvaziri <https://github.com/nmoinvaz>
* [2026-11-14] Fix work buffer overflow in threaded GETRF for large N

* vera-rubin <https://github.com/vera-rubin>
* [2026-11-21] Fix the sine in the small-cosine branch of CROTG/ZROTG for complex inputs
4 changes: 2 additions & 2 deletions interface/zrotg.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ void CNAME(void *VDA, void *VDB, FLOAT *C, void *VS) {
*R = *DA * (h / adahsq);
*(R+1) = *(DA+1) * (h / adahsq);
}
*S = *S1 * (*DA) / adahsq;
*(S+1) = *(S1+1) * (*DA) / adahsq;
*S = *S1 * (*DA / adahsq) - *(S1+1) * (*(DA+1) / adahsq);
*(S+1) = *S1 * (*(DA+1) / adahsq) + *(S1+1) * (*DA / adahsq);
}
*DA=*R;
*(DA+1)=*(R+1);
Expand Down
38 changes: 38 additions & 0 deletions utest/test_extensions/test_crotg.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,25 @@ CTEST(crotg, negative_real_negative_img)
ASSERT_DBL_NEAR_TOL(-5.26498f, sa[0], SINGLE_EPS);
ASSERT_DBL_NEAR_TOL(-7.01997f, sa[1], SINGLE_EPS);
}
/**
* Fortran API specific test
* Test crotg with a complex a much smaller than b, where the cosine
* is computed in the small-cosine branch
*/
CTEST(crotg, unbalanced_complex_a)
{
float sa[2] = {ldexpf(1.0, -30), ldexpf(1.0, -30)};
float sb[2] = {ldexpf(1.0, 50), 0.0};
float ss[2];
float sc;
BLASFUNC(crotg)(sa, sb, &sc, ss);
ASSERT_DBL_NEAR_TOL(1.41421356237310, ldexp(sc, 80), SINGLE_EPS);
ASSERT_DBL_NEAR_TOL(0.70710678118655, ss[0], SINGLE_EPS);
ASSERT_DBL_NEAR_TOL(0.70710678118655, ss[1], SINGLE_EPS);
ASSERT_DBL_NEAR_TOL(1.41421356237310, ldexp(sa[0], -49), SINGLE_EPS);
ASSERT_DBL_NEAR_TOL(1.41421356237310, ldexp(sa[1], -49), SINGLE_EPS);
}

#ifndef NO_CBLAS
/**
* C API specific test
Expand Down Expand Up @@ -363,5 +382,24 @@ CTEST(crotg, c_api_negative_real_negative_img)
ASSERT_DBL_NEAR_TOL(-5.26498f, sa[0], SINGLE_EPS);
ASSERT_DBL_NEAR_TOL(-7.01997f, sa[1], SINGLE_EPS);
}

/**
* C API specific test
* Test crotg with a complex a much smaller than b, where the cosine
* is computed in the small-cosine branch
*/
CTEST(crotg, c_api_unbalanced_complex_a)
{
float sa[2] = {ldexpf(1.0, -30), ldexpf(1.0, -30)};
float sb[2] = {ldexpf(1.0, 50), 0.0};
float ss[2];
float sc;
cblas_crotg(sa, sb, &sc, ss);
ASSERT_DBL_NEAR_TOL(1.41421356237310, ldexp(sc, 80), SINGLE_EPS);
ASSERT_DBL_NEAR_TOL(0.70710678118655, ss[0], SINGLE_EPS);
ASSERT_DBL_NEAR_TOL(0.70710678118655, ss[1], SINGLE_EPS);
ASSERT_DBL_NEAR_TOL(1.41421356237310, ldexp(sa[0], -49), SINGLE_EPS);
ASSERT_DBL_NEAR_TOL(1.41421356237310, ldexp(sa[1], -49), SINGLE_EPS);
}
#endif
#endif
38 changes: 38 additions & 0 deletions utest/test_extensions/test_zrotg.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,25 @@ CTEST(zrotg, negative_real_negative_img)
ASSERT_DBL_NEAR_TOL(-7.01997150991369, sa[1], DOUBLE_EPS);
}

/**
* Fortran API specific test
* Test zrotg with a complex a much smaller than b, where the cosine
* is computed in the small-cosine branch
*/
CTEST(zrotg, unbalanced_complex_a)
{
double sa[2] = {ldexp(1.0, -200), ldexp(1.0, -200)};
double sb[2] = {ldexp(1.0, 400), 0.0};
double ss[2];
double sc;
BLASFUNC(zrotg)(sa, sb, &sc, ss);
ASSERT_DBL_NEAR_TOL(1.41421356237310, ldexp(sc, 600), DOUBLE_EPS);
ASSERT_DBL_NEAR_TOL(0.70710678118655, ss[0], DOUBLE_EPS);
ASSERT_DBL_NEAR_TOL(0.70710678118655, ss[1], DOUBLE_EPS);
ASSERT_DBL_NEAR_TOL(1.41421356237310, ldexp(sa[0], -399), DOUBLE_EPS);
ASSERT_DBL_NEAR_TOL(1.41421356237310, ldexp(sa[1], -399), DOUBLE_EPS);
}

#ifndef NO_CBLAS
/**
* C API specific test
Expand Down Expand Up @@ -364,5 +383,24 @@ CTEST(zrotg, c_api_negative_real_negative_img)
ASSERT_DBL_NEAR_TOL(-5.26497863243527, sa[0], DOUBLE_EPS);
ASSERT_DBL_NEAR_TOL(-7.01997150991369, sa[1], DOUBLE_EPS);
}

/**
* C API specific test
* Test zrotg with a complex a much smaller than b, where the cosine
* is computed in the small-cosine branch
*/
CTEST(zrotg, c_api_unbalanced_complex_a)
{
double sa[2] = {ldexp(1.0, -200), ldexp(1.0, -200)};
double sb[2] = {ldexp(1.0, 400), 0.0};
double ss[2];
double sc;
cblas_zrotg(sa, sb, &sc, ss);
ASSERT_DBL_NEAR_TOL(1.41421356237310, ldexp(sc, 600), DOUBLE_EPS);
ASSERT_DBL_NEAR_TOL(0.70710678118655, ss[0], DOUBLE_EPS);
ASSERT_DBL_NEAR_TOL(0.70710678118655, ss[1], DOUBLE_EPS);
ASSERT_DBL_NEAR_TOL(1.41421356237310, ldexp(sa[0], -399), DOUBLE_EPS);
ASSERT_DBL_NEAR_TOL(1.41421356237310, ldexp(sa[1], -399), DOUBLE_EPS);
}
#endif
#endif
Loading