Permalink
Browse files

Merge pull request #1186 from andysim/fmtlibqt

fmt: clang-format libqt
  • Loading branch information...
dgasmith committed Sep 6, 2018
2 parents 0f90ac2 + b02d6b3 commit 8cf39e7790670fc63694e19aafe7940d69286db3
@@ -36,7 +36,7 @@
*/
namespace psi {
/*!
** 3d_array(): Initialize a (non-contiguous) 3D array
**
@@ -49,26 +49,24 @@ namespace psi {
** \ingroup QT
*/
double ***init_3d_array(int p, int q, int r)
{
double ***A;
int i,j,k;
double ***init_3d_array(int p, int q, int r) {
double ***A;
int i, j, k;
A = (double ***) malloc(p * sizeof(double **));
for(i=0; i < p; i++) {
A[i] = (double **) malloc(q * sizeof(double *));
for(j=0; j < q; j++) {
A[i][j] = (double *) malloc(r * sizeof(double));
for(k=0; k < r; k++) {
A[i][j][k] = 0.0;
}
A = (double ***)malloc(p * sizeof(double **));
for (i = 0; i < p; i++) {
A[i] = (double **)malloc(q * sizeof(double *));
for (j = 0; j < q; j++) {
A[i][j] = (double *)malloc(r * sizeof(double));
for (k = 0; k < r; k++) {
A[i][j][k] = 0.0;
}
}
}
}
return A;
return A;
}
/*!
** free_3d_array(): Free a (non-contiguous) 3D array
**
@@ -80,17 +78,15 @@ double ***init_3d_array(int p, int q, int r)
**
** \ingroup QT
*/
void free_3d_array(double ***A, int p, int q)
{
int i,j;
void free_3d_array(double ***A, int p, int q) {
int i, j;
for(i=0; i < p; i++)
for(j=0; j < q; j++)
free(A[i][j]);
for (i = 0; i < p; i++)
for (j = 0; j < q; j++) free(A[i][j]);
for(i=0; i < p; i++) free(A[i]);
for (i = 0; i < p; i++) free(A[i]);
free(A);
free(A);
}
}
} // namespace psi
@@ -60,30 +60,24 @@
extern "C" {
extern void F_DSWAP(int *length, double *x, int *incx, double *y, int *inc_y);
extern void F_DAXPY(int *length, double *a, double *x, int *inc_x,
double *y, int *inc_y);
extern void F_DCOPY(int *length, double *x, int *inc_x,
double *y, int *inc_y);
extern void F_DGEMM(char *transa, char *transb, int *m, int *n, int *k,
double *alpha, double *A, int *lda, double *B, int *ldb,
double *beta, double *C, int *ldc);
extern void F_DSYMM(char* side, char *uplo, int *m, int *n,
double *alpha, double *A, int *lda, double *B, int *ldb,
double *beta, double *C, int *ldc);
extern void F_DROT(int *ntot, double *x, int *incx, double *y, int *incy,
double *cotheta, double *sintheta);
extern void F_DAXPY(int *length, double *a, double *x, int *inc_x, double *y, int *inc_y);
extern void F_DCOPY(int *length, double *x, int *inc_x, double *y, int *inc_y);
extern void F_DGEMM(char *transa, char *transb, int *m, int *n, int *k, double *alpha, double *A, int *lda, double *B,
int *ldb, double *beta, double *C, int *ldc);
extern void F_DSYMM(char *side, char *uplo, int *m, int *n, double *alpha, double *A, int *lda, double *B, int *ldb,
double *beta, double *C, int *ldc);
extern void F_DROT(int *ntot, double *x, int *incx, double *y, int *incy, double *cotheta, double *sintheta);
extern void F_DSCAL(int *n, double *alpha, double *vec, int *inc);
extern void F_DGEMV(char *transa, int *m, int *n, double *alpha, double *A,
int *lda, double *X, int *inc_x, double *beta, double *Y, int *inc_y);
extern void F_DSYMV(char *uplo, int *n, double *alpha, double *A,
int *lda, double *X, int *inc_x, double *beta, double *Y, int *inc_y);
extern void F_DSPMV(char *uplo, int *n, double *alpha, double *A, double *X,
int *inc_x, double *beta, double *Y, int *inc_y);
extern void F_DGEMV(char *transa, int *m, int *n, double *alpha, double *A, int *lda, double *X, int *inc_x,
double *beta, double *Y, int *inc_y);
extern void F_DSYMV(char *uplo, int *n, double *alpha, double *A, int *lda, double *X, int *inc_x, double *beta,
double *Y, int *inc_y);
extern void F_DSPMV(char *uplo, int *n, double *alpha, double *A, double *X, int *inc_x, double *beta, double *Y,
int *inc_y);
extern double F_DDOT(int *n, double *x, int *incx, double *y, int *incy);
extern double F_DNRM2(int *n, double *x, int *incx);
extern double F_DASUM(int *n, double *x, int *incx);
extern int F_IDAMAX(int *n, double *x, int *incx);
}
namespace psi {
@@ -99,13 +93,12 @@ namespace psi {
*
* @ingroup QT
*/
void PSI_API C_DSWAP(size_t length, double *x, int inc_x, double *y, int inc_y)
{
void PSI_API C_DSWAP(size_t length, double *x, int inc_x, double *y, int inc_y) {
int big_blocks = (int)(length / INT_MAX);
int small_size = (int)(length % INT_MAX);
for (int block = 0; block <= big_blocks; block++) {
double* x_s = &x[block*inc_x*(size_t)INT_MAX];
double* y_s = &y[block*inc_y*(size_t)INT_MAX];
double *x_s = &x[block * inc_x * (size_t)INT_MAX];
double *y_s = &y[block * inc_y * (size_t)INT_MAX];
signed int length_s = (block == big_blocks) ? small_size : INT_MAX;
::F_DSWAP(&length_s, x_s, &inc_x, y_s, &inc_y);
}
@@ -125,14 +118,12 @@ void PSI_API C_DSWAP(size_t length, double *x, int inc_x, double *y, int inc_y)
*
* \ingroup QT
*/
void PSI_API C_DAXPY(size_t length, double a, double *x, int inc_x,
double *y, int inc_y)
{
void PSI_API C_DAXPY(size_t length, double a, double *x, int inc_x, double *y, int inc_y) {
int big_blocks = (int)(length / INT_MAX);
int small_size = (int)(length % INT_MAX);
for (int block = 0; block <= big_blocks; block++) {
double* x_s = &x[block*inc_x*(size_t)INT_MAX];
double* y_s = &y[block*inc_y*(size_t)INT_MAX];
double *x_s = &x[block * inc_x * (size_t)INT_MAX];
double *y_s = &y[block * inc_y * (size_t)INT_MAX];
signed int length_s = (block == big_blocks) ? small_size : INT_MAX;
::F_DAXPY(&length_s, &a, x_s, &inc_x, y_s, &inc_y);
}
@@ -151,20 +142,17 @@ void PSI_API C_DAXPY(size_t length, double a, double *x, int inc_x,
*
* \ingroup QT
*/
void PSI_API C_DCOPY(size_t length, double *x, int inc_x,
double *y, int inc_y)
{
void PSI_API C_DCOPY(size_t length, double *x, int inc_x, double *y, int inc_y) {
int big_blocks = (int)(length / INT_MAX);
int small_size = (int)(length % INT_MAX);
for (int block = 0; block <= big_blocks; block++) {
double* x_s = &x[block*inc_x*(size_t)INT_MAX];
double* y_s = &y[block*inc_y*(size_t)INT_MAX];
double *x_s = &x[block * inc_x * (size_t)INT_MAX];
double *y_s = &y[block * inc_y * (size_t)INT_MAX];
signed int length_s = (block == big_blocks) ? small_size : INT_MAX;
::F_DCOPY(&length_s, x_s, &inc_x, y_s, &inc_y);
}
}
/*!
* This function scales a vector by a real scalar.
*
@@ -175,18 +163,16 @@ void PSI_API C_DCOPY(size_t length, double *x, int inc_x,
*
* \ingroup QT
*/
void PSI_API C_DSCAL(size_t length, double alpha, double *vec, int inc)
{
void PSI_API C_DSCAL(size_t length, double alpha, double *vec, int inc) {
int big_blocks = (int)(length / INT_MAX);
int small_size = (int)(length % INT_MAX);
for (int block = 0; block <= big_blocks; block++) {
double* vec_s = &vec[block*inc*(size_t)INT_MAX];
double *vec_s = &vec[block * inc * (size_t)INT_MAX];
signed int length_s = (block == big_blocks) ? small_size : INT_MAX;
::F_DSCAL(&length_s, &alpha, vec_s, &inc);
}
}
/*!
*Calculates a plane Givens rotation for vectors x, y and
* angle theta. x = x*cos + y*sin, y = -x*sin + y*cos.
@@ -199,18 +185,15 @@ void PSI_API C_DSCAL(size_t length, double alpha, double *vec, int inc)
*
* \ingroup QT
*/
void PSI_API C_DROT(size_t length, double *x, int inc_x, double *y, int inc_y,
double costheta, double sintheta)
{
void PSI_API C_DROT(size_t length, double *x, int inc_x, double *y, int inc_y, double costheta, double sintheta) {
int big_blocks = (int)(length / INT_MAX);
int small_size = (int)(length % INT_MAX);
for (int block = 0; block <= big_blocks; block++) {
double* x_s = &x[block*inc_x*(size_t)INT_MAX];
double* y_s = &y[block*inc_y*(size_t)INT_MAX];
double *x_s = &x[block * inc_x * (size_t)INT_MAX];
double *y_s = &y[block * inc_y * (size_t)INT_MAX];
signed int length_s = (block == big_blocks) ? small_size : INT_MAX;
::F_DROT(&length_s, x_s, &inc_x, y_s, &inc_y, &costheta, &sintheta);
}
}
/*!
@@ -228,17 +211,16 @@ void PSI_API C_DROT(size_t length, double *x, int inc_x, double *y, int inc_y,
* \ingroup QT
*/
double PSI_API C_DDOT(size_t length, double *x, int inc_x, double *y, int inc_y)
{
if(length == 0) return 0.0;
double PSI_API C_DDOT(size_t length, double *x, int inc_x, double *y, int inc_y) {
if (length == 0) return 0.0;
double reg = 0.0;
int big_blocks = (int)(length / INT_MAX);
int small_size = (int)(length % INT_MAX);
for (int block = 0; block <= big_blocks; block++) {
double* x_s = &x[block*inc_x*(size_t)INT_MAX];
double* y_s = &y[block*inc_y*(size_t)INT_MAX];
double *x_s = &x[block * inc_x * (size_t)INT_MAX];
double *y_s = &y[block * inc_y * (size_t)INT_MAX];
signed int length_s = (block == big_blocks) ? small_size : INT_MAX;
reg += ::F_DDOT(&length_s, x_s, &inc_x, y_s, &inc_y);
}
@@ -258,16 +240,15 @@ double PSI_API C_DDOT(size_t length, double *x, int inc_x, double *y, int inc_y)
* \ingroup QT
*/
double PSI_API C_DNRM2(size_t length, double *x, int inc_x)
{
if(length == 0) return 0.0;
double PSI_API C_DNRM2(size_t length, double *x, int inc_x) {
if (length == 0) return 0.0;
double reg = 0.0;
int big_blocks = (int)(length / INT_MAX);
int small_size = (int)(length % INT_MAX);
for (int block = 0; block <= big_blocks; block++) {
double* x_s = &x[block*inc_x*(size_t)INT_MAX];
double *x_s = &x[block * inc_x * (size_t)INT_MAX];
signed int length_s = (block == big_blocks) ? small_size : INT_MAX;
reg += ::F_DNRM2(&length_s, x_s, &inc_x);
}
@@ -287,16 +268,15 @@ double PSI_API C_DNRM2(size_t length, double *x, int inc_x)
* \ingroup QT
*/
double PSI_API C_DASUM(size_t length, double *x, int inc_x)
{
if(length == 0) return 0.0;
double PSI_API C_DASUM(size_t length, double *x, int inc_x) {
if (length == 0) return 0.0;
double reg = 0.0;
int big_blocks = (int)(length / INT_MAX);
int small_size = (int)(length % INT_MAX);
for (int block = 0; block <= big_blocks; block++) {
double* x_s = &x[block*inc_x*(size_t)INT_MAX];
double *x_s = &x[block * inc_x * (size_t)INT_MAX];
signed int length_s = (block == big_blocks) ? small_size : INT_MAX;
reg += ::F_DASUM(&length_s, x_s, &inc_x);
}
@@ -316,25 +296,22 @@ double PSI_API C_DASUM(size_t length, double *x, int inc_x)
* \ingroup QT
*/
size_t C_IDAMAX(size_t length, double *x, int inc_x)
{
if(length == 0) return 0L;
size_t C_IDAMAX(size_t length, double *x, int inc_x) {
if (length == 0) return 0L;
size_t reg = 0L;
size_t reg2 = 0L;
int big_blocks = (int)(length / INT_MAX);
int small_size = (int)(length % INT_MAX);
for (int block = 0; block <= big_blocks; block++) {
double* x_s = &x[block*inc_x*(size_t)INT_MAX];
double *x_s = &x[block * inc_x * (size_t)INT_MAX];
signed int length_s = (block == big_blocks) ? small_size : INT_MAX;
reg2 = ::F_IDAMAX(&length_s, x_s, &inc_x) + block*inc_x*(size_t)INT_MAX;
if (std::fabs(x[reg]) > std::fabs(x[reg2]))
reg = reg2;
reg2 = ::F_IDAMAX(&length_s, x_s, &inc_x) + block * inc_x * (size_t)INT_MAX;
if (std::fabs(x[reg]) > std::fabs(x[reg2])) reg = reg2;
}
return reg;
}
}
} // namespace psi
Oops, something went wrong.

0 comments on commit 8cf39e7

Please sign in to comment.