Skip to content

Commit 15d05b4

Browse files
committed
fix code style in LAPACKE DGESV examples
1 parent 41909fd commit 15d05b4

File tree

4 files changed

+120
-120
lines changed

4 files changed

+120
-120
lines changed

LAPACKE/example/example_DGESV_colmajor.c

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -41,41 +41,41 @@ int main(int argc, char **argv) {
4141

4242
/* Locals */
4343
lapack_int n, nrhs, lda, ldb, info;
44-
int i, j;
44+
int i, j;
4545
/* Local arrays */
46-
double *A, *b;
47-
lapack_int *ipiv;
46+
double *A, *b;
47+
lapack_int *ipiv;
4848

4949
/* Default Value */
50-
n = 5; nrhs = 1;
50+
n = 5; nrhs = 1;
5151

5252
/* Arguments */
53-
for( i = 1; i < argc; i++ ) {
54-
if( strcmp( argv[i], "-n" ) == 0 ) {
55-
n = atoi(argv[i+1]);
56-
i++;
57-
}
58-
if( strcmp( argv[i], "-nrhs" ) == 0 ) {
59-
nrhs = atoi(argv[i+1]);
60-
i++;
61-
}
62-
}
53+
for( i = 1; i < argc; i++ ) {
54+
if( strcmp( argv[i], "-n" ) == 0 ) {
55+
n = atoi(argv[i+1]);
56+
i++;
57+
}
58+
if( strcmp( argv[i], "-nrhs" ) == 0 ) {
59+
nrhs = atoi(argv[i+1]);
60+
i++;
61+
}
62+
}
6363

6464
/* Initialization */
6565
lda=n, ldb=n;
66-
A = (double *)malloc(n*n*sizeof(double)) ;
67-
if (A==NULL){ printf("error of memory allocation\n"); exit(0); }
68-
b = (double *)malloc(n*nrhs*sizeof(double)) ;
69-
if (b==NULL){ printf("error of memory allocation\n"); free(A); exit(0); }
70-
ipiv = (lapack_int *)malloc(n*sizeof(lapack_int)) ;
71-
if (ipiv==NULL){ printf("error of memory allocation\n"); free(A); free(b); exit(0); }
66+
A = (double *)malloc(n*n*sizeof(double)) ;
67+
if (A==NULL){ printf("error of memory allocation\n"); exit(0); }
68+
b = (double *)malloc(n*nrhs*sizeof(double)) ;
69+
if (b==NULL){ printf("error of memory allocation\n"); free(A); exit(0); }
70+
ipiv = (lapack_int *)malloc(n*sizeof(lapack_int)) ;
71+
if (ipiv==NULL){ printf("error of memory allocation\n"); free(A); free(b); exit(0); }
7272

7373
for( i = 0; i < n; i++ ) {
7474
for( j = 0; j < n; j++ ) A[i+j*lda] = ((double) rand()) / ((double) RAND_MAX) - 0.5;
75-
}
75+
}
7676

77-
for(i=0;i<n*nrhs;i++)
78-
b[i] = ((double) rand()) / ((double) RAND_MAX) - 0.5;
77+
for(i=0;i<n*nrhs;i++)
78+
b[i] = ((double) rand()) / ((double) RAND_MAX) - 0.5;
7979

