//=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*= // Program huckel //=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*= #include "cip.h" #include "nxgraph.h" //---- declaration of class Array2d class Array2d { int dim; // dimension of this array double* head; // pointer to assign head of this array double** array; // pointers to assign head of each rows public: Array2d( int _dim ); ~Array2d(); double* operator [] ( int i ); int Dim( void ); void SetZero( void ); void SetUnit( void ); void Print( void ); }; //---- definition of class Array2d //---- constructor, allocates memory and set pointers Array2d::Array2d( int _dim ) { dim = _dim; head = new (double) [dim*dim]; array = new (double*) [dim]; for( int i=0 ; i= 0.0 ) return +1; return -1; } //---- rotates Vp and Vq by give cos and sin inline void Rotate( double c, double s, double& Vp, double& Vq ) { double _Vp; Vp = c*(_Vp=Vp) - s*Vq; Vq = s*_Vp + c*Vq; } //---- calculates eigen values and eigen vectors void Jacobi( Array2d& A, Array2d& V ) { double theta, s, c, t; int p, q, r, nonzero; V.SetUnit(); do{ nonzero = 0; for( p=0 ; p0.0 ){ r = int(c*24.0); NXSetColor( NX_PINK ); NXFillCircle( x, y-r, r ); NXSetColor( NX_CYAN ); NXFillCircle( x, y+r, r ); }else{ r = int(-c*24.0); NXSetColor( NX_CYAN ); NXFillCircle( x, y-r, r ); NXSetColor( NX_PINK ); NXFillCircle( x, y+r, r ); } } //---- draws orbitals void Draw( Array2d& A, Array2d& V ) { int i,j; NXClearWindow(); for( j=0 ; j