コード例 #1
0
ファイル: ComplexNumber.c プロジェクト: sirenChen/ENEL487
// Multiple two complex number
void mulComplex(struct complexNumber a, struct complexNumber b) {
    struct complexNumber result;
    
    result.real = a.real * b.real - a.imag * b.imag;
    result.imag = a.imag * b.real + a.real * b.imag;
    
    printComplex(result);
}
コード例 #2
0
ファイル: ComplexNumber.c プロジェクト: sirenChen/ENEL487
// Subtraction two complex number
void subComplex(struct complexNumber a, struct complexNumber b) {
    struct complexNumber result;
    
    result.real = a.real - b.real;
    result.imag = a.imag - b.imag;
    
    printComplex(result);
}
コード例 #3
0
ファイル: ComplexNumber.c プロジェクト: sirenChen/ENEL487
// Add two complex number
void addComplex(struct complexNumber a, struct complexNumber b) {
    struct complexNumber result;
    
    result.real = a.real + b.real;
    result.imag = a.imag + b.imag;
    
    printComplex(result);
}
コード例 #4
0
ファイル: ComplexNumber.c プロジェクト: sirenChen/ENEL487
// print the reciprocal of the given complex number: 1/z
void invComplex(struct complexNumber a) {
    struct complexNumber result;
    
    result.real = a.real/(a.real*a.real+a.imag*a.imag);
    result.imag = (-a.imag)/(a.real*a.real+a.imag*a.imag);
    
    printComplex(result);
}
コード例 #5
0
ファイル: ComplexNumber.c プロジェクト: sirenChen/ENEL487
// For the given complex number, calculate the exponential
// of that number, exp(z)
void expComplex(struct complexNumber a) {
    struct complexNumber result;
    
    result.real = exp(a.real)*cos(a.imag);
    result.imag = exp(a.real)*sin(a.imag);
    
    printComplex(result);
}
コード例 #6
0
ファイル: ComplexNumber.c プロジェクト: sirenChen/ENEL487
// Devide complex a by complex b
void divComplex(struct complexNumber a, struct complexNumber b) {
    struct complexNumber result;
    
    result.real = (a.real * b.real + a.imag * b.imag)
                  / (b.real * b.real + b.imag * b.imag);
    result.imag = (a.imag * b.real - a.real * b.imag)
                  / (b.real * b.real + b.imag * b.imag);
    
    printComplex(result);
}
コード例 #7
0
ファイル: algebra.c プロジェクト: FelipeSenra/MSpice
void printComplexMatrix(Complex Yn[MAX_NOS+1][MAX_NOS+2],int nv){
     int ip ;
     int jp ;
     for (ip = 1 ; ip <= nv; ip++){
           for(jp = 1 ; jp <= nv+1; jp++){
                 printf("[%d,%d]", ip, jp);
                 printComplex(Yn[ip][jp]);
                 printf("\t");
           }
           printf("\n");
     }
     printf("\n");
}
コード例 #8
0
void TaoArithNode::print( ostream *out )
{
	if(arithType==0){
		printString( out );
	}else if(arithType==1){
		printNumber( out );
	}else if(arithType==2){
		printComplex( out );
	}else if(arithType==3){
		comArray->print( out );
	}else if(arithType==4){
		byteArray->print( out );
	}else if(arithType==5){
		shortArray->print( out );
	}else if(arithType==6){
		intArray->print( out );
	}else if(arithType==7){
		floatArray->print( out );
	}else if(arithType==8){
		doubleArray->print( out );
	}
}