8080
/* Print Entry Matrix */
8181
print_matrix_colmajor( "Entry Matrix A", n, n, A, lda );
@@ -91,13 +91,13 @@ int main(int argc, char **argv) {
9191

9292
/* Check for the exact singularity */
9393
if( info > 0 ) {
94-
printf( "The diagonal element of the triangular factor of A,\n" );
95-
printf( "U(%" LAPACK_IFMT ",%" LAPACK_IFMT ") is zero, so that A is singular;\n", info, info );
96-
printf( "the solution could not be computed.\n" );
97-
free(A);
98-
free(b);
99-
free(ipiv);
100-
exit( 1 );
94+
printf( "The diagonal element of the triangular factor of A,\n" );
95+
printf( "U(%" LAPACK_IFMT ",%" LAPACK_IFMT ") is zero, so that A is singular;\n", info, info );
96+
printf( "the solution could not be computed.\n" );
97+
free(A);
98+
free(b);
99+
free(ipiv);
100+
exit( 1 );
101101
}
102102
if (info <0) {
103103
free(A);

LAPACKE/example/example_DGESV_colmajor_64.c

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -41,41 +41,41 @@ int main(int argc, char **argv) {
4141

4242
/* Locals */
4343
int64_t n, nrhs, lda, ldb, info;
44-
int i, j;
44+
int i, j;
4545
/* Local arrays */
46-
double *A, *b;
47-
int64_t *ipiv;
46+
double *A, *b;
47+
int64_t *ipiv;
4848

4949
/* Default Value */
50-
n = 5; nrhs = 1;
50+
n = 5; nrhs = 1;
5151

5252
/* Arguments */
53-
for( i = 1; i < argc; i++ ) {
54-
if( strcmp( argv[i], "-n" ) == 0 ) {
55-
n = atoi(argv[i+1]);
56-
i++;
57-
}
58-
if( strcmp( argv[i], "-nrhs" ) == 0 ) {
59-
nrhs = atoi(argv[i+1]);
60-
i++;
61-
}
62-
}
53+
for( i = 1; i < argc; i++ ) {
54+
if( strcmp( argv[i], "-n" ) == 0 ) {
55+
n = atoi(argv[i+1]);
56+
i++;
57+
}
58+
if( strcmp( argv[i], "-nrhs" ) == 0 ) {
59+
nrhs = atoi(argv[i+1]);
60+
i++;
61+
}
62+
}
6363

6464
/* Initialization */
6565
lda=n, ldb=n;
66-
A = (double *)malloc(n*n*sizeof(double)) ;
67-
if (A==NULL){ printf("error of memory allocation\n"); exit(0); }
68-
b = (double *)malloc(n*nrhs*sizeof(double)) ;
69-
if (b==NULL){ printf("error of memory allocation\n"); free(A); exit(0); }
70-
ipiv = (int64_t *)malloc(n*sizeof(int64_t)) ;
71-
if (ipiv==NULL){ printf("error of memory allocation\n"); free(A); free(b); exit(0); }
66+
A = (double *)malloc(n*n*sizeof(double)) ;
67+
if (A==NULL){ printf("error of memory allocation\n"); exit(0); }
68+
b = (double *)malloc(n*nrhs*sizeof(double)) ;
69+
if (b==NULL){ printf("error of memory allocation\n"); free(A); exit(0); }
70+
ipiv = (int64_t *)malloc(n*sizeof(int64_t)) ;
71+
if (ipiv==NULL){ printf("error of memory allocation\n"); free(A); free(b); exit(0); }
7272

7373
for( i = 0; i < n; i++ ) {
7474
for( j = 0; j < n; j++ ) A[i+j*lda] = ((double) rand()) / ((double) RAND_MAX) - 0.5;
75-
}
75+
}
7676

77-
for(i=0;i<n*nrhs;i++)
78-
b[i] = ((double) rand()) / ((double) RAND_MAX) - 0.5;
77+
for(i=0;i<n*nrhs;i++)
78+
b[i] = ((double) rand()) / ((double) RAND_MAX) - 0.5;
7979

8080
/* Print Entry Matrix */
8181
print_matrix_colmajor_64( "Entry Matrix A", n, n, A, lda );
@@ -91,13 +91,13 @@ int main(int argc, char **argv) {
9191

9292
/* Check for the exact singularity */
9393
if( info > 0 ) {
94-
printf( "The diagonal element of the triangular factor of A,\n" );
95-
printf( "U(%" LAPACK_IFMT ",%" LAPACK_IFMT ") is zero, so that A is singular;\n", info, info );
96-
printf( "the solution could not be computed.\n" );
97-
free(A);
98-
free(b);
99-
free(ipiv);
100-
exit( 1 );
94+
printf( "The diagonal element of the triangular factor of A,\n" );
95+
printf( "U(%" LAPACK_IFMT ",%" LAPACK_IFMT ") is zero, so that A is singular;\n", info, info );
96+
printf( "the solution could not be computed.\n" );
97+
free(A);
98+
free(b);
99+
free(ipiv);
100+
exit( 1 );
101101
}
102102
if (info <0) {
103103
free(A);

LAPACKE/example/example_DGESV_rowmajor.c

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -40,41 +40,41 @@ int main(int argc, char **argv) {
4040

4141
/* Locals */
4242
lapack_int n, nrhs, lda, ldb, info;
43-
int i, j;
43+
int i, j;
4444
/* Local arrays */
45-
double *A, *b;
46-
lapack_int *ipiv;
45+
double *A, *b;
46+
lapack_int *ipiv;
4747

4848
/* Default Value */
49-
n = 5; nrhs = 1;
49+
n = 5; nrhs = 1;
5050

5151
/* Arguments */
52-
for( i = 1; i < argc; i++ ) {
53-
if( strcmp( argv[i], "-n" ) == 0 ) {
54-
n = atoi(argv[i+1]);
55-
i++;
56-
}
57-
if( strcmp( argv[i], "-nrhs" ) == 0 ) {
58-
nrhs = atoi(argv[i+1]);
59-
i++;
60-
}
61-
}
52+
for( i = 1; i < argc; i++ ) {
53+
if( strcmp( argv[i], "-n" ) == 0 ) {
54+
n = atoi(argv[i+1]);
55+
i++;
56+
}
57+
if( strcmp( argv[i], "-nrhs" ) == 0 ) {
58+
nrhs = atoi(argv[i+1]);
59+
i++;
60+
}
61+
}
6262

6363
/* Initialization */
6464
lda=n, ldb=nrhs;
65-
A = (double *)malloc(n*n*sizeof(double)) ;
66-
if (A==NULL){ printf("error of memory allocation\n"); exit(0); }
67-
b = (double *)malloc(n*nrhs*sizeof(double)) ;
68-
if (b==NULL){ printf("error of memory allocation\n"); free(A); exit(0); }
69-
ipiv = (lapack_int *)malloc(n*sizeof(lapack_int)) ;
70-
if (ipiv==NULL){ printf("error of memory allocation\n"); free(A); free(b); exit(0); }
65+
A = (double *)malloc(n*n*sizeof(double)) ;
66+
if (A==NULL){ printf("error of memory allocation\n"); exit(0); }
67+
b = (double *)malloc(n*nrhs*sizeof(double)) ;
68+
if (b==NULL){ printf("error of memory allocation\n"); free(A); exit(0); }
69+
ipiv = (lapack_int *)malloc(n*sizeof(lapack_int)) ;
70+
if (ipiv==NULL){ printf("error of memory allocation\n"); free(A); free(b); exit(0); }
7171

7272
for( i = 0; i < n; i++ ) {
7373
for( j = 0; j < n; j++ ) A[i*lda+j] = ((double) rand()) / ((double) RAND_MAX) - 0.5;
74-
}
74+
}
7575

76-
for(i=0;i<n*nrhs;i++)
77-
b[i] = ((double) rand()) / ((double) RAND_MAX) - 0.5;
76+
for(i=0;i<n*nrhs;i++)
77+
b[i] = ((double) rand()) / ((double) RAND_MAX) - 0.5;
7878

7979
/* Print Entry Matrix */
8080
print_matrix_rowmajor( "Entry Matrix A", n, n, A, lda );
@@ -88,13 +88,13 @@ int main(int argc, char **argv) {
8888
b, ldb );
8989
/* Check for the exact singularity */
9090
if( info > 0 ) {
91-
printf( "The diagonal element of the triangular factor of A,\n" );
92-
printf( "U(%" LAPACK_IFMT ",%" LAPACK_IFMT ") is zero, so that A is singular;\n", info, info );
93-
printf( "the solution could not be computed.\n" );
94-
free(A);
95-
free(b);
96-
free(ipiv);
97-
exit( 1 );
91+
printf( "The diagonal element of the triangular factor of A,\n" );
92+
printf( "U(%" LAPACK_IFMT ",%" LAPACK_IFMT ") is zero, so that A is singular;\n", info, info );
93+
printf( "the solution could not be computed.\n" );
94+
free(A);
95+
free(b);
96+
free(ipiv);
97+
exit( 1 );
9898
}
9999
if (info <0) {
100100
free(A);

LAPACKE/example/example_DGESV_rowmajor_64.c

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -40,41 +40,41 @@ int main(int argc, char **argv) {
4040

4141
/* Locals */
4242
int64_t n, nrhs, lda, ldb, info;
43-
int i, j;
43+
int i, j;
4444
/* Local arrays */
45-
double *A, *b;
46-
int64_t *ipiv;
45+
double *A, *b;
46+
int64_t *ipiv;
4747

4848
/* Default Value */
49-
n = 5; nrhs = 1;
49+
n = 5; nrhs = 1;
5050

5151
/* Arguments */
52-
for( i = 1; i < argc; i++ ) {
53-
if( strcmp( argv[i], "-n" ) == 0 ) {
54-
n = atoi(argv[i+1]);
55-
i++;
56-
}
57-
if( strcmp( argv[i], "-nrhs" ) == 0 ) {
58-
nrhs = atoi(argv[i+1]);
59-
i++;
60-
}
61-
}
52+
for( i = 1; i < argc; i++ ) {
53+
if( strcmp( argv[i], "-n" ) == 0 ) {
54+
n = atoi(argv[i+1]);
55+
i++;
56+
}
57+
if( strcmp( argv[i], "-nrhs" ) == 0 ) {
58+
nrhs = atoi(argv[i+1]);
59+
i++;
60+
}
61+
}
6262

6363
/* Initialization */
6464
lda=n, ldb=nrhs;
65-
A = (double *)malloc(n*n*sizeof(double)) ;
66-
if (A==NULL){ printf("error of memory allocation\n"); exit(0); }
67-
b = (double *)malloc(n*nrhs*sizeof(double)) ;
68-
if (b==NULL){ printf("error of memory allocation\n"); free(A); exit(0); }
69-
ipiv = (int64_t *)malloc(n*sizeof(int64_t)) ;
70-
if (ipiv==NULL){ printf("error of memory allocation\n"); free(A); free(b); exit(0); }
65+
A = (double *)malloc(n*n*sizeof(double)) ;
66+
if (A==NULL){ printf("error of memory allocation\n"); exit(0); }
67+
b = (double *)malloc(n*nrhs*sizeof(double)) ;
68+
if (b==NULL){ printf("error of memory allocation\n"); free(A); exit(0); }
69+
ipiv = (int64_t *)malloc(n*sizeof(int64_t)) ;
70+
if (ipiv==NULL){ printf("error of memory allocation\n"); free(A); free(b); exit(0); }
7171

7272
for( i = 0; i < n; i++ ) {
7373
for( j = 0; j < n; j++ ) A[i*lda+j] = ((double) rand()) / ((double) RAND_MAX) - 0.5;
74-
}
74+
}
7575

76-
for(i=0;i<n*nrhs;i++)
77-
b[i] = ((double) rand()) / ((double) RAND_MAX) - 0.5;
76+
for(i=0;i<n*nrhs;i++)
77+
b[i] = ((double) rand()) / ((double) RAND_MAX) - 0.5;
7878

7979
/* Print Entry Matrix */
8080
print_matrix_rowmajor_64( "Entry Matrix A", n, n, A, lda );
@@ -88,13 +88,13 @@ int main(int argc, char **argv) {
8888
b, ldb );
8989
/* Check for the exact singularity */
9090
if( info > 0 ) {
91-
printf( "The diagonal element of the triangular factor of A,\n" );
92-
printf( "U(%" LAPACK_IFMT ",%" LAPACK_IFMT ") is zero, so that A is singular;\n", info, info );
93-
printf( "the solution could not be computed.\n" );
94-
free(A);
95-
free(b);
96-
free(ipiv);
97-
exit( 1 );
91+
printf( "The diagonal element of the triangular factor of A,\n" );
92+
printf( "U(%" LAPACK_IFMT ",%" LAPACK_IFMT ") is zero, so that A is singular;\n", info, info );
93+
printf( "the solution could not be computed.\n" );
94+
free(A);
95+
free(b);
96+
free(ipiv);
97+
exit( 1 );
9898
}
9999
if (info <0) {
100100
free(A);

0 commit comments

Comments
 (0)