c++ as a programming language for cas.ppt [modo de … · 2017. 3. 7. · •• web2.0 philosophy:...
TRANSCRIPT
![Page 1: C++ as a programming language for CAS.ppt [Modo de … · 2017. 3. 7. · •• Web2.0 philosophy: intuitive applications, Web2.0 philosophy: intuitive applications, easy th d d](https://reader036.vdocuments.net/reader036/viewer/2022081623/6147f4b9a830d0442101c55a/html5/thumbnails/1.jpg)
-- Lluís Parcerisa --
C++ as a programmingC++ as a programminglanguage for CASlanguage for CASlanguage for CASlanguage for CAS
ContentsContentsContentsContents
• C++ vs Basic• C++ in a calculator1.- Introduction
• Development environment• Application model• Example
2.- Application structure
• Embedded functions• CAS calling3.- Functions
• Laboratory• Result checking• Circuit Analysis
4.- Real application examples
• C++ as future programming language bridging CAS• Advantages and Drawbacks• Final statement
5.- Conclusions
![Page 2: C++ as a programming language for CAS.ppt [Modo de … · 2017. 3. 7. · •• Web2.0 philosophy: intuitive applications, Web2.0 philosophy: intuitive applications, easy th d d](https://reader036.vdocuments.net/reader036/viewer/2022081623/6147f4b9a830d0442101c55a/html5/thumbnails/2.jpg)
ContentsContentsContentsContents
• C++ vs Basic• C++ in a calculator1.- Introduction
• Development environment• Application model• Example
2.- Application structure
• Embedded functions• CAS calling3.- Functions
• Laboratory• Result checking• Circuit Analysis
4.- Real application examples
• C++ as future programming language bridging CAS• Advantages and Drawbacks• Final statement
5.- Conclusions
C++ C++ vsvs Basic Basic -- FeaturesFeaturesC++ C++ vsvs Basic Basic -- FeaturesFeatures
Basic C++
![Page 3: C++ as a programming language for CAS.ppt [Modo de … · 2017. 3. 7. · •• Web2.0 philosophy: intuitive applications, Web2.0 philosophy: intuitive applications, easy th d d](https://reader036.vdocuments.net/reader036/viewer/2022081623/6147f4b9a830d0442101c55a/html5/thumbnails/3.jpg)
C++ C++ vsvs Basic Basic –– AppApp StructureStructureC++ C++ vsvs Basic Basic –– AppApp. . StructureStructure
•• C++ => Object orientedC++ => Object oriented
–– Code reuse and extensionCode reuse and extension
–– Adequate for complex systemsAdequate for complex systems
–– Empower visual applicationsEmpower visual applicationsp ppp pp
–– Prototype constructionPrototype construction
–– Speed application programming timeSpeed application programming timep pp p g gp pp p g g
–– Enforce cooperative workEnforce cooperative work
–– Software maintenanceSoftware maintenance
C++ to program calculator appsC++ to program calculator appsC++ to program calculator appsC++ to program calculator apps
er • Fast learning er • Easy
mm
e
• Code division• Embedded U
se • Intuitive• Useful
ogra
m
functions• CAS calling
• Customizable
Pro
![Page 4: C++ as a programming language for CAS.ppt [Modo de … · 2017. 3. 7. · •• Web2.0 philosophy: intuitive applications, Web2.0 philosophy: intuitive applications, easy th d d](https://reader036.vdocuments.net/reader036/viewer/2022081623/6147f4b9a830d0442101c55a/html5/thumbnails/4.jpg)
ContentsContentsContentsContents
• C++ vs Basic• C++ in a calculator1.- Introduction
• Development environment• Application model• Example
2.- Application structure
• Embedded functions• CAS calling3.- Functions
• Laboratory• Result checking• Circuit Analysis
4.- Real application examples
• C++ as future programming language bridging CAS• Advantages and Drawbacks• Final statement
5.- Conclusions
Development EnvironmentDevelopment Environment
•• C SintaxC Sintax
•• Compilation: addCompilation: add--in cpain cpa
•• Software: DevSoftware: Dev--CPPCPP
•• www cpsdk comwww cpsdk com•• www.cpsdk.comwww.cpsdk.com
Página 8
![Page 5: C++ as a programming language for CAS.ppt [Modo de … · 2017. 3. 7. · •• Web2.0 philosophy: intuitive applications, Web2.0 philosophy: intuitive applications, easy th d d](https://reader036.vdocuments.net/reader036/viewer/2022081623/6147f4b9a830d0442101c55a/html5/thumbnails/5.jpg)
Application StructureApplication Structure
M d lM d l AA Pi d kPi d k / B Whit/ B Whit•• ModelModel: A. : A. PizdrowskyPizdrowsky / B. White/ B. White
main ClassPad.h
App hApp.h
.cpp
Cnt signal
Página 9
Cnt, signal
Implementation exampleImplementation example
Página 10
![Page 6: C++ as a programming language for CAS.ppt [Modo de … · 2017. 3. 7. · •• Web2.0 philosophy: intuitive applications, Web2.0 philosophy: intuitive applications, easy th d d](https://reader036.vdocuments.net/reader036/viewer/2022081623/6147f4b9a830d0442101c55a/html5/thumbnails/6.jpg)
Implementation exampleImplementation example
Página 11
Implementation exampleImplementation example
Página 12
![Page 7: C++ as a programming language for CAS.ppt [Modo de … · 2017. 3. 7. · •• Web2.0 philosophy: intuitive applications, Web2.0 philosophy: intuitive applications, easy th d d](https://reader036.vdocuments.net/reader036/viewer/2022081623/6147f4b9a830d0442101c55a/html5/thumbnails/7.jpg)
Implementation exampleImplementation example
Página 13
ContentsContentsContentsContents
• C++ vs Basic• C++ in a calculator1.- Introduction
• Development environment• Application model• Example
2.- Application structure
• Embedded functions• CAS calling3.- Functions
• Laboratory• Result checking• Circuit Analysis
4.- Real application examples
• C++ as future programming language bridging CAS• Advantages and Drawbacks• Final statement
5.- Conclusions
![Page 8: C++ as a programming language for CAS.ppt [Modo de … · 2017. 3. 7. · •• Web2.0 philosophy: intuitive applications, Web2.0 philosophy: intuitive applications, easy th d d](https://reader036.vdocuments.net/reader036/viewer/2022081623/6147f4b9a830d0442101c55a/html5/thumbnails/8.jpg)
Embedded Functions Embedded Functions
GUI
Signal
Screen
Signal
funcs
GUI ElementsGUI ElementsGUI ElementsGUI Elements
PegPromptPegPrompt, , CPPegStringCPPegString PegCheckBoxPegCheckBox, , PegTextButtonPegTextButton
![Page 9: C++ as a programming language for CAS.ppt [Modo de … · 2017. 3. 7. · •• Web2.0 philosophy: intuitive applications, Web2.0 philosophy: intuitive applications, easy th d d](https://reader036.vdocuments.net/reader036/viewer/2022081623/6147f4b9a830d0442101c55a/html5/thumbnails/9.jpg)
GUI ElementsGUI Elements
CPDialogCPDialog
GUI ElementsGUI Elements
CPDialogCPDialog, , PegMessageWindowPegMessageWindow PegVertListPegVertList, , PegComboBoxPegComboBox
SignalsSignals
Li tLi t >>S tSi lS tSi l (SIGMASK(PSF LIST SELECT))(SIGMASK(PSF LIST SELECT))
SignalsSignals
pListpList-->>SetSignalsSetSignals(SIGMASK(PSF_LIST_SELECT));(SIGMASK(PSF_LIST_SELECT));
(...)(...)
SIGNED SIGNED AWGAWG::::MessageMessage((constconst PegMessagePegMessage &&MesgMesg) {) {switchswitch((Mesg.wTypeMesg.wType) {) {
casecase SIGNAL(ID_VERTLIST,PSF_LIST_SELECT): {SIGNAL(ID_VERTLIST,PSF_LIST_SELECT): {cListcList-->Clear();>Clear();Calcula(Calcula(pListpList-->>GetSelectedIndexGetSelectedIndex()()--3); 3); ((pp ()() ););DrawDraw();();
} break; } break; defaultdefault: : returnreturn CPModuleWindowCPModuleWindow::::MessageMessage((MesgMesg););defaultdefault: : returnreturn CPModuleWindowCPModuleWindow::::MessageMessage((MesgMesg););
}}returnreturn 0;0;
}}}}
![Page 10: C++ as a programming language for CAS.ppt [Modo de … · 2017. 3. 7. · •• Web2.0 philosophy: intuitive applications, Web2.0 philosophy: intuitive applications, easy th d d](https://reader036.vdocuments.net/reader036/viewer/2022081623/6147f4b9a830d0442101c55a/html5/thumbnails/10.jpg)
Ex: Ex: AWGAWG ConversorConversorEx: Ex: AWGAWG, , ConversorConversor
Graphical FunctionsGraphical FunctionsGraphical FunctionsGraphical Functions
•• PegScreenPegScreen
–– LineLine
•• ConvertConvert BitmapBitmap
–– RectangleRectangle
–– CircleCircle
–– PatternLinePatternLine
–– ArcArc
–– PolygonPolygon
![Page 11: C++ as a programming language for CAS.ppt [Modo de … · 2017. 3. 7. · •• Web2.0 philosophy: intuitive applications, Web2.0 philosophy: intuitive applications, easy th d d](https://reader036.vdocuments.net/reader036/viewer/2022081623/6147f4b9a830d0442101c55a/html5/thumbnails/11.jpg)
Ex1: Ex1: SnellSnell Nyquist Nyquist DiagramDiagramEx1: Ex1: SnellSnell, Nyquist , Nyquist DiagramDiagram
Ex2: Ex2: AntennaAntenna ArraysArraysEx2: Ex2: AntennaAntenna ArraysArrays
![Page 12: C++ as a programming language for CAS.ppt [Modo de … · 2017. 3. 7. · •• Web2.0 philosophy: intuitive applications, Web2.0 philosophy: intuitive applications, easy th d d](https://reader036.vdocuments.net/reader036/viewer/2022081623/6147f4b9a830d0442101c55a/html5/thumbnails/12.jpg)
Real numbersReal numbers
Página 23
Real numbersReal numbers
Página 24
![Page 13: C++ as a programming language for CAS.ppt [Modo de … · 2017. 3. 7. · •• Web2.0 philosophy: intuitive applications, Web2.0 philosophy: intuitive applications, easy th d d](https://reader036.vdocuments.net/reader036/viewer/2022081623/6147f4b9a830d0442101c55a/html5/thumbnails/13.jpg)
ContentsContentsContentsContents
• C++ vs Basic• C++ in a calculator1.- Introduction
• Development environment• Application model• Example
2.- Application structure
• Embedded functions• CAS calling3.- Functions
• Laboratory• Result checking• Circuit Analysis
4.- Real application examples
• C++ as future programming language bridging CAS• Advantages and Drawbacks• Final statement
5.- Conclusions
CallingCalling CAS CAS FunctionsFunctionsCallingCalling CAS CAS FunctionsFunctions
•• CPExpressionCPExpression Class ReferenceClass ReferenceCPP expression class which manages CPP expression class which manages expression memory. The expression memory. The CPExpressionCPExpression class class contains a reference to a contains a reference to a CPExpressionObjectCPExpressionObject. A . A CPExpressionObjectCPExpressionObject should never be used should never be used directly. This is a reference counted object that directly. This is a reference counted object that keeps track of the memory used for the CAS keeps track of the memory used for the CAS expression. When there are no longer any expression. When there are no longer any CPExpressionCPExpression objects referring to this memory it objects referring to this memory it is automatically freed. is automatically freed.
![Page 14: C++ as a programming language for CAS.ppt [Modo de … · 2017. 3. 7. · •• Web2.0 philosophy: intuitive applications, Web2.0 philosophy: intuitive applications, easy th d d](https://reader036.vdocuments.net/reader036/viewer/2022081623/6147f4b9a830d0442101c55a/html5/thumbnails/14.jpg)
CallingCalling CAS CAS FunctionsFunctionsCallingCalling CAS CAS FunctionsFunctions
Calc
i
F()Calc
i
CPExpression( x )
CAS C++CAS C++
CallingCalling CAS CAS FunctionsFunctionsCallingCalling CAS CAS FunctionsFunctions
3/2 => 1 5Transform
Calculate
Fraction Approx /toFrac / propFrac
3/2 => 1.51.5 => 3/21.5 => 1 1/2
ComplexesExpand / CollectFactor / factorOutrFactor
(a+b)^2 => …Factorize (x)Root
Polinomy
Matrices
Equations
rFactorCombineSimplify
Rootmcd
Trigonometry sin(a+b)tExpand / tCollect
Other Dms / toDMS 3.44 => 3,26,24
e^jxexpToTrig / trigToExp
Página 28
Other
![Page 15: C++ as a programming language for CAS.ppt [Modo de … · 2017. 3. 7. · •• Web2.0 philosophy: intuitive applications, Web2.0 philosophy: intuitive applications, easy th d d](https://reader036.vdocuments.net/reader036/viewer/2022081623/6147f4b9a830d0442101c55a/html5/thumbnails/15.jpg)
CallingCalling CAS CAS FunctionsFunctionsCallingCalling CAS CAS FunctionsFunctions
TaylorTransform
Calculate
Taylor
Complexes
Laplace / InvLaplaceMatrices
Equations
Laplace / InvLaplace
+ Fourier/InvFourier/FFT…
Página 29
CallingCalling CAS CAS FunctionsFunctionsCallingCalling CAS CAS FunctionsFunctions
diff / ∫Transform
Calculate
diff / ∫
lim
Complexes ∑ / ∏
fMin / fMaxMatrices
Equations
fMin / fMax
tanLine/normal
arcLine
gcd / lcmgcd / lcm
denominator/numerator
Página 30
mod
![Page 16: C++ as a programming language for CAS.ppt [Modo de … · 2017. 3. 7. · •• Web2.0 philosophy: intuitive applications, Web2.0 philosophy: intuitive applications, easy th d d](https://reader036.vdocuments.net/reader036/viewer/2022081623/6147f4b9a830d0442101c55a/html5/thumbnails/16.jpg)
CallingCalling CAS CAS FunctionsFunctionsCallingCalling CAS CAS FunctionsFunctions√(a2 + b2)
jb
arctg(b/a)
Transform
Calculate Abs
a - jb
Arg
Complexes
Abs
I / Ra / b
ConjgArg
a + jbMatrices
Equations
Im / Rea / b
compToTrigcExpand
a + jb
compToPol
compToTrigcExpand
compToPol-1√(a2 + b2) · (cos() + j sin())
Página 31√(a2 + b2) · e^(j arctg(b/a))
CallingCalling CAS CAS FunctionsFunctionsCallingCalling CAS CAS FunctionsFunctionsa bdTransform
Calculate
• Trn => [a c][b d]
• Dim => {2 2}
c d
Complexes
Dim => {2,2}
• Det => ad - bc
Matrices
Equations
• Norm => √(|a|^2+|b|^2 +|c|^2 +|d|^2)
• eigVl / eigVc => propis
C ti
g g p p
• Rref / Ref => escalonada
Creation:• Menú• Vectors
• LU / QR => descomposició
• Swap => [c d][a b]
Página 32
• Vectors• 2D
![Page 17: C++ as a programming language for CAS.ppt [Modo de … · 2017. 3. 7. · •• Web2.0 philosophy: intuitive applications, Web2.0 philosophy: intuitive applications, easy th d d](https://reader036.vdocuments.net/reader036/viewer/2022081623/6147f4b9a830d0442101c55a/html5/thumbnails/17.jpg)
CallingCalling CAS CAS FunctionsFunctionsCallingCalling CAS CAS FunctionsFunctions
Transform
CalculateReals Solve(3x-8=0)
Complexes Parameter Solve(mx^2+x-5=0)
Matrices
Equations Complexes Solve(y^2-1=0,y)
InequalitiesSolve(x-5>2) Solve(x^2≠5)
SystemsSolve({x+y=0,x-y=7},{x,y})
Página 33
y
ContentsContentsContentsContents
• C++ vs Basic• C++ in a calculator1.- Introduction
• Development environment• Application model• Example
2.- Application structure
• Embedded functions• CAS calling3.- Functions
• Laboratory• Result checking• Circuit Analysis
4.- Real application examples
• C++ as future programming language bridging CAS• Advantages and Drawbacks• Final statement
5.- Conclusions
![Page 18: C++ as a programming language for CAS.ppt [Modo de … · 2017. 3. 7. · •• Web2.0 philosophy: intuitive applications, Web2.0 philosophy: intuitive applications, easy th d d](https://reader036.vdocuments.net/reader036/viewer/2022081623/6147f4b9a830d0442101c55a/html5/thumbnails/18.jpg)
Lab – StandardLab – Standard
Página 35
Lab - ResisLab - Resis
Página 36
![Page 19: C++ as a programming language for CAS.ppt [Modo de … · 2017. 3. 7. · •• Web2.0 philosophy: intuitive applications, Web2.0 philosophy: intuitive applications, easy th d d](https://reader036.vdocuments.net/reader036/viewer/2022081623/6147f4b9a830d0442101c55a/html5/thumbnails/19.jpg)
Lab – Logic FunctionsLab – Logic Functions
Página 37
Check – Ohm’s LawCheck – Ohm s Law
V = R IV = R · I
P = V IP = V · I
Página 38
![Page 20: C++ as a programming language for CAS.ppt [Modo de … · 2017. 3. 7. · •• Web2.0 philosophy: intuitive applications, Web2.0 philosophy: intuitive applications, easy th d d](https://reader036.vdocuments.net/reader036/viewer/2022081623/6147f4b9a830d0442101c55a/html5/thumbnails/20.jpg)
Check – Tx LinesCheck – Tx. Lines
Página 39
Check - CommunicationsCheck - Communications
Página 40
![Page 21: C++ as a programming language for CAS.ppt [Modo de … · 2017. 3. 7. · •• Web2.0 philosophy: intuitive applications, Web2.0 philosophy: intuitive applications, easy th d d](https://reader036.vdocuments.net/reader036/viewer/2022081623/6147f4b9a830d0442101c55a/html5/thumbnails/21.jpg)
Circ Analysis - VdivCirc. Analysis - Vdiv
Vo = R2/(R1+R2) · Vi
Página 41
Circ Analysis - D-StarCirc. Analysis - D-Star
R1 = (Ra x Rc) / (Ra + Rb + Rc)R2 = (Rb x Rc) / (Ra + Rb + Rc)R3 = (Ra x Rb) / (Ra + Rb + Rc)
Ra = [ (R1 x R2) + (R1 x R3) + (R2 x R3) ] / R2Rb = [ (R1 x R2) + (R1 x R3) + (R2 x R3) ] / R1Rc = [ (R1 x R2) + (R1 x R3) + (R2 x R3) ] / R3
Página 42
![Page 22: C++ as a programming language for CAS.ppt [Modo de … · 2017. 3. 7. · •• Web2.0 philosophy: intuitive applications, Web2.0 philosophy: intuitive applications, easy th d d](https://reader036.vdocuments.net/reader036/viewer/2022081623/6147f4b9a830d0442101c55a/html5/thumbnails/22.jpg)
ContentsContentsContentsContents
• C++ vs Basic• C++ in a calculator1.- Introduction
• Development environment• Application model• Example
2.- Application structure
• Embedded functions• CAS calling3.- Functions
• Laboratory• Result checking• Circuit Analysis
4.- Real application examples
• C++ as future programming language bridging CAS• Advantages and Drawbacks• Final statement
5.- Conclusions
4 24 2-- Advantages & DrawbacksAdvantages & Drawbacks4.24.2-- Advantages & DrawbacksAdvantages & Drawbacks
Easy and powerful framework, versatility and complexity
Real and complexversatility and complexity.
Intuitive and useful applications.
complex numbers, new language (?)pp g g ( )
![Page 23: C++ as a programming language for CAS.ppt [Modo de … · 2017. 3. 7. · •• Web2.0 philosophy: intuitive applications, Web2.0 philosophy: intuitive applications, easy th d d](https://reader036.vdocuments.net/reader036/viewer/2022081623/6147f4b9a830d0442101c55a/html5/thumbnails/23.jpg)
4 34 3-- Final Final StatementStatement4.34.3-- Final Final StatementStatement
•• C++ is the natural evolution to program C++ is the natural evolution to program calculator addcalculator add--ins, providing both ins, providing both , p g, p gpowerfulness (embedded functions, CAS powerfulness (embedded functions, CAS calling) and simplicity (modular design)calling) and simplicity (modular design)calling) and simplicity (modular design).calling) and simplicity (modular design).
•• Web2.0 philosophy: intuitive applications, Web2.0 philosophy: intuitive applications, t h d d bl ft h d d bl feasy to share and run and capable of easy to share and run and capable of
being improved by the community.being improved by the community.
S i d l
Thank you for you attentionThank you for you attentionSuggestions and comments are welcome
Thank you for you attentionThank you for you attention