데이타를 여러방식으로 구현할 때 Multiple Representations 데이터 구현방식마다 꼬리표를 붙이고. 데이터 속내용 감추기 원리를 유지하면서. 예를 들어 complex number data 구현방안들을 생각해 보자 – complex number 만들기 make-from-real-imag:

Slides:



Advertisements
Similar presentations
1 Lecture 16: Tables and OOP. 2 Tables -- get and put.
Advertisements

Fall 2008Programming Development Techniques 1 Topic 12 Multiple Representations of Abstract Data – Complex Numbers Section
Structure and Interpretation of Computer Programs* Section 2.4 – 2.5 Presenter: Xiang Zhang 05/04/ * Harold A., Gerald J. S., Julie S.. Structure.
8.3 THE COMPLEX PLANE & DEMOIVRE’S THEOREM Precalculus.
ET-314 Week 11 Nov 7, 2014 Topic(s): 19.1 Vectors.
Solving Linear Equations  Many applications require solving systems of linear equations.  One method for solving linear equations is to write a matrix.
Getting started with ML ML is a functional programming language. ML is statically typed: The types of literals, values, expressions and functions in a.
11.2 Geometric Representations of Complex Numbers.
Fall 2008Programming Development Techniques 1 Topic 15 Generic Arithmetic Operations Section &
6.001 SICP SICP – September ? 6001-Introduction Trevor Darrell 32-D web page: section.
מבוא מורחב 1 Lecture #13. מבוא מורחב 2 Multiple representations of data.
Polar Coordinates (MAT 170) Sections 6.3
מבוא מורחב למדעי המחשב בשפת Scheme תרגול 7. Outline Symbols Data Directed Programming, Message Passing.
Cylindrical Coordinate Coordinate Systems. Representing 3D points in Cylindrical Coordinates.  r Start from polar representations in the plane.
POLAR COORDINATES (Ch )
6.3 Polar Coordinates Day One
10.4A Polar Equations Rectangular: P (x, y) Polar: P (r,  )  r = radius (distance from origin)   = angle (radians)
Warm-Up 12/05 165° + 360k° 525°; – 195°. Rigor: You will learn how graph points and simple graphs with polar coordinates. Relevance: You will be able.
PRIOR READING: Main 1.1 & 1.2 Taylor 5.2 REPRESENTING SIMPLE HARMONIC MOTION 0.
Scheme Tutorial. Goals Combine several simple ideas into one compound idea to obtain complex ideas Bring two ideas together to obtain relations Seperate.
Copyright © 2009 Pearson Education, Inc. CHAPTER 8: Applications of Trigonometry 8.1The Law of Sines 8.2The Law of Cosines 8.3Complex Numbers: Trigonometric.
CS220 Programming Principles 프로그래밍의 이해 2002 년 가을학기 Class 8 한 태숙.
DeMoivre’s Theorem The Complex Plane. Complex Number A complex number z = x + yi can be interpreted geometrically as the point (x, y) in the complex plane.
Mathematics. Complex Numbers Session Session Objectives.
Design Constraints in Data Implementation data abstraction (abstraction barrier) is good. the performance of the users of the data depends on the implementation/representation.
Fall 2008Programming Development Techniques 1 Topic 13 Multiple Representations of Abstract Data – Tagged Data Section
Polar Coordinates Packet 1. Polar Coordinates  Recording the position of an object using the distance from a fixed point and an angle made from that.
1/38. 2/38 Tagged Data Tag: a symbol in a data structure that identifies its type Why we need tags Extended example: evaluating arithmetic expressions.
Section 6.5 Complex Numbers in Polar Form. Overview Recall that a complex number is written in the form a + bi, where a and b are real numbers and While.
SICP Tagged data Why do we need tags Concept of tags Extended example.
10.6 Polar Coordinates 10.7 Graphs of Polar equations.
Fall 2008Programming Development Techniques 1 Topic 5 Data Abstraction Note: This represents a change in order. We are skipping to chapter 2 without finishing.
Fall 2008Programming Development Techniques 1 Topic 14 Multiple Representations of Abstract Data – Data Directed Programming and Additivity Section
מבוא מורחב 1 Multiple representations of data. מבוא מורחב 2 Complex numbers imaginary real i 13 atan(2/3)
8.2 Trigonometric (Polar) Form of Complex Numbers.
Jeopardy! for the Classroom. Real Numbers Complex Numbers Polar Equations Polar Graphs Operations w/ Complex Numbers C & V
11.2 GEOMETRIC REPRESENTATION OF COMPLEX NUMBERS Can be confusing, polar form has a degree with it, rectangular form does not, this all takes place in.
Applications of Trigonometric Functions
1) Trig form of a Complex # 2) Multiplying, Dividing, and powers (DeMoivre’s Theorem) of Complex #s 3) Roots of Complex #s Section 6-5 Day 1, 2 &3.
1Complex numbersV-01 Reference: Croft & Davision, Chapter 14, p Introduction Extended the set of real numbers to.
IMAGINARY NUMBERS AND DEMOIVRE’S THEOREM Dual 8.3.
Holt Geometry 11-Ext Polar Coordinates 11-Ext Polar Coordinates Holt Geometry Lesson Presentation Lesson Presentation.
1/38 Tagged Data Tag: a symbol in a data structure that identifies its type Why we need tags Extended example: evaluating arithmetic expressions.
Introduction to Complex Numbers AC Circuits I. Outline Complex numbers basics Rectangular form – Addition – Subtraction – Multiplication – Division Rectangular.
SICP Tagged data Why do we need tags Concept of tags Extended example.
Additional Scheme examples
Complex Numbers TENNESSEE STATE STANDARDS:
Tagged Data Tag: a symbol in a data structure that identifies its type
Lecture 16 Streams continue Infinite Streams מבוא מורחב - שיעור 16.
6.001 SICP Object Oriented Programming
ECE 3301 General Electrical Engineering
Complex Numbers Real part Imaginary part
Chapter 15 – Functional Programming Languages
Complex Number Arithmetic
11.2 – Geometric Representation of Complex Numbers
Trigonometry Section 11.2 Write and graph complex numbers in polar form. Multiply complex numbers. To represent the complex number a+ bi graphically,
Trigonometry Second Edition Chapter 5
Lecture 15: Tables and OOP
Lecture 18.
Lecture #6 section pages pages72-77
Lecture 16: Tables and OOP
Lecture 12: Message passing The Environment Model
Lecture #6 section pages pages72-77
Lecture 11: Multiple representations of abstract data Message passing Overloading Section 2.4, pages ,2.5.2 pages מבוא.
Lecture #7 מבוא מורחב.
Lecture # , , , , מבוא מורחב.
Lecture 13: Assignment and the Environment Model (EM)
Convert the following to rectangular form:
Complex Numbers MAΘ
list data list 만들기 list 사용하기 nil : list link :  * list -> list
Presentation transcript:

