Computer graphics lab report with code in cppAlamgir Hossain
This is the lab report for computer graphics in cpp language. Basically this course is only for the computer science and engineering students.
Problem list:
1.Program for the generation of Bresenham Line Drawing.
2. Program for the generation of Digital Differential Analyzer (DDA) Line Drawing.
3. Program for the generation of Midpoint Circle Drawing.
4. Program for the generation of Midpoint Ellipse Drawing.
5. Program for the generation of Translating an object.
6. Program for the generation of Rotating an Object.
7. Program for the generation of scaling an object.
All programs are coaded in cpp language .
The document contains C code for implementing various computer graphics algorithms including line drawing algorithms like Bresenham's line drawing algorithm, DDA line drawing algorithm, and symmetrical DDA line drawing algorithm. It also contains circle drawing algorithms using trigonometric, polynomial, Bresenham's and mid-point circle algorithms. Further, it includes ellipse drawing algorithms using trigonometric and polynomial methods. Finally, it shows an implementation of the Liang-Barsky line clipping algorithm.
The document contains 10 programs written in C programming language to perform various 2D and 3D graphics operations like drawing lines, rectangles, circles, ellipses, torus, scaling, rotating, shearing and reflecting objects. Program 1-5 demonstrate drawing basic shapes like line, rectangle, circle and ellipse. Program 6 draws a 3D torus using OpenGL. Program 7-9 demonstrate transformations like scaling, rotating and shearing of objects. Program 10 shows reflection of an object about x-axis, y-axis and origin.
This document provides instructions for drawing basic shapes in graphics mode in Turbo C++. It explains how to enable the graphics library, initialize graphics mode, and use functions like putpixel, line, rectangle, circle, ellipse, arc, bar and bar3d to draw pixels, lines, rectangles, circles, ellipses, arcs, filled rectangles and 3D filled rectangles. Examples of code are given to draw each shape. Programming assignments are provided to combine the shapes to draw a flag, hut, smiley face and fish.
1) The document is a numerical methods assignment submitted by a student to their professor. It contains 4 problems solved using various numerical methods like Gauss-Seidel iteration, Lagrange interpolation, and Newton divided differences.
2) For problem 1, the solutions to a system of equations using Gauss-Seidel iteration are found to be x1= 1, x2= -2, x3= -3.
3) For problem 4, the value of f(5) is estimated using Newton divided differences to be 92.
This program writes a C code to shear a cuboid. It includes graphics header files and uses the Bresenham's line algorithm to draw lines. The program defines a function called 'bress' to draw lines using the Bresenham algorithm. It takes coordinates of two points as input and uses conditions on the slope to determine the increment, endpoint and direction of line drawing. This function is used to draw the individual lines of the cuboid before and after shearing.
The document provides source code for generating and manipulating computer graphics using various algorithms. It includes algorithms for drawing lines, circles and curves, as well as algorithms for translating, rotating, and scaling two-dimensional and three-dimensional objects. The source code is written in C/C++ and uses graphics libraries to output the results. Various input parameters are taken from the user and output is displayed to demonstrate the algorithms.
The document discusses functional programming concepts in Scala including pure functions, referential transparency, algebraic data types, immutable linked lists, list folding, option types, higher order functions, and random number generation. It provides code examples for implementing immutable linked lists with pattern matching, list folding with foldLeft and foldRight, mapping, filtering and flatMapping lists, and defining monads and functors in Scala.
Computer graphics lab report with code in cppAlamgir Hossain
This is the lab report for computer graphics in cpp language. Basically this course is only for the computer science and engineering students.
Problem list:
1.Program for the generation of Bresenham Line Drawing.
2. Program for the generation of Digital Differential Analyzer (DDA) Line Drawing.
3. Program for the generation of Midpoint Circle Drawing.
4. Program for the generation of Midpoint Ellipse Drawing.
5. Program for the generation of Translating an object.
6. Program for the generation of Rotating an Object.
7. Program for the generation of scaling an object.
All programs are coaded in cpp language .
The document contains C code for implementing various computer graphics algorithms including line drawing algorithms like Bresenham's line drawing algorithm, DDA line drawing algorithm, and symmetrical DDA line drawing algorithm. It also contains circle drawing algorithms using trigonometric, polynomial, Bresenham's and mid-point circle algorithms. Further, it includes ellipse drawing algorithms using trigonometric and polynomial methods. Finally, it shows an implementation of the Liang-Barsky line clipping algorithm.
The document contains 10 programs written in C programming language to perform various 2D and 3D graphics operations like drawing lines, rectangles, circles, ellipses, torus, scaling, rotating, shearing and reflecting objects. Program 1-5 demonstrate drawing basic shapes like line, rectangle, circle and ellipse. Program 6 draws a 3D torus using OpenGL. Program 7-9 demonstrate transformations like scaling, rotating and shearing of objects. Program 10 shows reflection of an object about x-axis, y-axis and origin.
This document provides instructions for drawing basic shapes in graphics mode in Turbo C++. It explains how to enable the graphics library, initialize graphics mode, and use functions like putpixel, line, rectangle, circle, ellipse, arc, bar and bar3d to draw pixels, lines, rectangles, circles, ellipses, arcs, filled rectangles and 3D filled rectangles. Examples of code are given to draw each shape. Programming assignments are provided to combine the shapes to draw a flag, hut, smiley face and fish.
1) The document is a numerical methods assignment submitted by a student to their professor. It contains 4 problems solved using various numerical methods like Gauss-Seidel iteration, Lagrange interpolation, and Newton divided differences.
2) For problem 1, the solutions to a system of equations using Gauss-Seidel iteration are found to be x1= 1, x2= -2, x3= -3.
3) For problem 4, the value of f(5) is estimated using Newton divided differences to be 92.
This program writes a C code to shear a cuboid. It includes graphics header files and uses the Bresenham's line algorithm to draw lines. The program defines a function called 'bress' to draw lines using the Bresenham algorithm. It takes coordinates of two points as input and uses conditions on the slope to determine the increment, endpoint and direction of line drawing. This function is used to draw the individual lines of the cuboid before and after shearing.
The document provides source code for generating and manipulating computer graphics using various algorithms. It includes algorithms for drawing lines, circles and curves, as well as algorithms for translating, rotating, and scaling two-dimensional and three-dimensional objects. The source code is written in C/C++ and uses graphics libraries to output the results. Various input parameters are taken from the user and output is displayed to demonstrate the algorithms.
The document discusses functional programming concepts in Scala including pure functions, referential transparency, algebraic data types, immutable linked lists, list folding, option types, higher order functions, and random number generation. It provides code examples for implementing immutable linked lists with pattern matching, list folding with foldLeft and foldRight, mapping, filtering and flatMapping lists, and defining monads and functors in Scala.
How to extend map? Or why we need collections redesign? - Scalar 2017Szymon Matejczyk
This document discusses extending Scala's immutable Map to create a Grid data structure. It describes the complex inheritance hierarchy of Map, issues with covariance, and workarounds used to implement methods like row, +, - on the NestedGrid. It argues that the collections framework could be simplified by separating interfaces from implementations and fixing the inheritance structure to improve extensibility. Redesigning collections for more generic interfaces and avoiding CanBuildFrom could help address these issues.
This document provides an introduction to the Agda programming language through examples of its key features including:
1) Built-in support for natural numbers and inductive data types.
2) Notation for unicode symbols, records, indexed types, and propositional equality.
3) Support for parametric and indexed polymorphism, termination checking, and intuitionistic logic.
4) Examples of programming with dependent types including views, inverse functions, and proof of Socrates' mortality.
This document discusses side effects in Scala programs and proposes an IO monad to encapsulate side effects. Some key points:
- It introduces an IO trait that represents computations that may produce side effects. IO values can be combined using flatMap and map to sequence computations.
- Common side effects like printing are modeled as IO values. An interpreter is defined to actually run IO actions by pattern matching on the data structure.
- The document shows how the IO monad allows separating pure logic from effects, running effects in order, and capturing external interactions like input/output as data. This provides better control over side effects.
- Later sections discuss implementing the interpreter recursively to properly sequence nested effects. The
The Ring programming language version 1.8 book - Part 35 of 202Mahmoud Samir Fayed
This document discusses object-oriented programming in Ring and provides examples of defining classes and creating objects. It covers defining classes with attributes and methods, creating objects using the New keyword, accessing object attributes and methods using dot notation or braces, passing parameters to initialization methods, and defining private attributes and methods. Inheritance, dynamic attributes, packages, printing objects, and sorting lists of objects are also briefly mentioned.
The Ring programming language version 1.9 book - Part 38 of 210Mahmoud Samir Fayed
The document discusses object-oriented programming concepts in Ring including classes, objects, composition, setter and getter methods, private attributes and methods, operator overloading, and inheritance. It provides examples of defining classes and creating objects that demonstrate accessing object attributes and methods using braces, passing parameters to initialization methods, and overloading operators like + to work with custom classes. The examples show how to define classes with attributes and methods to encapsulate data and behavior into reusable objects.
The document describes algorithms for 2D transformations in computer graphics using C programming language. It discusses functions for translation, rotation, and scaling of 2D objects.
The algorithms take input for the type of transformation, parameters for the transformation, and coordinates of the 2D object. Translation simply adds the translation offsets to the x and y coordinates. Rotation rotates the object around the x-axis or y-axis based on the angle input. Scaling multiplies the x and y coordinates by respective scaling factors.
The transformed object is displayed on the graphics screen. Thus basic 2D transformations like translation, rotation, scaling are implemented through these algorithms in C.
This document discusses one-dimensional arrays in Visual Basic, including how to declare and populate them. It also covers multi-dimensional arrays, resizing arrays using Redim and Redim Preserve, erasing array elements, and looping through arrays using For loops. The document concludes with sections on calling subroutines by reference or by value and accessing array properties like LBound and UBound.
The document contains 10 programs for computer graphics operations including drawing graphics objects, 2D bars, pattern fills, pie charts, boundary fills, flood fills, translation, scaling, rotation, and window to viewport transformation. For each program, the code is provided to implement the specified graphics operation through functions like line(), circle(), rectangle(), bar(), pieslice(), bfill(), etc.
Wap in c to draw a line using DDA algorithmKapil Pandit
This C code uses the Digital Differential Algorithm (DDA) to draw a line on a graph between two points. It takes integer inputs for the x and y coordinates of the start and end points, calculates the change in x and y, and number of steps. It then uses putpixel to draw each point by rounding the incremental changes in x and y over the number of steps.
Monads are functional programming constructs that allow computations to be structured and composed in a purely functional way. They provide a way to compose functions of different types that can be logically combined. In Scala, monads can be represented using classes with map and flatMap methods, and for-comprehensions provide a cleaner syntax for working with monadic code. Some examples of monads in Scala include Option, List, and Writer.
This talk covers how to integrate D3 with SVG & Angular to create awesome visualisations, leveraging the modularity of D3 and it's data binding, with angular data binding and the reusability of directives.
Source code for this talk:
https://github.com/adamkleingit/d3-svg-angular
This document discusses using graphics to teach core Python concepts. It describes some challenges in using graphics APIs that are too complex or produce trivial results. Some solutions proposed are wrapping graphics APIs to simplify them, reusing code through classes, and using simple algorithms that generate complex patterns. Examples provided include using the POV-Ray and PIL libraries to generate 3D shapes and fractal images, as well as cellular automata with Tkinter. The goal is to focus on core Python concepts while producing interesting visual results.
The document contains C code implementations of several numerical methods for solving equations, performing numerical integration, and solving ordinary differential equations. These include the bisection method, Newton-Raphson method, interpolation methods, trapezoidal rule, Simpson's rules, and Euler and Runge-Kutta methods. For each method, the relevant theory is briefly explained, then C code is provided as an example to solve a sample problem using that particular method.
The document contains instructions for 15 computer graphics experiments to be completed in a Computer Graphics lab course. The experiments include programs to draw lines and shapes using algorithms like DDA, Bresenham, midpoint circle and ellipse algorithms. Programs for transformations like rotation, translation, scaling and shearing of shapes are also included. Boundary fill and flood fill algorithms are among the programs listed.
1. The document provides examples of solving linear and quadratic equations related to cost, profit, and rate problems.
2. It determines that the minimum production cost occurs when 8,000 units are produced daily based on the given quadratic equation.
3. It finds the minimum cost of production to be 260 soles by substituting 8,000 back into the original equation.
The document contains code snippets in C++ for graphics programs to draw various shapes and perform transformations like translation, rotation, and scaling using Turbo C++. It includes programs to draw a line, rotate a line, scale a line, display text horizontally and vertically, draw a house, fish, and man cartoon. Each code example contains functions for initialization, input, drawing objects using lines, circles, rectangles, and outputting text.
The document describes a computer graphics lab and contains programs to perform various graphics functions in C++ using graphics libraries. It includes 14 programs to:
1) Draw a line using the DDA algorithm
2) Draw a scenery using 20 graphics functions such as lines, circles, rectangles
3) Draw a circle using Bresenham's circle drawing algorithm
A function is a machine that takes an input (x-value) and produces a single output (y-value). Functions can be displayed as tables by plugging in x-values and listing the corresponding y-values, or as graphs by plotting points and connecting them. The domain is the set of all possible x-values, while the range is the set of all possible y-values. Functions can be combined, transformed, and have their slope and y-intercept found. Slope is the rise over run and indicates the rate of change, while the y-intercept is the point where the function crosses the y-axis.
SE Computer, Programming Laboratory(210251) University of PuneBhavesh Shah
This document contains code for drawing various shapes and lines in C++ using graphics functions. It includes classes for a pixel, line, and circle. The line class contains methods for drawing a line using DDA and Bresenham's algorithms. Additional methods allow drawing thick lines and dotted lines. The circle class inherits from line and contains a method for drawing a circle by putting pixels on the circumference. The document provides code examples and outputs for each task.
Computer Graphics in Java and Scala - Part 1bPhilip Schwarz
First see the Scala program from Part 1 translated into Java.
Then see the Scala program modified to produce a more intricate drawing.
Java Code: https://github.com/philipschwarz/computer-graphics-50-triangles-java
Scala Code: https://github.com/philipschwarz/computer-graphics-chessboard-with-a-great-many-squares-scala
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docxagnesdcarey33086
SAMPLE QUESTION:
Exercise 1: Consider the function
f (x,C)=
sin(C x)
Cx
(a) Create a vector x with 100 elements from -3*pi to 3*pi. Write f as an inline or anonymous function
and generate the vectors y1 = f(x,C1), y2 = f(x,C2) and y3 = f(x,C3), where C1 = 1, C2 = 2 and
C3 = 3. Make sure you suppress the output of x and y's vectors. Plot the function f (for the three
C's above), name the axis, give a title to the plot and include a legend to identify the plots. Add a
grid to the plot.
(b) Without using inline or anonymous functions write a function+function structure m-file that does
the same job as in part (a)
SAMPLE LAB WRITEUP:
MAT 275 MATLAB LAB 1 NAME: __________________________
LAB DAY and TIME:______________
Instructor: _______________________
Exercise 1
(a)
x = linspace(-3*pi,3*pi); % generating x vector - default value for number
% of pts linspace is 100
f= @(x,C) sin(C*x)./(C*x) % C will be just a constant, no need for ".*"
C1 = 1, C2 = 2, C3 = 3 % Using commans to separate commands
y1 = f(x,C1); y2 = f(x,C2); y3 = f(x,C3); % supressing the y's
plot(x,y1,'b.-', x,y2,'ro-', x,y3,'ks-') % using different markers for
% black and white plots
xlabel('x'), ylabel('y') % labeling the axis
title('f(x,C) = sin(Cx)/(Cx)') % adding a title
legend('C = 1','C = 2','C = 3') % adding a legend
grid on
Command window output:
f =
@(x,C)sin(C*x)./(C*x)
C1 =
1
C2 =
2
C3 =
3
(b)
M-file of structure function+function
function ex1
x = linspace(-3*pi,3*pi); % generating x vector - default value for number
% of pts linspace is 100
C1 = 1, C2 = 2, C3 = 3 % Using commans to separate commands
y1 = f(x,C1); y2 = f(x,C2); y3 = f(x,C3); % function f is defined below
plot(x,y1,'b.-', x,y2,'ro-', x,y3,'ks-') % using different markers for
% black and white plots
xlabel('x'), ylabel('y') % labeling the axis
title('f(x,C) = sin(Cx)/(Cx)') % adding a title
legend('C = 1','C = 2','C = 3') % adding a legend
grid on
end
function y = f(x,C)
y = sin(C*x)./(C*x);
end
Command window output:
C1 =
1
C2 =
2
C3 =
3
Joe Bob
Mon lab: 4:30-6:50
Lab 3
Exercise 1
(a) Create function M-file for banded LU factorization
function [L,U] = luband(A,p)
% LUBAND Banded LU factorization
% Adaptation to LUFACT
% Input:
% A diagonally dominant square matrix
% Output:
% L,U unit lower triangular and upper triangular such that LU=A
n = length(A);
L = eye(n); % ones on diagonal
% Gaussian Elimination
for j = 1:n-1
a = min(j+p.
How to extend map? Or why we need collections redesign? - Scalar 2017Szymon Matejczyk
This document discusses extending Scala's immutable Map to create a Grid data structure. It describes the complex inheritance hierarchy of Map, issues with covariance, and workarounds used to implement methods like row, +, - on the NestedGrid. It argues that the collections framework could be simplified by separating interfaces from implementations and fixing the inheritance structure to improve extensibility. Redesigning collections for more generic interfaces and avoiding CanBuildFrom could help address these issues.
This document provides an introduction to the Agda programming language through examples of its key features including:
1) Built-in support for natural numbers and inductive data types.
2) Notation for unicode symbols, records, indexed types, and propositional equality.
3) Support for parametric and indexed polymorphism, termination checking, and intuitionistic logic.
4) Examples of programming with dependent types including views, inverse functions, and proof of Socrates' mortality.
This document discusses side effects in Scala programs and proposes an IO monad to encapsulate side effects. Some key points:
- It introduces an IO trait that represents computations that may produce side effects. IO values can be combined using flatMap and map to sequence computations.
- Common side effects like printing are modeled as IO values. An interpreter is defined to actually run IO actions by pattern matching on the data structure.
- The document shows how the IO monad allows separating pure logic from effects, running effects in order, and capturing external interactions like input/output as data. This provides better control over side effects.
- Later sections discuss implementing the interpreter recursively to properly sequence nested effects. The
The Ring programming language version 1.8 book - Part 35 of 202Mahmoud Samir Fayed
This document discusses object-oriented programming in Ring and provides examples of defining classes and creating objects. It covers defining classes with attributes and methods, creating objects using the New keyword, accessing object attributes and methods using dot notation or braces, passing parameters to initialization methods, and defining private attributes and methods. Inheritance, dynamic attributes, packages, printing objects, and sorting lists of objects are also briefly mentioned.
The Ring programming language version 1.9 book - Part 38 of 210Mahmoud Samir Fayed
The document discusses object-oriented programming concepts in Ring including classes, objects, composition, setter and getter methods, private attributes and methods, operator overloading, and inheritance. It provides examples of defining classes and creating objects that demonstrate accessing object attributes and methods using braces, passing parameters to initialization methods, and overloading operators like + to work with custom classes. The examples show how to define classes with attributes and methods to encapsulate data and behavior into reusable objects.
The document describes algorithms for 2D transformations in computer graphics using C programming language. It discusses functions for translation, rotation, and scaling of 2D objects.
The algorithms take input for the type of transformation, parameters for the transformation, and coordinates of the 2D object. Translation simply adds the translation offsets to the x and y coordinates. Rotation rotates the object around the x-axis or y-axis based on the angle input. Scaling multiplies the x and y coordinates by respective scaling factors.
The transformed object is displayed on the graphics screen. Thus basic 2D transformations like translation, rotation, scaling are implemented through these algorithms in C.
This document discusses one-dimensional arrays in Visual Basic, including how to declare and populate them. It also covers multi-dimensional arrays, resizing arrays using Redim and Redim Preserve, erasing array elements, and looping through arrays using For loops. The document concludes with sections on calling subroutines by reference or by value and accessing array properties like LBound and UBound.
The document contains 10 programs for computer graphics operations including drawing graphics objects, 2D bars, pattern fills, pie charts, boundary fills, flood fills, translation, scaling, rotation, and window to viewport transformation. For each program, the code is provided to implement the specified graphics operation through functions like line(), circle(), rectangle(), bar(), pieslice(), bfill(), etc.
Wap in c to draw a line using DDA algorithmKapil Pandit
This C code uses the Digital Differential Algorithm (DDA) to draw a line on a graph between two points. It takes integer inputs for the x and y coordinates of the start and end points, calculates the change in x and y, and number of steps. It then uses putpixel to draw each point by rounding the incremental changes in x and y over the number of steps.
Monads are functional programming constructs that allow computations to be structured and composed in a purely functional way. They provide a way to compose functions of different types that can be logically combined. In Scala, monads can be represented using classes with map and flatMap methods, and for-comprehensions provide a cleaner syntax for working with monadic code. Some examples of monads in Scala include Option, List, and Writer.
This talk covers how to integrate D3 with SVG & Angular to create awesome visualisations, leveraging the modularity of D3 and it's data binding, with angular data binding and the reusability of directives.
Source code for this talk:
https://github.com/adamkleingit/d3-svg-angular
This document discusses using graphics to teach core Python concepts. It describes some challenges in using graphics APIs that are too complex or produce trivial results. Some solutions proposed are wrapping graphics APIs to simplify them, reusing code through classes, and using simple algorithms that generate complex patterns. Examples provided include using the POV-Ray and PIL libraries to generate 3D shapes and fractal images, as well as cellular automata with Tkinter. The goal is to focus on core Python concepts while producing interesting visual results.
The document contains C code implementations of several numerical methods for solving equations, performing numerical integration, and solving ordinary differential equations. These include the bisection method, Newton-Raphson method, interpolation methods, trapezoidal rule, Simpson's rules, and Euler and Runge-Kutta methods. For each method, the relevant theory is briefly explained, then C code is provided as an example to solve a sample problem using that particular method.
The document contains instructions for 15 computer graphics experiments to be completed in a Computer Graphics lab course. The experiments include programs to draw lines and shapes using algorithms like DDA, Bresenham, midpoint circle and ellipse algorithms. Programs for transformations like rotation, translation, scaling and shearing of shapes are also included. Boundary fill and flood fill algorithms are among the programs listed.
1. The document provides examples of solving linear and quadratic equations related to cost, profit, and rate problems.
2. It determines that the minimum production cost occurs when 8,000 units are produced daily based on the given quadratic equation.
3. It finds the minimum cost of production to be 260 soles by substituting 8,000 back into the original equation.
The document contains code snippets in C++ for graphics programs to draw various shapes and perform transformations like translation, rotation, and scaling using Turbo C++. It includes programs to draw a line, rotate a line, scale a line, display text horizontally and vertically, draw a house, fish, and man cartoon. Each code example contains functions for initialization, input, drawing objects using lines, circles, rectangles, and outputting text.
The document describes a computer graphics lab and contains programs to perform various graphics functions in C++ using graphics libraries. It includes 14 programs to:
1) Draw a line using the DDA algorithm
2) Draw a scenery using 20 graphics functions such as lines, circles, rectangles
3) Draw a circle using Bresenham's circle drawing algorithm
A function is a machine that takes an input (x-value) and produces a single output (y-value). Functions can be displayed as tables by plugging in x-values and listing the corresponding y-values, or as graphs by plotting points and connecting them. The domain is the set of all possible x-values, while the range is the set of all possible y-values. Functions can be combined, transformed, and have their slope and y-intercept found. Slope is the rise over run and indicates the rate of change, while the y-intercept is the point where the function crosses the y-axis.
SE Computer, Programming Laboratory(210251) University of PuneBhavesh Shah
This document contains code for drawing various shapes and lines in C++ using graphics functions. It includes classes for a pixel, line, and circle. The line class contains methods for drawing a line using DDA and Bresenham's algorithms. Additional methods allow drawing thick lines and dotted lines. The circle class inherits from line and contains a method for drawing a circle by putting pixels on the circumference. The document provides code examples and outputs for each task.
Computer Graphics in Java and Scala - Part 1bPhilip Schwarz
First see the Scala program from Part 1 translated into Java.
Then see the Scala program modified to produce a more intricate drawing.
Java Code: https://github.com/philipschwarz/computer-graphics-50-triangles-java
Scala Code: https://github.com/philipschwarz/computer-graphics-chessboard-with-a-great-many-squares-scala
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docxagnesdcarey33086
SAMPLE QUESTION:
Exercise 1: Consider the function
f (x,C)=
sin(C x)
Cx
(a) Create a vector x with 100 elements from -3*pi to 3*pi. Write f as an inline or anonymous function
and generate the vectors y1 = f(x,C1), y2 = f(x,C2) and y3 = f(x,C3), where C1 = 1, C2 = 2 and
C3 = 3. Make sure you suppress the output of x and y's vectors. Plot the function f (for the three
C's above), name the axis, give a title to the plot and include a legend to identify the plots. Add a
grid to the plot.
(b) Without using inline or anonymous functions write a function+function structure m-file that does
the same job as in part (a)
SAMPLE LAB WRITEUP:
MAT 275 MATLAB LAB 1 NAME: __________________________
LAB DAY and TIME:______________
Instructor: _______________________
Exercise 1
(a)
x = linspace(-3*pi,3*pi); % generating x vector - default value for number
% of pts linspace is 100
f= @(x,C) sin(C*x)./(C*x) % C will be just a constant, no need for ".*"
C1 = 1, C2 = 2, C3 = 3 % Using commans to separate commands
y1 = f(x,C1); y2 = f(x,C2); y3 = f(x,C3); % supressing the y's
plot(x,y1,'b.-', x,y2,'ro-', x,y3,'ks-') % using different markers for
% black and white plots
xlabel('x'), ylabel('y') % labeling the axis
title('f(x,C) = sin(Cx)/(Cx)') % adding a title
legend('C = 1','C = 2','C = 3') % adding a legend
grid on
Command window output:
f =
@(x,C)sin(C*x)./(C*x)
C1 =
1
C2 =
2
C3 =
3
(b)
M-file of structure function+function
function ex1
x = linspace(-3*pi,3*pi); % generating x vector - default value for number
% of pts linspace is 100
C1 = 1, C2 = 2, C3 = 3 % Using commans to separate commands
y1 = f(x,C1); y2 = f(x,C2); y3 = f(x,C3); % function f is defined below
plot(x,y1,'b.-', x,y2,'ro-', x,y3,'ks-') % using different markers for
% black and white plots
xlabel('x'), ylabel('y') % labeling the axis
title('f(x,C) = sin(Cx)/(Cx)') % adding a title
legend('C = 1','C = 2','C = 3') % adding a legend
grid on
end
function y = f(x,C)
y = sin(C*x)./(C*x);
end
Command window output:
C1 =
1
C2 =
2
C3 =
3
Joe Bob
Mon lab: 4:30-6:50
Lab 3
Exercise 1
(a) Create function M-file for banded LU factorization
function [L,U] = luband(A,p)
% LUBAND Banded LU factorization
% Adaptation to LUFACT
% Input:
% A diagonally dominant square matrix
% Output:
% L,U unit lower triangular and upper triangular such that LU=A
n = length(A);
L = eye(n); % ones on diagonal
% Gaussian Elimination
for j = 1:n-1
a = min(j+p.
Computer Graphics in Java and Scala - Part 1Philip Schwarz
Computer Graphics in Java and Scala - Part 1.
Continuous (Logical) and Discrete (Device) Coordinates,
with a simple yet pleasing example involving concentric triangles.
Scala code: https://github.com/philipschwarz/computer-graphics-50-triangles-scala
Errata:
1. Scala classes TrianglesPanel and Triangles need not be classes, they could just be objects.
This document discusses monads and continuations in functional programming. It provides examples of using monads like Option and List to handle failure in sequences of operations. It also discusses delimited continuations as a low-level control flow primitive that can implement exceptions, concurrency, and suspensions. The document proposes using monads to pass implicit state through programs by wrapping computations in a state transformer (ST) monad.
Some languages, like SML, Haskell, and Scala, have built-in support for pattern matching, which is a generic way of branching based on the structure of data.
While not without its drawbacks, pattern matching can help eliminate a lot of boilerplate, and it's often cited as a reason why functional programming languages are so concise.
In this talk, John A. De Goes talks about the differences between built-in patterns, and so-called first-class patterns (which are "do-it-yourself" patterns implemented using other language features).
Unlike built-in patterns, first-class patterns aren't magical, so you can store them in variables and combine them in lots of interesting ways that aren't always possible with built-in patterns. In addition, almost every programming language can support first-class patterns (albeit with differing levels of effort and type-safety).
During the talk, you'll watch as a mini-pattern matching library is developed, and have the opportunity to follow along and build your own pattern matching library in the language of your choice.
To plot graphs in MATLAB, you must:
1. Define the range of values for the x-axis variable
2. Define the function as y = f(x)
3. Use the plot command plot(x,y) to generate the graph
MATLAB allows adding titles, labels, grid lines, adjusting axis scales, and plotting multiple functions on the same graph. Subplot allows generating multiple plots in the same figure.
In this talk, Adrian Kashivskyy, Netguru iOS Developer, digs into rarely discussed Swift features, such as literal convertibles, interpolation convertibles, pattern matching, reflection and advanced Objective-C bridging.
This document provides an introduction to MATLAB. It discusses that MATLAB is a high-performance language for technical computing that integrates computation, visualization, and programming. It can be used for tasks like math and computation, algorithm development, modeling, simulation, prototyping, data analysis, and scientific graphics. MATLAB uses arrays as its basic data type and allows matrix and vector problems to be solved more quickly than with other languages. The document then provides examples of entering matrices, using basic MATLAB commands and functions, plotting graphs, and writing MATLAB code in M-files.
User Defined Aggregation in Apache Spark: A Love StoryDatabricks
Defining customized scalable aggregation logic is one of Apache Spark’s most powerful features. User Defined Aggregate Functions (UDAF) are a flexible mechanism for extending both Spark data frames and Structured Streaming with new functionality ranging from specialized summary techniques to building blocks for exploratory data analysis.
User Defined Aggregation in Apache Spark: A Love StoryDatabricks
This document summarizes a user's journey developing a custom aggregation function for Apache Spark using a T-Digest sketch. The user initially implemented it as a User Defined Aggregate Function (UDAF) but ran into performance issues due to excessive serialization/deserialization. They then worked to resolve it by implementing the function as a custom Aggregator using Spark 3.0's new aggregation APIs, which avoided unnecessary serialization and provided a 70x performance improvement. The story highlights the importance of understanding how custom functions interact with Spark's execution model and optimization techniques like avoiding excessive serialization.
More instructions for the lab write-up1) You are not obli.docxgilpinleeanna
More instructions for the lab write-up:
1) You are not obligated to use the 'diary' function. It was presented only for you convenience. You
should be copying and pasting your code, plots, and results into some sort of "Word" type editor that
will allow you to import graphs and such. Make sure you always include the commands to generate
what is been asked and include the outputs (from command window and plots), unless the problem
says to suppress it.
2) Edit this document: there should be no code or MATLAB commands that do not pertain to the
exercises you are presenting in your final submission. For each exercise, only the relevant code that
performs the task should be included. Do not include error messages. So once you have determined
either the command line instructions or the appropriate script file that will perform the task you are
given for the exercise, you should only include that and the associated output. Copy/paste these into
your final submission document followed by the output (including plots) that these MATLAB
instructions generate.
3) All code, output and plots for an exercise are to be grouped together. Do not put them in appendix, at
the end of the writeup, etc. In particular, put any mfiles you write BEFORE you first call them.
Each exercise, as well as the part of the exercises, is to be clearly demarked. Do not blend them all
together into some sort of composition style paper, complimentary to this: do NOT double space.
You can have spacing that makes your lab report look nice, but do not double space sections of text
as you would in a literature paper.
4) You can suppress much of the MATLAB output. If you need to create a vector, "x = 0:0.1:10" for
example, for use, there is no need to include this as output in your writeup. Just make sure you
include whatever result you are asked to show. Plots also do not have to be a full, or even half page.
They just have to be large enough that the relevant structure can be seen.
5) Before you put down any code, plots, etc. answer whatever questions that the exercise asks first.
You will follow this with the results of your work that support your answer.
SAMPLE QUESTION:
Exercise 1: Consider the function
f (x,C)=
sin(C x)
Cx
(a) Create a vector x with 100 elements from -3*pi to 3*pi. Write f as an inline or anonymous function
and generate the vectors y1 = f(x,C1), y2 = f(x,C2) and y3 = f(x,C3), where C1 = 1, C2 = 2 and
C3 = 3. Make sure you suppress the output of x and y's vectors. Plot the function f (for the three
C's above), name the axis, give a title to the plot and include a legend to identify the plots. Add a
grid to the plot.
(b) Without using inline or anonymous functions write a function+function structure m-file that does
the same job as in part (a)
SAMPLE LAB WRITEUP:
MAT 275 MATLAB LAB 1 NAME: ...
This document discusses animations in SwiftUI. It provides an overview of basic animation properties like position, size, angle, shape, and color that can be animated. It also covers transformation animations using translation, scaling, rotation, and opacity. Different timing functions for animations like linear, easeIn, easeOut, easeInOut, and spring are demonstrated. The key concepts of Animatable and VectorArithmetic protocols that enable property animation are explained. Examples are provided to illustrate animating a star shape by modifying its edges property over time. Custom animatable modifiers like PercentageModifier are also demonstrated to create progress indicators. The document concludes by emphasizing the effective way to implement animation in SwiftUI.
The document describes exercises on structures and strings in C programming. It defines a structure called _PLAYER to store details of players like name, date of birth, height and weight. It then shows how to define the structure, read and print records of multiple players from an array of _PLAYER structures. Functions are defined to find the tallest player, print names in descending order of height, check character cases, convert case of characters in a string, and compute operations on structures like distance between points.
This document introduces new commands in Matlab lesson 3 for creating plots, including plot(x,y) to create Cartesian plots, semilogx(x,y) to plot log(x) vs y, and bar(x) to create bar graphs. It also discusses using titles, labels, text and grids with plots, and describes polar, multiple, and fancy plots using different line styles and point markers. The document concludes with instructions for printing and saving graphic plots.
This document provides a 3-sentence summary of the given document:
The document is a tutorial introduction to high-performance Haskell that covers topics like lazy evaluation, reasoning about space usage, benchmarking, profiling, and making Haskell code run faster. It explains concepts like laziness, thunks, and strictness and shows how to define tail-recursive functions, use foldl' for a strict left fold, and force evaluation of data constructor arguments to avoid space leaks. The goal is to help programmers optimize Haskell code and make efficient use of multiple processor cores.
This document provides an overview of new features in Java 8, including lambda expressions, default methods on interfaces, bulk data operations on collections, and other library enhancements. It discusses how lambda expressions allow for closures in Java and interface evolution with default methods. It also provides code examples of using lambda expressions for event handling and animation in a JavaFX application that makes circles vanish when clicked.
An oft-cited benefit of learning a functional language is that it changes one's approach to solving problems for the better. The functional approach has such a strict emphasis on simplistic and highly composable solutions that an otherwise varied landscape of solution possibilities narrows down to only a few novel options.
This talk introduces functional design and showcases its application to several real-world problems. It will briefly cover denotational semantics and several math-based programming abstractions. Finally, the talk will conclude with a comparison of functional solutions to the results more traditional design methodologies.
No prior knowledge of functional programming or functional programming languages is required for this talk. All the examples make use of the C++ programming language.
The document outlines various statistical and data analysis techniques that can be performed in R including importing data, data visualization, correlation and regression, and provides code examples for functions to conduct t-tests, ANOVA, PCA, clustering, time series analysis, and producing publication-quality output. It also reviews basic R syntax and functions for computing summary statistics, transforming data, and performing vector and matrix operations.
ACM Distinguished Program: Cooperative Testing and Analysis: Human-Tool, Tool...Tao Xie
Here are a few key points about coding duels:
- They encourage learning by having users write code to match secret implementations, getting automated feedback from Pex.
- The feedback loop of writing code -> running tests -> improving code is educational. Users learn by trial and error.
- It's gamified learning - there's a competitive element to match the secret behavior that some may find motivating.
- By generating tests automatically, Pex removes the tedium of manual testing so users can focus on the coding problem.
- Over time, as users get better at passing tests, the secret implementations get more complex, increasing the learning challenge.
- It's a human-centric approach where users are
Similar to Fast and Simple Statistics with Scala (20)
WWDC 2024 Keynote Review: For CocoaCoders AustinPatrick Weigel
Overview of WWDC 2024 Keynote Address.
Covers: Apple Intelligence, iOS18, macOS Sequoia, iPadOS, watchOS, visionOS, and Apple TV+.
Understandable dialogue on Apple TV+
On-device app controlling AI.
Access to ChatGPT with a guest appearance by Chief Data Thief Sam Altman!
App Locking! iPhone Mirroring! And a Calculator!!
UI5con 2024 - Bring Your Own Design SystemPeter Muessig
How do you combine the OpenUI5/SAPUI5 programming model with a design system that makes its controls available as Web Components? Since OpenUI5/SAPUI5 1.120, the framework supports the integration of any Web Components. This makes it possible, for example, to natively embed own Web Components of your design system which are created with Stencil. The integration embeds the Web Components in a way that they can be used naturally in XMLViews, like with standard UI5 controls, and can be bound with data binding. Learn how you can also make use of the Web Components base class in OpenUI5/SAPUI5 to also integrate your Web Components and get inspired by the solution to generate a custom UI5 library providing the Web Components control wrappers for the native ones.
E-commerce Development Services- Hornet DynamicsHornet Dynamics
For any business hoping to succeed in the digital age, having a strong online presence is crucial. We offer Ecommerce Development Services that are customized according to your business requirements and client preferences, enabling you to create a dynamic, safe, and user-friendly online store.
Microservice Teams - How the cloud changes the way we workSven Peters
A lot of technical challenges and complexity come with building a cloud-native and distributed architecture. The way we develop backend software has fundamentally changed in the last ten years. Managing a microservices architecture demands a lot of us to ensure observability and operational resiliency. But did you also change the way you run your development teams?
Sven will talk about Atlassian’s journey from a monolith to a multi-tenanted architecture and how it affected the way the engineering teams work. You will learn how we shifted to service ownership, moved to more autonomous teams (and its challenges), and established platform and enablement teams.
Using Query Store in Azure PostgreSQL to Understand Query PerformanceGrant Fritchey
Microsoft has added an excellent new extension in PostgreSQL on their Azure Platform. This session, presented at Posette 2024, covers what Query Store is and the types of information you can get out of it.
Malibou Pitch Deck For Its €3M Seed Roundsjcobrien
French start-up Malibou raised a €3 million Seed Round to develop its payroll and human resources
management platform for VSEs and SMEs. The financing round was led by investors Breega, Y Combinator, and FCVC.
14 th Edition of International conference on computer visionShulagnaSarkar2
About the event
14th Edition of International conference on computer vision
Computer conferences organized by ScienceFather group. ScienceFather takes the privilege to invite speakers participants students delegates and exhibitors from across the globe to its International Conference on computer conferences to be held in the Various Beautiful cites of the world. computer conferences are a discussion of common Inventions-related issues and additionally trade information share proof thoughts and insight into advanced developments in the science inventions service system. New technology may create many materials and devices with a vast range of applications such as in Science medicine electronics biomaterials energy production and consumer products.
Nomination are Open!! Don't Miss it
Visit: computer.scifat.com
Award Nomination: https://x-i.me/ishnom
Conference Submission: https://x-i.me/anicon
For Enquiry: Computer@scifat.com
Hand Rolled Applicative User ValidationCode KataPhilip Schwarz
Could you use a simple piece of Scala validation code (granted, a very simplistic one too!) that you can rewrite, now and again, to refresh your basic understanding of Applicative operators <*>, <*, *>?
The goal is not to write perfect code showcasing validation, but rather, to provide a small, rough-and ready exercise to reinforce your muscle-memory.
Despite its grandiose-sounding title, this deck consists of just three slides showing the Scala 3 code to be rewritten whenever the details of the operators begin to fade away.
The code is my rough and ready translation of a Haskell user-validation program found in a book called Finding Success (and Failure) in Haskell - Fall in love with applicative functors.
Unveiling the Advantages of Agile Software Development.pdfbrainerhub1
Learn about Agile Software Development's advantages. Simplify your workflow to spur quicker innovation. Jump right in! We have also discussed the advantages.
Artificia Intellicence and XPath Extension FunctionsOctavian Nadolu
The purpose of this presentation is to provide an overview of how you can use AI from XSLT, XQuery, Schematron, or XML Refactoring operations, the potential benefits of using AI, and some of the challenges we face.
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsPeter Muessig
The UI5 tooling is the development and build tooling of UI5. It is built in a modular and extensible way so that it can be easily extended by your needs. This session will showcase various tooling extensions which can boost your development experience by far so that you can really work offline, transpile your code in your project to use even newer versions of EcmaScript (than 2022 which is supported right now by the UI5 tooling), consume any npm package of your choice in your project, using different kind of proxies, and even stitching UI5 projects during development together to mimic your target environment.
Flutter is a popular open source, cross-platform framework developed by Google. In this webinar we'll explore Flutter and its architecture, delve into the Flutter Embedder and Flutter’s Dart language, discover how to leverage Flutter for embedded device development, learn about Automotive Grade Linux (AGL) and its consortium and understand the rationale behind AGL's choice of Flutter for next-gen IVI systems. Don’t miss this opportunity to discover whether Flutter is right for your project.
24. import flip.implicits._
// get 100 random variables from standard normal distribution
val underlying0 = NumericDist.normal(0.0, 1.0)
val (underlying1, samples) = underlying0.samples(100)
// update samples to sketch
val sketch0 = Sketch.empty[Double]
val sketch1 = samples.foldLeft(sketch0) {
case (sketch, sample) ⇒ sketch.update(sample)
}
// get probability for interval [0.0, 1.0]
println("result: " + sketch1.probability(0.0, 1.0))
println("expected: " + underlying1.probability(0.0, 1.0))
24
25. import flip.implicits._
// get 100 random variables from standard normal distribution
val underlying0 = NumericDist.normal(0.0, 1.0)
val (underlying1, samples) = underlying0.samples(100)
// update samples to sketch
val sketch0 = Sketch.empty[Double]
val sketch1 = samples.foldLeft(sketch0) {
case (sketch, sample) ⇒ sketch.update(sample)
}
// get probability for interval [0.0, 1.0]
println("result: " + sketch1.probability(0.0, 1.0))
println("expected: " + underlying1.probability(0.0, 1.0))
25
26. import flip.implicits._
// get 100 random variables from standard normal distribution
val underlying0 = NumericDist.normal(0.0, 1.0)
val (underlying1, samples) = underlying0.samples(100)
// update samples to sketch
val sketch0 = Sketch.empty[Double]
val sketch1 = samples.foldLeft(sketch0) {
case (sketch, sample) ⇒ sketch.update(sample)
}
// get probability for interval [0.0, 1.0]
println("result: " + sketch1.probability(0.0, 1.0))
println("expected: " + underlying1.probability(0.0, 1.0))
26
27. import flip.implicits._
// get 100 random variables from standard normal distribution
val underlying0 = NumericDist.normal(0.0, 1.0)
val (underlying1, samples) = underlying0.samples(100)
// update samples to sketch
val sketch0 = Sketch.empty[Double]
val sketch1 = samples.foldLeft(sketch0) {
case (sketch, sample) ⇒ sketch.update(sample)
}
// get probability for interval [0.0, 1.0]
println("result: " + sketch1.probability(0.0, 1.0))
println("expected: " + underlying1.probability(0.0, 1.0))
27
28. // probability for interval [0.0, 1.0]
sketch.probability(0.0, 1.0)
// probability density at 0.0
sketch.pdf(0.0)
// median
sketch.median
// 100 random samples
sketch.samples(100)
28
38. Average speed for three different speed
models
for {
speedA ← speedSketchA
speedB ← speedSketchB
speedC ← speedSketchC
} yield (speedA + speedB + speedC) / 3
38
39. Average height for male and female
for {
gender ← genderDist
height ← gender match {
case Male ⇒ maleHeightDist
case Female ⇒ femaleHeightDist
}
} yield height
39
40. !
Flip: Fast, Lightweight library for
Information and Probability
4 Most fast and lightweight
4 Pure-functional
4 Unique and high-level open source
4 GitHub: https://github.com/xxxnell/flip
40
42. Further Readings
4 Kernel Density Estimation in Spark
4 A frequentist approach to probability
4 Probability Distribution Monad (code)
4 Foundations of the Giry Monad
4 Platform for statistical modeling
4 A library for probabilistic modeling on TF
42