CS137 Lecture Notes - Lecture 11: Cplex, Pagerank, Ansi C

112 views4 pages

Document Summary

X + yi: x is real, y is imaginary i = sqrt(-1) i2 = -1. Addition: (x + yi) + (w + zi) = (x + w) + (y + z)i. Multiplication: (x + yi)(w + zi) = xw yz + (xz + yw)i. }cplex; cplex cplexconstruct (double r, double i); cplex cplexadd(cplex a, cplex b); cplex cplexmult(cplex a, cplex b); void cplexprint(cplex a); #include cplex. h cplex cplexconstruct (double r, double i) cplex c; c. r=r; c. i=i; //prints 1 + 2i when a = 1. 0 + 2. 0i main. c: #include cplex. h int main() cplex a, b, c; a = cplexconstruct (1,2); = cplexconstruct (3,4); c = cplexadd(a,b); cplexprint(c); c = cplemult(a,b); cplexprint(c); return 0; #include int main () double complex a = 1 + 2*i; double complex c = 3 + 4*i; double complex c = a+b; printf( %g+%gi\n , creal(c), cimag(c)); return 0;

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents