DSP Lab. Week 5 complex Doug Young Suh Media Lab. Rm401 Last update : September 16, 2015.

Slides:



Advertisements
Similar presentations
Object Oriented Programming
Advertisements

Chapter 7 Completing a Program
Integer Arithmetic. Operator Priority Real Number Arithmetic.
Programming in C Chapter 10 Structures and Unions
Operator overloading redefine the operations of operators
STRING AN EXAMPLE OF REFERENCE DATA TYPE. 2 Primitive Data Types  The eight Java primitive data types are:  byte  short  int  long  float  double.
Department of Computer Engineering Faculty of Engineering, Prince of Songkla University 1 5 – Abstract Data Types.
CSC241 Object-Oriented Programming (OOP) Lecture No. 9.
1 Class Vehicle #include #define N 10../.. 2 Class Vehicle class vehicle { public: float speed; char colour[N+1]; char make[N+1];
1 COSC2767: Object-Oriented Programming Haibin Zhu, Ph. D. Associate Professor of CS, Nipissing University.
OBJECT-ORIENTED PROGRAMMING. What is an “object”? Abstract entity that contains data and actions Attributes (characteristics) and methods (functions)
Wednesday, 10/2/02, Slide #1 CS 106 Intro to CS 1 Wednesday, 10/2/02  QUESTIONS (on HW02 – due at 5 pm)??  Today:  Review of parameters  Introduction.
1 Procedural Concept The main program coordinates calls to procedures and hands over appropriate data as parameters.
1 Chapter 8 Objects and Classes. 2 Motivations After learning the preceding chapters, you are capable of solving many programming problems using selections,
OBJECT ORIENTED PROGRAMMING IN C++ LECTURE
1.11 Introduction to OOP academy.zariba.com 1. Lecture Content 1.What is OOP and why use it? 2.Classes and objects 3.Static classes 4.Properties, fields.
Designing Data Types. 2 Object Oriented Programming Procedural programming. [verb-oriented] n Tell the computer to do this. n Tell the computer to do.
Programming Languages
Object Oriented Programming using C++. Overview Problem Solving Features of an OOL Basic Syntax Programming Paradigms.
Object-Oriented Programming with C++ Yingcai Xiao.
Sadegh Aliakbary Sharif University of Technology Fall 2011.
Java ProgrammingtMyn1 Java Programming Timo Mynttinen Mikkeli University of Applied Sciences.
Object Oriented Programming Elhanan Borenstein copyrights © Elhanan Borenstein.
14/3/02 Sudeshna Sarkar, CSE, IIT Kharagpur1 Structures, ADT Lecture 25 14/3/2002.
Checking Equality of Reference Variables. Arrays and objects are both “reference” types n They are allocated a chunk of memory in the address space n.
CMPE-013/L: “C” Programming Gabriel Hugh Elkaim – Spring 2013 CMPE-013/L Structures Gabriel Hugh Elkaim Spring 2013.
ICOM 4035 – Data Structures Dr. Manuel Rodríguez Martínez Electrical and Computer Engineering Department Lecture 4 – August 30, 2001.
CS1201: Programming Language 2 Classes and objects By: Nouf Aljaffan Edited by : Nouf Almunyif.
Copyright © Curt Hill Structured Data What this course is about.
 Structures are like arrays except that they allow many variables of different types grouped together under the same name. For example you can create.
C Programming Lecture 11 : Structure. Data Type struct union enum typedef.
CS 11 C++ track: lecture 3 Today const and const -correctness operator overloading.
SNPL1 Woochang Lim C+OOP = C++ C (non OOP)  C++ (non OOP+OOP)  Java (OOP) Object-Oriented Design  Object-Oriented Programming Programming with C++
Salman Marvasti Sharif University of Technology Winter 2015.
1 OOP - An Introduction ISQS 6337 John R. Durrett.
Ch6 & 12 Note Dr. Wang. Strings for C, C++, Java C++ string – string str = “VWC”; C- string – char cstr[21] = {‘V’, ‘W’, ‘C’, ‘\0’}; char cstr2[21] =
Interfaces An interface is like an extreme case of an abstract class – However, an interface is not a class – It is a type that can be satisfied by any.
CPS120: Introduction to Computer Science Lecture 16 Data Structures, OOP & Advanced Strings.
9 장 추상 데이터 타입 및 모듈 (Abstract Data Type & Module).
1 CSE Programming in C++. 2 Overview Sign roster list Syllabus and Course Policies Introduction to C++ About Lab 1 Fill Questionnaire.
Object Oriented Programming Session # 03.  Abstraction: Process of forming of general and relevant information from a complex scenarios.  Encapsulation:
From C to C++. What is C++ C++ is the work of Bjarne Stroustrup of AT&T Bell Labs. C++ is a mostly upward compatible extension of C that provides: A better.
Copyright 2005, The Ohio State University CSE – Introduction to C++ Name: Shirish Tatikonda Time: T 3:30 PM Room: BE 394
1 Pointers: Parameter Passing and Return. 2 Passing Pointers to a Function Pointers are often passed to a function as arguments  Allows data items within.
CMSC 341 Lecture 2. Announcements Tutors wanted Office hrs Project 1.
CPSC 233 Tutorial 5 February 9 th /10 th, Java Classes Each Java class contains a set of instance variables and methods Instance Variables: Type.
ENEE150 – 0102 ANDREW GOFFIN Abstract Data Types.
Structure A Data structure is a collection of variable which can be same or different types. You can refer to a structure as a single variable, and to.
1 Another Example: Complex Class #ifndef _Complex_H #define _Complex_H class Complex { float re, im; // by default private public: Complex(float x = 0,
Sadegh Aliakbary Sharif University of Technology Fall 2010.
Chapter 1. Experiments and Probabilities Doug Young Suh Media Lab.
Programming in Java Transitioning from Alice. Becomes not myFirstMethod but …. public static void main (String[] arg) { // code for testing classes goes.
Object-Oriented Programming Review 1. Object-Oriented Programming Object-Oriented Programming languages vary but generally all support the following features:
DSP Lab. Week 2 Matrix multiplication Doug Young Suh Media Lab. Rm401 Last update : September 9, 2015.
DSP Lab. Week 2 Matrix multiplication Doug Young Suh Media Lab. Rm401 Last update : September 9, 2015.
Overloading C++ supports the concept of overloading Two main types
The C++ Data Types Fundamental Data Types
Programmer Defined Types and Classes
CSC 143 Introduction to C++ Classes and User-Defined Data Types
COMPUTER 2430 Object Oriented Programming and Data Structures I
DSP Lab. Week 7 CDMA and noise
DSP Lab. Week 1 Drawing sinusoidal waves
Object-Oriented Programming (OOP) Lecture No. 18
COMPUTER 2430 Object Oriented Programming and Data Structures I
C++ Programming ㅎㅎ String OOP Class Constructor & Destructor.
DSP Lab. Week 12 DFT audio Doug Young Suh Media Lab. Rm401
Introduction to Programming
CMPE 152: Compiler Design February 28 / March 5 Lab
ㅎㅎ Sixth step for Learning C++ Programming Pointer new, delete String
CMPE 152: Compiler Design March 7/12 Lab
Presentation transcript:

DSP Lab. Week 5 complex Doug Young Suh Media Lab. Rm401 Last update : September 16, 2015

5 important constants in the universe 1 j -j Im Re

Complex number, re jθ 1 j -j Im Re r θ re jθ

Complex variables Solve x=1, x 2 =1, x 3 =1, x 4 =1,∙∙∙∙, x 100 =1 1 j -j Im Re 1 j -j Im Re 1 j -j Im Re 1 j -j Im Re 1 j -j Im Re x 2 =1 x 3 =1 x 4 =1 x 8 =1 x 100 =1

Complex Exponential signals Cont.  

Complex signals 1 j -j Im Re

OOP, object-oriented programming 객체지향적 프로그래밍 C++, Smalltalk, Object Pascal, Java C++ 의 4 대 특성 캡슐화 (Encapsulation) 추상화 (Abstraction) 상속 (Inheritance) 다형성 (Polymorphism) 예 ) 학교에 관계있는 사람 : 교수, 학생 MediaLab, Kyunghee University 7

Encapsulation 자료와 함수를 단일 객체로서 캡슐화한다. (member functions and member data) class Employ{ // 클라스 직원 // Data members // 자료 요소들 char Name[61], Phone[9]; // char 이름 [61], 전화번호 [9]; int Salary, Dependents; // int 월급, 부양자수 ; // member functions // 멤버 함수들 void DialPhone(); // void 전화거시요 (); void PrintPayCheck(float HoursWorked); // void 월급봉투를 _ 찍으시요 ( 일한 _ 시간 ); } Employ Frank,Bob,Judy,Sales[10]; // 직원 * 우득만, 최가현, 영업부 [10], Frank.PrintPayCheck(40); // 우득만 -> 전화를거시요 (); 클래스 (class) 는 단 하나의 실체 (instance) 로 존재, 메모리 할당을 요구하지 않음. 객체 (object) 는 클래스의 실체로서 int, char, float 등과 같은 data type 으로 취급되 며 메모리할당이 필요하다. 하드웨어에 대한 종속성을 숨길 수 있다. MediaLab, Kyunghee University 8

Abstraction (Operator overloading) 표준연산자 (+,-,*,/, > 등등 ) 들이 적용될 때 기대되는 행동 양식을 클래스마다 정의할 수 있다. 예를 들어 우리가 스트링 Str 이라는 클래스를 사용한다고하자. Str string1; Str string2 = "Test"; Str string3 = " of Strings"; string1 = string2 + string3; 우리는 string1 이 “Test of Strings" 가 되기를 기대한다. C++ 에 서는 이렇게 되도록 할 수 있다. Str 이라는 클래스를 지정할 때 Str 이라는 클래스에 대해서는 + 라는 연산자가 위와 같은 기능을 하도록 프로그램한다. MediaLab, Kyunghee University 9

Inheritance and contaiment 상속 isA : member data, member function 포함 hasA MediaLab, Kyunghee University 10 컨디션계산 ( ) 오늘의전투력계산 ( ) 전투후전투력변경 ( ) 전투력 힘 지략 컨디션 선수 ( 동물 ) 뛰다 ( ) 다리 포유류 날다 ( ) 다리 날개 조류 isA Oscilloscope Radio TV Color TV monitor Remote controller isA hasA

Polymorphism 여러 개의 함수가 하나의 이름으로 class test { int age; float weight; void Print(int); void Print(float); }; void test::Print(int i){cout << "You are " << i << " years old.\n"; } void test::Print(float x){ cout << "Your weight is " << x << " kg.\n"; } test young,hun; young.print(18); Hun.print(55.5); MediaLab, Kyunghee University 11

Class and object MediaLab, Kyunghee University 12 Class : type, no memory 빵틀 Object : instance, memory 빵 Ex) Class objects int i, j; float x, y; test young, hun;

Complex in C In main( ) #include "complex.h“ ….. complex x[4]; x[0].re = 45; x->im = 20; (x+1)->im = -10; x[1].im = 25; Cplus(x[0],x[1],x+2); In complex.h typedef struct { Real re, im; } complex; void CPlus(complex,complex,complex*); ……….. In complex.cpp void CPlus(complex a,complex b,complex *c) { c->re = a.re + b.re; c->im = a.im + b.im; } MediaLab, Kyunghee University13

Complex in C++ In main( ) #include "complex.h“ ….. complex x[4]; x[0] = complex(45,20); x[1] = complex(-10,25); x[2] = x[0] + x[1]; In complex.h class complex{ public: double re,im; complex(){ re = im = 0; }; complex(double x,double y){ re = x; im = y; }; complex operator+(const complex&); ……….. In complex.cpp complex complex::operator+(const complex& y){ complex c; c.re = re + y.re; c.im = im + y.im; return c; } MediaLab, Kyunghee University14

Week 5 assignment MediaLab, Kyunghee University15