Class Notes (811,705)
CS 137 (16)
Lecture 11

# Programming Lecture 11 & 12.docx

4 Pages
108 Views

School
Department
Computer Science
Course
CS 137
Professor
Andrew Morton
Semester
Fall

Description
Programming Lecture 11 & 12 October 23, 2012 Complex Numbers  x + yi o x is real o y is imaginary  i = sqrt(-1) 2  i = -1  x + 1 = 0  x = -1  Addition o (x + yi) + (w + zi) = (x + w) + (y + z)i  Multiplication o (x + yi)(w + zi) = xw – yz + (xz + yw)i  Roll-your-own in C89 cplex.h: #ifndef CPLEX_H #define CPLEX_H typedef struct { double r; //real double i; //imaginary }cplex; cplex cplexConstruct (double r, double i); cplex cplexAdd(cplex a, cplex b); cplex cplexMult(cplex a, cplex b); void cplexPrint(cplex a); #endif cplex.c: #include #include “cplex.h” cplex cplexConstruct (double r, double i) { cplex c; c.r=r; c.i=I; //OR cplex c = {r, i}; return c; } cplex cplexAdd (cplex a, cplex b) { cplex c = {a.r+b.r, a.i+b.i}; return c; } cplex cplexMult (cplex a, cplex b) { cplex c = {a.r*b.r-a.i*b.i, a.r*b.i+a.i*b.r}; return c; } void cplexPrint (cplex a) { printf(“%g + %gi\n”, a.r, a.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); b = cplexConstruct (3,4); c = cplexAdd(a,b); cplexPrint(c); // 4 + 6i c = cpleMult(a,b); cplexPrint(c); // -5 + 10i return 0; } main.c in C99: #include #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; } Website Crawling  How does Google read your mind? o Structure and content of web pages o User behavior o “Quality” of web pages (static rank)  Early version: PageRank o Random Surfer Model  Pretend you’re “surfing”  At each step, you either:  Follow a link o Probability d  Jump to a “random” page o Probability 1-d  The PageRank of page Q, R(Q) if the probability you’re on page Q after surfing for a long time  Computing  PageRank – R(Q) o Out(P)  He number of links out of P o N pages in total o R(Q) = (1-d)/N + d ∑ )) )
More Less

Related notes for CS 137
Me

OR

Don't have an account?

Join OneClass

Access over 10 million pages of study
documents for 1.3 million courses.

Join to view

OR

By registering, I agree to the Terms and Privacy Policies
Just a few more details

So we can recommend you notes for your school.