Revisão | 403c5717f5ef269805fe703550b7328c2a52957f (tree) |
---|---|
Hora | 2012-07-04 19:13:29 |
Autor | Mikiya Fujii <mikiya.fujii@gmai...> |
Commiter | Mikiya Fujii |
Mndo::Calchessian is partially implemented. #28554
git-svn-id: https://svn.sourceforge.jp/svnroot/molds/trunk@865 1136aad2-a195-0410-b898-f5ea1d11b9d8
@@ -479,6 +479,146 @@ public: | ||
479 | 479 | MallocerFreer::SubtCurrentMalloced(static_cast<double>(size1*size2*size3*size4*size5*size6*sizeof(T))); |
480 | 480 | *matrix = NULL; |
481 | 481 | } |
482 | + | |
483 | + //7d | |
484 | + template<typename T> void Malloc(T******** matrix, int size1, int size2, int size3, int size4, int size5, int size6, int size7) const{ | |
485 | + if(*matrix!=NULL){ | |
486 | + return; | |
487 | + } | |
488 | + double wannaMalloc = static_cast<double>(size1*size2*size3*size4*size5*size6*size7*sizeof(T)); | |
489 | + this->CheckLimitHeap(wannaMalloc); | |
490 | + | |
491 | + T *p1d=NULL, **p2d=NULL, ***p3d=NULL, ****p4d=NULL, *****p5d=NULL, ******p6d=NULL, *******p7d=NULL; | |
492 | + try{ | |
493 | + p1d = new T[size1*size2*size3*size4*size5*size6*size7]; | |
494 | + if(p1d==NULL){ | |
495 | + throw MolDSException(this->errorMessageMallocFailure); | |
496 | + } | |
497 | + p2d = new T*[size1*size2*size3*size4*size5*size6]; | |
498 | + if(p2d==NULL){ | |
499 | + throw MolDSException(this->errorMessageMallocFailure); | |
500 | + } | |
501 | + p3d = new T**[size1*size2*size3*size4*size5]; | |
502 | + if(p3d==NULL){ | |
503 | + throw MolDSException(this->errorMessageMallocFailure); | |
504 | + } | |
505 | + p4d = new T***[size1*size2*size3*size4]; | |
506 | + if(p4d==NULL){ | |
507 | + throw MolDSException(this->errorMessageMallocFailure); | |
508 | + } | |
509 | + p5d = new T****[size1*size2*size3]; | |
510 | + if(p5d==NULL){ | |
511 | + throw MolDSException(this->errorMessageMallocFailure); | |
512 | + } | |
513 | + p6d = new T*****[size1*size2]; | |
514 | + if(p6d==NULL){ | |
515 | + throw MolDSException(this->errorMessageMallocFailure); | |
516 | + } | |
517 | + p7d = new T******[size1]; | |
518 | + if(p6d==NULL){ | |
519 | + throw MolDSException(this->errorMessageMallocFailure); | |
520 | + } | |
521 | + | |
522 | + for(int i=0;i<size1;i++){ | |
523 | + p7d[i] = &p6d[i*size2]; | |
524 | + for(int j=0;j<size2;j++){ | |
525 | + p7d[i][j] = &p5d[i*size2*size3+j*size3]; | |
526 | + for(int k=0;k<size3;k++){ | |
527 | + p7d[i][j][k] = &p4d[i*size2*size3*size4+j*size3*size4+k*size4]; | |
528 | + for(int l=0;l<size4;l++){ | |
529 | + p7d[i][j][k][l] = &p3d[i*size2*size3*size4*size5+ | |
530 | + j*size3*size4*size5+ | |
531 | + k*size4*size5+ | |
532 | + l*size5]; | |
533 | + for(int m=0;m<size5;m++){ | |
534 | + p7d[i][j][k][l][m] = &p2d[i*size2*size3*size4*size5*size6+ | |
535 | + j*size3*size4*size5*size6+ | |
536 | + k*size4*size5*size6+ | |
537 | + l*size5*size6+ | |
538 | + m*size6]; | |
539 | + for(int n=0;n<size6;n++){ | |
540 | + p7d[i][j][k][l][m][n] = &p1d[i*size2*size3*size4*size5*size6*size7+ | |
541 | + j*size3*size4*size5*size6*size7+ | |
542 | + k*size4*size5*size6*size7+ | |
543 | + l*size5*size6*size7+ | |
544 | + m*size6*size7+ | |
545 | + n*size7]; | |
546 | + } | |
547 | + } | |
548 | + } | |
549 | + } | |
550 | + } | |
551 | + } | |
552 | + *matrix = p7d; | |
553 | + MallocerFreer::AddCurrentMalloced(wannaMalloc); | |
554 | + this->Initialize<T>(*matrix, size1, size2, size3, size4, size5, size6, size7); | |
555 | + } | |
556 | + catch(MolDSException ex){ | |
557 | + if(p1d!=NULL){ | |
558 | + delete[] p1d; | |
559 | + } | |
560 | + if(p2d!=NULL){ | |
561 | + delete[] p2d; | |
562 | + } | |
563 | + if(p3d!=NULL){ | |
564 | + delete[] p3d; | |
565 | + } | |
566 | + if(p4d!=NULL){ | |
567 | + delete[] p4d; | |
568 | + } | |
569 | + if(p5d!=NULL){ | |
570 | + delete[] p5d; | |
571 | + } | |
572 | + if(p6d!=NULL){ | |
573 | + delete[] p6d; | |
574 | + } | |
575 | + if(p7d!=NULL){ | |
576 | + delete[] p7d; | |
577 | + } | |
578 | + throw ex; | |
579 | + } | |
580 | + } | |
581 | + | |
582 | + template<typename T> void Initialize(T******* matrix, int size1, int size2, int size3, int size4, int size5, int size6, int size7) const{ | |
583 | + for(int i=0;i<size1;i++) { | |
584 | + for(int j=0;j<size2;j++){ | |
585 | + for(int k=0;k<size3;k++){ | |
586 | + for(int l=0;l<size4;l++){ | |
587 | + for(int m=0;m<size5;m++){ | |
588 | + for(int n=0;n<size6;n++){ | |
589 | + for(int o=0;o<size7;o++){ | |
590 | + matrix[i][j][k][l][m][n][o] = 0.0; | |
591 | + } | |
592 | + } | |
593 | + } | |
594 | + } | |
595 | + } | |
596 | + } | |
597 | + } | |
598 | + } | |
599 | + | |
600 | + template<typename T> void Free(T******** matrix, int size1, int size2, int size3, int size4, int size5, int size6, int size7) const{ | |
601 | + if(*matrix==NULL){ | |
602 | + return; | |
603 | + } | |
604 | + T *p1d=NULL, **p2d=NULL, ***p3d=NULL,****p4d=NULL, *****p5d=NULL, ******p6d=NULL, *******p7d=NULL; | |
605 | + p7d = *matrix; | |
606 | + p6d = p7d[0]; | |
607 | + p5d = p6d[0]; | |
608 | + p4d = p5d[0]; | |
609 | + p3d = p4d[0]; | |
610 | + p2d = p3d[0]; | |
611 | + p1d = p2d[0]; | |
612 | + delete [] p7d; | |
613 | + delete [] p6d; | |
614 | + delete [] p5d; | |
615 | + delete [] p4d; | |
616 | + delete [] p3d; | |
617 | + delete [] p2d; | |
618 | + delete [] p1d; | |
619 | + MallocerFreer::SubtCurrentMalloced(static_cast<double>(size1*size2*size3*size4*size5*size6*size7*sizeof(T))); | |
620 | + *matrix = NULL; | |
621 | + } | |
482 | 622 | private: |
483 | 623 | MallocerFreer(); |
484 | 624 | ~MallocerFreer(); |
@@ -1817,7 +1817,6 @@ void Mndo::CalcHessianSCF(double** hessianSCF) const{ | ||
1817 | 1817 | totalNumberAOs, |
1818 | 1818 | this->molecule->GetNumberAtoms(), |
1819 | 1819 | CartesianType_end); |
1820 | - | |
1821 | 1820 | this->CalcOrbitalElectronPopulationFirstDerivatives(orbitalElectronPopulationFirstDerivatives); |
1822 | 1821 | |
1823 | 1822 |
@@ -1828,6 +1827,7 @@ void Mndo::CalcHessianSCF(double** hessianSCF) const{ | ||
1828 | 1827 | // atomA == atomB |
1829 | 1828 | for(int axisA2 = axisA; axisA2<CartesianType_end; axisA2++){ |
1830 | 1829 | int l = atomAIndex*CartesianType_end + axisA2; |
1830 | + hessianSCF[k][l] = 0.0; | |
1831 | 1831 | for(int atomCIndex=0; atomCIndex<this->molecule->GetNumberAtoms(); atomCIndex++){ |
1832 | 1832 | // second derivatives of the nuclear repulsions |
1833 | 1833 | hessianSCF[k][l] += this->GetDiatomCoreRepulsionSecondDerivative(atomAIndex, |
@@ -1849,6 +1849,7 @@ void Mndo::CalcHessianSCF(double** hessianSCF) const{ | ||
1849 | 1849 | for(int atomBIndex=atomAIndex+1; atomBIndex<this->molecule->GetNumberAtoms(); atomBIndex++){ |
1850 | 1850 | for(int axisB = XAxis; axisB<CartesianType_end; axisB++){ |
1851 | 1851 | int l = atomAIndex*CartesianType_end + axisB; |
1852 | + hessianSCF[k][l] = 0.0; | |
1852 | 1853 | |
1853 | 1854 | // second derivatives of the nuclear repulsions |
1854 | 1855 | hessianSCF[k][l] -= this->GetDiatomCoreRepulsionSecondDerivative(atomAIndex, |