데이타를 여러방식으로 구현할 때 Multiple Representations 데이터 구현방식마다 꼬리표를 붙이고. 데이터 속내용 감추기 원리를 유지하면서. 예를 들어 complex number data 구현방안들을 생각해 보자 – complex number 만들기 make-from-real-imag: real * real -> complex make-from-mag-angle: real * real -> complex – complex number 사용하기 is-complex?:  -> bool real: complex -> real imag: complex -> real mag: complex -> real angle: complex -> real

add-complex mul-complex make-from-real-imag make-from-mag-angle real img mag angle is-complex? rectangular representation

(define (make-from-real-imag x y) (cons x y)) (define (make-from-mag-angle m a) (cons (* m (cos a)) (* m (sin a)))) (define (is-complex? c) (and (pair? c) (real? (car c)) (real? (cdr c))) (define (real c) (cond ((not (is-complex? c)) (error)) (else (car c)))) (define (imag c) (cond ((not (is-complex? c) (error)) (else (cdr c)))) (define (mag c) (cond ((not (is-complex? c) (error)) (else (sqrt (+ (square (real c)) (square (imag c))))) )) (define (angle c) (cond ((not (is-complex? c) (error)) (else (atan (imag c) (real c)))))

외부에서는, (define (add-complex c1 c2) (make-from-real-imag (+ (real c1) (real c2)) (+ (imag c1) (imag c2)) )) (define (mul-complex c1 c2) (make-from-mag-angle (* (mag c1) (mag c2)) (+ (angle c1) (angle c2)) ))

rectangular representation polar representation make … make-from-real-imag make-from-mag-angle real imag mag angle is-complex? add-complex mul-complex

rectagular complex 속내용 감추기data abstraction – make-from-real-imag-rectangular: real * real -> complex – make-from-mag-angle-rectangular: real * real -> complex – is-rectangular?: complex -> bool – real-rectangular: complex -> real – imag-rectangular: complex -> real – mag-rectangular: complex -> real – angle-rectangular: complex -> real (define rectangular-tag ‘ rectangular) (define (make-from-real-imag-rectangular x y) (cons rectangular-tag (cons x y))) (define (make-from-mag-angle-rectangular m a) (cons rectangular-tag (cons (* m (cos a)) (* m (sin a))))) (define (is-rectangular? c) (equal? (car c) rectangular-tag)) (define (real-rectangular c) (car (cdr c))) (define (imag-rectangular c) (cdr (cdr c))) (define (mag-rectangular c) (sqrt (+ (square (real-rectangular c))) (+ (square (imag-rectangular c))))) (define (angle-rectangular c) (atan (imag-rectangular c) (real-rectangular c)))

polar complex 속내용 감추기data abstraction – make-from-real-imag-polar: real * real -> complex – make-from-mag-angle-polar: real * real -> complex – is-polar?: complex -> bool – real-polar: complex -> real – imag-polar: complex -> real – mag-polar: complex -> real – angle-polar: complex -> real (define polar-tag ‘ polar) (define (make-from-real-imag-polar x y) (cons polar-tag (cons … ))) (define (make-from-mag-angle-polar m a) (cons polar-tag (cons m a))) (define (is-polar? c) (equal? (car c) polar-tag)) (define (mag-polar c) (car (cdr c))) (define (angle-polar c) (cdr (cdr c))) (define (real-polar c) (* (mag-polar c) (cos (angle-polar c)))) (define (imag-polarr c) (* (mag-polar c) (sin (angle-polar c))))

(define (make-from-real-imag x y) (make-from-real-imag-rectangular x y)) (define (make-from-mag-angle m a) (make-from-mag-angle-polar m a)) (define (is-complex? c) (and (pair? c) (cond ((is-rectangular? c) (and (real? (real-rectangular c)) (real? (imag-rectangular c)))) ((is-polar? c) (and (real? (mag-polar c)) (real? (angle-polar c)))) (else #f)) ))

(define (real c) (cond ((not (is-complex? c)) (error)) ((is-rectangular? c) (real-rectangular c)) ((is-polar? c) (real-polar c)))) (define (imag c) (cond ((not (is-complex? c)) (error)) ((is-rectangular? c) (imag-rectangular c)) ((is-polar? c) (imag-polar c)))) (define (mag c) (cond ((not (is-complex? c)) (error)) ((is-rectangllar? c) (mag-rectangular c)) ((is-polar? c) (mag-polar c)))) (define (angle c) (cond ((not (is-complex? c)) (error)) ((is-rectangular? c) (angle-rectangular c)) ((is-polar? c) (angle-polar c))))

외부에서는, 변함없이 (define (add-complex c1 c2) (make-from-real-imag (+ (real c1) (real c2)) (+ (imag c1) (imag c2)) )) (define (mul-complex c1 c2) (make-from-mag-angle (* (mag c1) (mag c2)) (+ (angle c1) (angle c2)) ))

데이타를 여러방식으로 구현할 때 Multiple Representations 데이터 구현방식마다 꼬리표를 붙이고. 데이터 속내용 감추기 원리를 유지하면서. rectangular representation polar representation make … make-from-real-imag make-from-mag-angle real imag mag angle is-complex? add-complex mul-complex

또다른 complex number 구현방식을 품고 있게 하려면? rectangular representation polar representation make … make-from-real-imag make-from-mag-angle real imag mag angle is-complex? add-complex mul-complex make … xyz representation 어디를 어떻게 바꾸어야 할까? 적어도 real, imag, mag, angle, is-complex?를 확 장해야.

(define (real c) (cond ((not (is-complex? c)) (error)) ((is-rectangular? c) (real-rectangular c)) ((is-polar? c) (real-polar c)) ((is-xyz? c) (real-xyz c)) )) (define (imag c) (cond ((not (is-complex? c)) (error)) ((is-rectangular? c) (imag-rectangular c)) ((is-polar? c) (imag-polar c)) ((is-xyz? c) (imag-xyz c)) )) (define (mag c) (cond ((not (is-complex? c)) (error)) ((is-rectangllar? c) (mag-rectangular c)) ((is-polar? c) (mag-polar c)) ((is-xyz? c) (mag-xyz c)) )) (define (angle c) (cond ((not (is-complex? c)) (error)) ((is-rectangular? c) (angle-rectangular c)) ((is-polar? c) (angle-polar c)) ((is-xyz? c) (angle-xyz c)) ))