SVG Shapes • I love SVG! https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Basic_Shapes
View full slide show




Step 1: Matrix Multiplication A Simple Host Version in C // Matrix multiplication on the (CPU) host in double precision 44 WIDTH N WIDTH k P WIDTH void MatrixMulOnHost(float* M, float* N, float* P, int WIDTH) { int i, j, k; double a, b, sum; j for (i = 0; i < WIDTH; ++i) for (j = 0; j < WIDTH; ++j) { sum = 0; for (k = 0; k < WIDTH; ++k) { a = M[i * WIDTH + k]; M b = N[k * WIDTH + j]; sum += a * b; i } P[i * WIDTH + j] = sum; } } k WIDTH
View full slide show




TABLE SIZE • • • Initially, a table’s width is determined by the width of its columns whose width is determined by the width of the cells within the column whose width is determined by the widest item in each column – This is very flexible but may give your table an unbalanced look – You can control this width by setting the table’s width combined with setting the column (cell) width. You can control the total width of the table using a style within the table tag – width:value; – Value is normally designated as a percentage (e.g. 80%) or in pixels (px) • If you use pixels, the table will always be the same size regardless of the window size. Percent will scale to window size – NOTE: the width= and height= attributes (not in a style) are deprecated. Table height is rarely specified. Table height is normally, automatically based on the number of rows in the table and height of those rows.
View full slide show




Step 4: Kernel Function __global__ void MatrixMulKernel(float* Md, float* Nd, float* Pd, int WIDTH) { float Pvalue = 0; k WIDTH for (int k = 0; k < WIDTH; ++k) { float Melement = Md[threadIdx.y*WIDTH+k]; float Nelement = Nd[k*WIDTH+threadIdx.x]; Pvalue += Melement * Nelement; } Nd tx Pd[threadIdx.y*WIDTH+threadIdx.x] = Pvalue; } Md Pd ty tx k 47 WIDTH ty WIDTH WIDTH
View full slide show




Configure Width and Height with CSS width property ○ Configures the width of an element’s content h1 { width: 80%; } min-width property ○ Configures minimum width of an element max-width property ○ Configures the maximum width of an element height property ○ Configures the height of an element h1 { height: 100px; }
View full slide show




           Command: PLINE Specify start point:1 ,1. Current line-width is 0.0000 Specify next point or [Arc/Halfwidth/Length/Undo/Width]: W Specify starting width< 0.0000>:0.15 Specify ending width< 0.0150>: Specify next point or [Arc/Halfwidth/Length/Undo/Width]: 42,1 Specify next point or [Arc/Close/Halfwidth/Length/Undo/Width: 42,32 Specify next point or [Arc/Close/Halfwidth/Length/Undo/Width]: 1,32 Specify next point or [Arc/Close/Halfwidth/Length/Undo/Width ]: C Command: Customizing Interface Elements and Commands 113
View full slide show




How can we calculate those points? • Assumptions: – – – – right-handed coordinate system camera at origin (0,0,0) camera look-at is (1, 0, 0) camera up is (0, 1, 0) • Easy, simple arithmetic: – – – – – – – – front-top-right = (near, height/2, width/2) front-bottom-right = (near, -height/2, width/2) front-top-left = (near, height/2, -width/2) front-bottom-left = (near, -height/2, -width/2) back-top-right = (far, height/2, width/2) back-bottom-right = (far, -height/2, width/2) back-top-left = (far, height/2, -width/2) back-bottom-left = (far, -height/2, -width/2) Calculate these values once, at start of game
View full slide show




textio write procedures procedure write (L : inout line; value: in bit; justified: in side := right; field: in width := 0); procedure write (L : inout line; value: in bit_vector; justified: in side := right; field: in width := 0); procedure write (L : inout line; value: in boolean; justified: in side := right; field: in width := 0); procedure write (L : inout line; value: in character; justified: in side := right; field: in width := 0); procedure write (L : inout line; value: in integer; justified: in side := right; field: in width := 0); procedure write (L : inout line; value: in real; justified: in side := right; field: in width := 0); procedure write (L : inout line; value: in string; justified: in side := right; field: in width := 0); procedure write (L : inout line; value: in time; justified: in side := right; field: in width; unit: in time:= ns)
View full slide show




C++ VB #include Imports System.IO ifstream inFile; Dim inFile As StreamReader inFile.open(“measures.txt”); Dim outFile As StreamWriter ofstream outFile; inFile = File.OpenText Why are these Why are theseneeded? needed? (“measures.txt”) outFile.open(“results.txt”); outFile = File.CreateText . (“results.txt”) . . Assume . Assumethat thatwe wehave: have: . int Dim As int length; length; length Dim length length As Integer Integer inFile >> length; = Cint(inFile.Readline) int width; Dim . As Dim width width As Integer Integer inFile >> width;int width; width = Cint(inFile.ReadLine) int area; Dim area As Integer int area; Dim =area As Integer area=length*width; area length * width outFile << area << endl; outFile.WriteLine(area.ToString) NOT NOTneeded, needed,the theWrite Writeand andWriteLine WriteLine methods methodsare are“overloaded.” “overloaded.” . . . . . must What Whatother othercode code mustwe we . add to this program? add to this program? inFile.close() 18
View full slide show




G4PVReplica – pAxis, width, offset pAxis 高高高高高高高高高 kXAxis, kYAxis, kZAxis const G4String& pName, 高高高高高高高高高高高高高高高 G4LogicalVolume* pLogical, -width*(nReplicas-1)*0.5+n*width G4LogicalVolume* pMother, 高高高高高高 const EAxis pAxis, Offset 高高高高高高 const G4int nReplicas, pAxis 高高高高高高高高 const G4double width, kRho const G4double offset=0 ); 高高高高高高高 width*n+offset 高高 widt width*(n+1)+offset 高高高高高高高 h • pAxis 高 phi 高高高高高 kPhi offse 高高高高高高高 width*n+offset 高高 t widt width*(n+1)+offset 高高高高高高高 G4PVReplica( • • h offse t Geant4 高高高高高高高高高高 - M.Asai (SLAC) 15
View full slide show




Different Line Styles size=12 width-100% size=6 width-50% size=3 width-25% size=1 width-10% XP



You can use line styles to improve the appearance of your Web page. Creating Web Pages with HTML, 3e Prepared by: C. Hueckstaedt, Tutorial 1 55

View full slide show




Answer public class Rectangle { int x, y, width, height; public Rectangle(int x, int y, int width, int height) { this.x = x; this.y = y; this.width = width; this.height = height; } /** * overriden equals method * */ public boolean equals(Object object) { Rectangle r = (Rectangle)object; if(x==r.x && y==r.y && width==r.width && height==r.height) return true; return false; } public String toString() { return "Rectangle [x:"+x+" y:"+y+" width:"+width+" height:"+height+"]"; } public static void main(String args[]) { Rectangle r1 = new Rectangle(10,20,50,50); Rectangle r2 = new Rectangle(10,20,50,50); Rectangle r3 = new Rectangle(10,50,50,50); System.out.println("r1= "+r1); System.out.println("r2= "+r2); System.out.println("r3= "+r3); System.out.println("r1.equals(r2)"+r1.equals(r2)); System.out.println("r1.equals(r3)"+r1.equals(r3)); } Copyright © 2014 by John Wiley } & Sons. All rights reserved. 65
View full slide show




Answer public class Rectangle { int x, y, width, height; public Rectangle(int x, int y, int width, int height) { this.x = x; this.y = y; this.width = width; this.height = height; } /** * overriden equals method * */ public boolean equals(Object object) { Rectangle r = (Rectangle)object; if(x==r.x && y==r.y && width==r.width && height==r.height) return true; return false; } public String toString() { return "Rectangle [x:"+x+" y:"+y+" width:"+width+" height:"+height+"]"; } public static void main(String args[]) { Rectangle r1 = new Rectangle(10,20,50,50); Rectangle r2 = new Rectangle(10,20,50,50); Rectangle r3 = new Rectangle(10,50,50,50); System.out.println("r1= "+r1); System.out.println("r2= "+r2); System.out.println("r3= "+r3); System.out.println("r1.equals(r2)"+r1.equals(r2)); System.out.println("r1.equals(r3)"+r1.equals(r3)); } Copyright © 2014 by John Wiley } & Sons. All rights reserved. 58
View full slide show




Graphics methods Method name Description g.drawLine(x1, y1, x2, y2); line between points (x1, y1), (x2, y2) g.drawOval(x, y, width, height); outline largest oval that fits in a box of size width * height with top-left at (x, y) g.drawRect(x, y, width, height); outline of rectangle of size width * height with top-left at (x, y) g.drawString(text, x, y); text with bottom-left at (x, y) g.fillOval(x, y, width, height); fill largest oval that fits in a box of size width * height with top-left at (x, y) g.fillRect(x, y, width, height); fill rectangle of size width * height with top-left at (x, y) g.setColor(Color); set Graphics to paint any following shapes in the given color 7
View full slide show




Rectangle class class Rectangle { // Data members private double width = 1, height = 1; private static String color = "yellow"; // Constructor public Rectangle() { } // Constructor public Rectangle(double width, double height) { this.width = width; this.height = height; } Now put it all together and compile it. public double getWidth() { return width; } public double getHeight() { return height; } public static String getColor() { return color; } public static void setColor(String color) { Rectangle.color = color; } Did you get it? public double getArea() { return width * height; } public double getPerimeter() { return 2 * (width + height); } }
View full slide show




Programming Model: Square Matrix Multiplication Example P=M*N   Each is of size WIDTH x WIDTH N Basic Idea:  WIDTH  One thread calculates one element of P  M and N are loaded WIDTH times from global memory P WIDTH M 43 WIDTH WIDTH
View full slide show




Histogram of V65D (cont.) • Next we erect a rectangle (a “bar,” if you wish) on each class interval, so that the area [not height] of each rectangle is proportional to the frequency associated with that class interval. • How tall should each rectangle be? • The width of each rectangle is the width of the class interval, and [from 3rd grade we remember that] Area = Height × Width so Height = Area / Width • Since Area here represents Frequency, we have the formula: Height = Frequency / Width, where Width is the width of the class interval.
View full slide show




Step 1: Matrix Multiplication A Simple Host Version in C // Matrix multiplication on the (CPU) host in double precision void MatrixMulOnHost(float* M, float* N, float* P, int Width) { for (int i = 0; i < Width; ++i) for (int j = 0; j < Width; ++j) { double sum = 0; for (int k = 0; k < Width; ++k) { double a = M[i * Width + k]; double b = N[k * Width + j]; sum += a * b; } P[i * Width + j] = sum; } } CUDA Programming Basics – Slide 55
View full slide show




// The volume function calculates and returns the volume of the // box with the parameterized dimensions. It returns an invalid // value if any dimension is determined to be invalid. double volume(double length, double width, double height) { if ((length >= 0.0) && (width >= 0.0) && (height >= 0.0)) return (length * width * height); else return -1.0; } // The surfaceArea function calculates and returns the surface // of the box with the parameterized dimensions. It returns an // invalid value if any dimension is determined to be invalid. double surfaceArea(double length, double width, double height) { double frontArea = length * height; double sideArea = width * height; double topArea = length * width; if ((length >= 0.0) && (width >= 0.0) && (height >= 0.0)) return (2 * frontArea + 2 * sideArea + 2 * topArea); else return -1.0; } 30.7 28.7 46.8 33.2 45.9 45.9 67 3 23.4 56.7 25.8 20.4 39.6 19.4 33.1 15.7 82.6 75.2 91.7 17.8 66.2 17.1 18.0 62.8 78.1 62.1 10.6 43.3 4.7 81.7 60.0 66.2 13.9 28.6 22.6 29.5 80.1 18.2 12.7 33.9 50.3 17.4 90.2 87.4 77.1 39.1 CHAPTER 5 – User-Defined Functions // // // // // // The function header is identical to the prototype (except for the semicolon at the end of the prototype). Since the functions are defined with type double they must return a value of that type (unlike the void that the main function). Note parameters are treated as variables inside the function, and that the functions 4 may have their own
View full slide show




Rectangle.java public class Rectangle extends Shape { private int length; private int width; public Rectangle(String color, int length, int width) { super(color); this.length = length; this.width = width; } @Override public String toString() { return "Rectangle of length=" + length + " and width=" + width + ", subclass of " + super.toString(); } @Override public double getArea() { return length*width; } } Copyright © 2014 by John Wiley & Sons. All rights reserved. 76
View full slide show