@@ -213,8 +213,8 @@ namespace CTF {
213
213
if (lda == nrow/pc){
214
214
memcpy (this ->data , (char *)data_, sizeof (dtype)*this ->size );
215
215
} else {
216
- for (int i=0 ; i<ncol/pc; i++){
217
- memcpy (this ->data +i*lda*sizeof (dtype),(char *)(data_+i*lda), nrow*sizeof (dtype)/pr);
216
+ for (int64_t i=0 ; i<ncol/pc; i++){
217
+ memcpy (this ->data +i*lda*sizeof (dtype),(char *)(data_+i*lda), (( int64_t ) nrow) *sizeof (dtype)/pr);
218
218
}
219
219
}
220
220
} else {
@@ -258,7 +258,7 @@ namespace CTF {
258
258
if (lda == nrow/pc){
259
259
memcpy ((char *)data_, this ->data , sizeof (dtype)*this ->size );
260
260
} else {
261
- for (int i=0 ; i<ncol/pc; i++){
261
+ for (int64_t i=0 ; i<ncol/pc; i++){
262
262
memcpy ((char *)(data_+i*lda), this ->data +i*lda*sizeof (dtype), nrow*sizeof (dtype)/pr);
263
263
}
264
264
}
@@ -437,11 +437,11 @@ namespace CTF {
437
437
438
438
this ->read_mat (desca, A);
439
439
440
- dtype * tau = (dtype*)malloc (n *sizeof (dtype));
440
+ dtype * tau = (dtype*)malloc ((( int64_t )n) *sizeof (dtype));
441
441
dtype dlwork;
442
442
CTF_SCALAPACK::pgeqrf<dtype>(m,n,A,1 ,1 ,desca,tau,(dtype*)&dlwork,-1 ,&info);
443
443
int lwork = get_int_fromreal<dtype>(dlwork);
444
- dtype * work = (dtype*)malloc (lwork*sizeof (dtype));
444
+ dtype * work = (dtype*)malloc ((( int64_t ) lwork) *sizeof (dtype));
445
445
CTF_SCALAPACK::pgeqrf<dtype>(m,n,A,1 ,1 ,desca,tau,work,lwork,&info);
446
446
447
447
@@ -453,14 +453,14 @@ namespace CTF {
453
453
R = Matrix<dtype>(Q);
454
454
else {
455
455
R = Matrix<dtype>(desca,dQ,*this ->wrld ,*this ->sr );
456
- R = R.slice (0 ,m *(n-1 )+n-1 );
456
+ R = R.slice (0 ,(( int64_t )m) *(n-1 )+n-1 );
457
457
}
458
458
459
459
460
460
free (work);
461
461
CTF_SCALAPACK::porgqr<dtype>(m,n,n,dQ,1 ,1 ,desca,tau,(dtype*)&dlwork,-1 ,&info);
462
462
lwork = get_int_fromreal<dtype>(dlwork);
463
- work = (dtype*)malloc (lwork*sizeof (dtype));
463
+ work = (dtype*)malloc ((( int64_t ) lwork) *sizeof (dtype));
464
464
CTF_SCALAPACK::porgqr<dtype>(m,n,n,dQ,1 ,1 ,desca,tau,work,lwork,&info);
465
465
Q = Matrix<dtype>(desca, dQ, (*(this ->wrld )));
466
466
free (work);
@@ -502,22 +502,24 @@ namespace CTF {
502
502
int64_t kpr = k/pr + (k % pr != 0 );
503
503
int64_t kpc = k/pc + (k % pc != 0 );
504
504
int64_t npc = n/pc + (n % pc != 0 );
505
+
505
506
CTF_SCALAPACK::cdescinit (descu, m, k, 1 , 1 , 0 , 0 , ictxt, mpr, &info);
506
507
CTF_SCALAPACK::cdescinit (descvt, k, n, 1 , 1 , 0 , 0 , ictxt, kpr, &info);
507
- dtype * A = (dtype*)malloc (this ->size *sizeof (dtype));
508
+
509
+ dtype * A = (dtype*)CTF_int::alloc (this ->size *sizeof (dtype));
508
510
509
511
510
- dtype * u = (dtype*)new dtype[ mpr*kpc] ;
511
- dtype * s = (dtype*)new dtype[k] ;
512
- dtype * vt = (dtype*)new dtype[ kpr*npc] ;
512
+ dtype * u = (dtype*)CTF_int::alloc ( sizeof ( dtype)* mpr*kpc) ;
513
+ dtype * s = (dtype*)CTF_int::alloc ( sizeof ( dtype)*k) ;
514
+ dtype * vt = (dtype*)CTF_int::alloc ( sizeof ( dtype)* kpr*npc) ;
513
515
this ->read_mat (desca, A);
514
516
515
517
int lwork;
516
518
dtype dlwork;
517
519
CTF_SCALAPACK::pgesvd<dtype>(' V' , ' V' , m, n, NULL , 1 , 1 , desca, NULL , NULL , 1 , 1 , descu, vt, 1 , 1 , descvt, &dlwork, -1 , &info);
518
520
519
521
lwork = get_int_fromreal<dtype>(dlwork);
520
- dtype * work = (dtype*)malloc (sizeof (dtype)*lwork);
522
+ dtype * work = (dtype*)CTF_int::alloc (sizeof (dtype)*(( int64_t ) lwork) );
521
523
522
524
CTF_SCALAPACK::pgesvd<dtype>(' V' , ' V' , m, n, A, 1 , 1 , desca, s, u, 1 , 1 , descu, vt, 1 , 1 , descvt, work, lwork, &info);
523
525
@@ -537,18 +539,18 @@ namespace CTF {
537
539
}
538
540
if (rank > 0 && rank < k) {
539
541
S = S.slice (0 , rank-1 );
540
- U = U.slice (0 , rank*(m)-1 );
541
- VT = VT.slice (0 , k*n -(k-rank+1 ));
542
+ U = U.slice (0 , rank*(( int64_t ) m)-1 );
543
+ VT = VT.slice (0 , k*(( int64_t )n) -(k-rank+1 ));
542
544
}
543
545
544
- free (A);
545
- delete [] u ;
546
- delete [] s ;
547
- delete [] vt ;
546
+ CTF_int::cdealloc (A);
547
+ CTF_int::cdealloc (u) ;
548
+ CTF_int::cdealloc (s) ;
549
+ CTF_int::cdealloc (vt) ;
548
550
free (desca);
549
551
free (descu);
550
552
free (descvt);
551
- free (work);
553
+ CTF_int::cdealloc (work);
552
554
553
555
}
554
556
0 commit comments