Upload
others
View
5
Download
0
Embed Size (px)
Citation preview
GNU OctaveA free high-level tool for Scientific Computing
Carlo de Falco Jordi Gutierrez Hermoso
November 8 2012
What is Octave Octave and
Outline
1 What is OctaveDefinitionHistoryCommunity dynamics
2 Octave and Octave and Octave-ForgeOctave and MatlabOctave and C++Octave and Parallel Computing
cdf jgh mdash GNU Octave A free high-level tool for Scientific Computing 235
What is Octave Octave and
Outline
1 What is OctaveDefinitionHistoryCommunity dynamics
2 Octave and Octave and Octave-ForgeOctave and MatlabOctave and C++Octave and Parallel Computing
cdf jgh mdash GNU Octave A free high-level tool for Scientific Computing 335
What is Octave Octave and
Outline
1 What is OctaveDefinitionHistoryCommunity dynamics
cdf jgh mdash GNU Octave A free high-level tool for Scientific Computing 435
What is Octave Octave and
What is Octave
Octave
ldquoA free a numerical environment mostly compatible with Matlabrdquo
What is compatibility A point of much debate
If it works in Matlab it should work in Octave
If it breaks it is considered a bug
If it works in Octave it can break in Matlab
aldquofreerdquo = ldquoliberordquo 6= ldquogratisrdquo
cdf jgh mdash GNU Octave A free high-level tool for Scientific Computing 535
What is Octave Octave and
Lines of code
The stuff Octave is made of
Core
About 600000 lines of C++
About 100000 lines of m-scripts
About 50000 lines of Fortran
Octave-Forge
About 200000 lines of C++
About 330000 lines of m-scripts
About 50000 lines of Fortran
cdf jgh mdash GNU Octave A free high-level tool for Scientific Computing 635
What is Octave Octave and
Lines of code
The stuff Octave is made of
Core
About 600000 lines of C++
About 100000 lines of m-scripts
About 50000 lines of Fortran
Octave-Forge
About 200000 lines of C++
About 330000 lines of m-scripts
About 50000 lines of Fortran
cdf jgh mdash GNU Octave A free high-level tool for Scientific Computing 635
What is Octave Octave and
Lines of code
The stuff Octave is made of
Core
About 600000 lines of C++
About 100000 lines of m-scripts
About 50000 lines of Fortran
Octave-Forge
About 200000 lines of C++
About 330000 lines of m-scripts
About 50000 lines of Fortran
cdf jgh mdash GNU Octave A free high-level tool for Scientific Computing 635
What is Octave Octave and
Features
Current features
N-d arrays linear algebra sparse matrices
Nonlinear equations
OrdinaryAlgebraic Differential Equations
Image processing statistics special functions
Many more
Features in development
GUI
JIT compiling
classdef OOP
cdf jgh mdash GNU Octave A free high-level tool for Scientific Computing 735
What is Octave Octave and
What does it look like
Primarily a CLI interface
Figure CLI screenshot
Most requested feature GUI Will ship with next release (40)
cdf jgh mdash GNU Octave A free high-level tool for Scientific Computing 835
What is Octave Octave and
What does it look like
Primarily a CLI interface
Most requested feature GUI Will ship with next release (40)
Figure Qt based GUI development started as J Dawidrsquos GSoC2012 project
cdf jgh mdash GNU Octave A free high-level tool for Scientific Computing 835
What is Octave Octave and
What does it look like
Primarily a CLI interface
Most requested feature GUI Will ship with next release (40)
Figure Qt based GUI development started as J Dawidrsquos GSoC2012 project
cdf jgh mdash GNU Octave A free high-level tool for Scientific Computing 835
What is Octave Octave and
Outline
1 What is OctaveDefinitionHistoryCommunity dynamics
cdf jgh mdash GNU Octave A free high-level tool for Scientific Computing 935
What is Octave Octave and
In the beginning
Companion software for chemical reactor textbook by James BRawlings and John G Ekerdt
John W Eaton (hereafter jwe) started coding in 1993
Rawlings said
Why donrsquot you call it ldquoOctaverdquo
Octave refers to Octave Levenspiel nothing to do with music
cdf jgh mdash GNU Octave A free high-level tool for Scientific Computing 1035
What is Octave Octave and
In the beginning
Companion software for chemical reactor textbook by James BRawlings and John G Ekerdt
John W Eaton (hereafter jwe) started coding in 1993
Rawlings said
Why donrsquot you call it ldquoOctaverdquo
Octave refers to Octave Levenspiel nothing to do with music
cdf jgh mdash GNU Octave A free high-level tool for Scientific Computing 1035
What is Octave Octave and
jwe is a lone wolf
jwe works almost completely alone for first four or five years
In the very beginning
No mailing lists
No widespread announcements
No VCS (these were dark times)
cdf jgh mdash GNU Octave A free high-level tool for Scientific Computing 1135
What is Octave Octave and
jwe is a lone wolf
jwe works almost completely alone for first four or five years
In the very beginning
No mailing lists
No widespread announcements
No VCS (these were dark times)
cdf jgh mdash GNU Octave A free high-level tool for Scientific Computing 1135
What is Octave Octave and
Contributions slowly trickle in
Timeline
1989 Planning stages
1992 Development begins
1993 First public announcement
1994 Version 10
1996 Version 20
1998 Version 21 development
2004 Version 29 in preparation for 30 release
2007 Version 30 major upgrade
2010 Version 324 last before using hg
2011 Version 340
2012 Version 364
cdf jgh mdash GNU Octave A free high-level tool for Scientific Computing 1235
What is Octave Octave and
Contributions slowly trickle in
Milestones
1994 Most of the current basic functionality already in (Much waswritten during its first two years)
1995 Structs Matlab-style plot() command
1998 Original sparse matrix implementation
2001 Octave-Forgersquos first commit
2006 MEX interface in core
2007 Implementation of handle graphics full support for sparse matrices
2009 OpenGL plotting
2010 -forge option for pkgm
2011 Profiler
2012 Nested functions
2013 GUI JIT compiling
cdf jgh mdash GNU Octave A free high-level tool for Scientific Computing 1335
What is Octave Octave and
Contributions slowly trickle in
Milestones
1994 Most of the current basic functionality already in (Much waswritten during its first two years)
1995 Structs Matlab-style plot() command
1998 Original sparse matrix implementation
2001 Octave-Forgersquos first commit
2006 MEX interface in core
2007 Implementation of handle graphics full support for sparse matrices
2009 OpenGL plotting
2010 -forge option for pkgm
2011 Profiler
2012 Nested functions
2013 GUI JIT compiling
cdf jgh mdash GNU Octave A free high-level tool for Scientific Computing 1335
What is Octave Octave and
Contributions slowly trickle in
Milestones
1994 Most of the current basic functionality already in (Much waswritten during its first two years)
1995 Structs Matlab-style plot() command
1998 Original sparse matrix implementation
2001 Octave-Forgersquos first commit
2006 MEX interface in core
2007 Implementation of handle graphics full support for sparse matrices
2009 OpenGL plotting
2010 -forge option for pkgm
2011 Profiler
2012 Nested functions
2013 GUI JIT compiling
cdf jgh mdash GNU Octave A free high-level tool for Scientific Computing 1335
What is Octave Octave and
Outline
1 What is OctaveDefinitionHistoryCommunity dynamics
cdf jgh mdash GNU Octave A free high-level tool for Scientific Computing 1435
What is Octave Octave and
Web resources
Web pages
Octave website
Octave-Forge website
Octave wiki
Users communication
Octave users mailing list
Octave-Forge mailing list
octave channel in Freenode
Savannah bug tracker
Developers collaboration
Octave Mercurial repository
Octave-Forge Subversion repository
cdf jgh mdash GNU Octave A free high-level tool for Scientific Computing 1535
What is Octave Octave and
Web resources
Web pages
Octave website
Octave-Forge website
Octave wiki
Users communication
Octave users mailing list
Octave-Forge mailing list
octave channel in Freenode
Savannah bug tracker
Developers collaboration
Octave Mercurial repository
Octave-Forge Subversion repository
cdf jgh mdash GNU Octave A free high-level tool for Scientific Computing 1535
What is Octave Octave and
Social structure
Like all free projects every user is a potential developer
15 current Core developers (with write access to repo)
cdf jgh mdash GNU Octave A free high-level tool for Scientific Computing 1635
What is Octave Octave and
Social structure
Like all free projects every user is a potential developer
15 current Core developers (with write access to repo)
49 currently registered rsquoForge developers (38 active)
cdf jgh mdash GNU Octave A free high-level tool for Scientific Computing 1635
What is Octave Octave and
Social structure
Like all free projects every user is a potential developer15 current Core developers (with write access to repo)49 currently registered rsquoForge developers (38 active)296 total contributors over all timeBen Abbott Andy Adler Giles Anderson Joel Andersson Muthiah Annamalai Marco Atzeri Shai Ayal Roger Banks Ben Barrowes
Alexander Barth David Bateman Heinz Bauschke Roman Belov Karl Berry David Billinghurst Don Bindner Jakub Bogusz Moritz
Borgmann Paul Boven Richard Bovey John Bradshaw Marcus Brinkmann Remy Bruno Ansgar Burchard Marco Caliari Daniel
Calvelo John C Campbell Juan Pablo Carbajal Jean-Francois Cardoso Joao Cardoso Larrie Carr David Castelow Vincent
Cautaerts Clinton Chee Albert Chin-A-Young Carsten Clark J D Cole Martin Costabel Michael Creel Jeff Cunningham Martin
Dalecki Jorge Barros de Abreu Carlo de Falco Jacob Dawid Thomas D Dean Philippe Defert Bill Denney Fabian Deutsch
Christos Dimitrakakis David M Doolin Carne Draug Pascal A Dupuis John W Eaton Dirk Eddelbuettel Pieter Eendebak Paul
Eggert Stephen Eglen Peter Ekberg Rolf Fabian Gunnar Farneback Stephen Fegan Ramon Garcia Fernandez Torsten Finke Jose
Daniel Munoz Frias Brad Froehle Castor Fu Eduardo Gallestey Walter Gautschi Klaus Gebhardt Driss Ghaddab Nicolo Giorgetti
Michael D Godfrey Michael Goffioul Glenn Golden Tomislav Goles Keith Goodman Brian Gough Steffen Groot Etienne
Grossmann David Grundberg Peter Gustafson Kai Habel Patrick Hacker William P Y Hadisoeseno Jaroslav Hajek Benjamin Hall
Kim Hansen Soslashren Hauberg Dave Hawthorne Daniel Heiserer Martin Helm Stefan Hepp Jordi Gutierrez Hermoso Yozo Hida Ryan
Hinton Roman Hodek A Scottedward Hodel Richard Allan Holcombe Tom Holroyd David Hoover Kurt Hornik Christopher
Hulbert Cyril Humbert Teemu Ikonen Alan W Irwin Geoff Jacobsen Mats Jansson Cai Jianming Steven G Johnson Heikki Junes
Matthias Juschke Atsushi Kajita Jarkko Kaleva Mohamed Kamoun Lute Kamstra Fotios Kasolis Thomas Kasper Joel Keay
Mumit Khan Paul Kienzle Aaron A King Arno J Klaassen Alexander Klein Geoffrey Knauth Heine Kolltveit Ken Kouno Kacper
Kowalik Daniel Kraft Aravindh Krishnamoorthy Oyvind Kristiansen Piotr Krzyzanowski Volker Kuhlmann Tetsuro Kurita
Miroslaw Kwasniak Rafael Laboissiere Kai Labusch Claude Lacoursiere Walter Landry Bill Lash Dirk Laurie Maurice LeBrun
Friedrich Leisch Jyh-miin Lin Timo Lindfors Benjamin Lindner Ross Lippert David Livings Sebastien Loisel Erik de Castro Lopo
Massimo Lorenzin Emil Lucretiu Hoxide Ma James Macnicol Jens-Uwe Mager Rob Mahurin Ricardo Marranita Orestes Mas
Makoto Matsumoto Tatsuro Matsuoka Laurent Mazet G D McBain Alexander Mamonov Christoph Mayer Julio Hoffimann
Mendes Thorsten Meyer Petr Mikulik Stefan Monnier Antoine Moreau Kai P Mueller Hannes Muller Victor Munoz Carmen
Navarrete Todd Neal Philip Nienhuis Al Niessner Rick Niles Takuji Nishimura Kai Noda Eric Norum Krzesimir Nowak Michael
OrsquoBrien Peter OrsquoGorman Thorsten Ohl Arno Onken Luis F Ortiz Scott Pakin Gabriele Pannocchia Sylvain Pelissier Per Persson
Primozz Peterlin Jim Peterson Danilo Piazzalunga Nicholas Piper Elias Pipping Robert Platt Hans Ekkehard Plesser Tom Poage
Orion Poplawski Ondrej Popp Jef Poskanzer Francesco Potortı Konstantinos Poulios Jarno Rajahalme James B Rawlings Eric S
Raymond Balint Reczey Joshua Redstone Lukas Reichlin Michael Reifenberger Anthony Richardson Jason Riedy E Joshua Rigler
Petter Risholm Matthew W Roberts Andrew Ross Mark van Rossum Joe Rothweiler Kevin Ruland Kristian Rumberg Ryan
Rusaw Olli Saarela Toni Saarela Juhani Saastamoinen Radek Salac Ben Sapp Aleksej Saushev Alois Schlogl Michel D Schmid
Julian Schnidder Nicol N Schraudolph Sebastian Schubert Ludwig Schwardt Thomas L Scofield Daniel J Sebald Dmitri A
Sergatskov Vanya Sergeev Baylis Shanks Andriy Shinkarchuck Robert T Short Joseph P Skudlarek John Smith Julius Smith
Shan G Smith Peter L Sondergaard Joerg Specht Quentin H Spencer Christoph Spiel Richard Stallman Russell Standish Brett
Stewart Doug Stewart Jonathan Stickel Judd Storrs Thomas Stuart Ivan Sutoris John Swensen Daisuke Takago Ariel Tankus
Matthew Tenny Georg Thimm Duncan Temple Lang Kris Thielemans Olaf Till Christophe Tournery Thomas Treichl Karsten
Trulsen Frederick Umminger Utkarsh Upadhyay Stefan van der Walt Peter Van Wieren James R Van Zandt Gregory Vanuxem
Ivana Varekova Thomas Walter Andreas Weber Olaf Weber Thomas Weber Rik Wehbring Bob Weigel Andreas Weingessel
Martin Weiser Michael Weitzel David Wells Fook Fah Yap Sean Young Michael Zeising Federico Zenith Alex Zvoleff
cdf jgh mdash GNU Octave A free high-level tool for Scientific Computing 1635
What is Octave Octave and
Social structure
Like all free projects every user is a potential developer
15 current Core developers (with write access to repo)
49 currently registered rsquoForge developers (38 active)
296 total contributors over all time
How many users Thousands Millions
cdf jgh mdash GNU Octave A free high-level tool for Scientific Computing 1635
What is Octave Octave and
From user to developer
This is a FAQ
How can I contribute
Code (obviously)
Money (pay-what-you-need)
Documentation (especially examples)
Wiki maintenance
Help in the mailing list
Bug reporting
cdf jgh mdash GNU Octave A free high-level tool for Scientific Computing 1735
What is Octave Octave and
From user to developer
This is a FAQ
How can I contribute
Code (obviously)
Money (pay-what-you-need)
Documentation (especially examples)
Wiki maintenance
Help in the mailing list
Bug reporting
cdf jgh mdash GNU Octave A free high-level tool for Scientific Computing 1735
What is Octave Octave and
From user to developer
This is a FAQ
How can I contribute
Code (obviously)
Money (pay-what-you-need)
Documentation (especially examples)
Wiki maintenance
Help in the mailing list
Bug reporting
cdf jgh mdash GNU Octave A free high-level tool for Scientific Computing 1735
What is Octave Octave and
Student projects
Google Summer of Code
GSoC 2011
Daniel Kraft Profiler
GSoC 2012
Jacob Dawid Qt GUIMax Brister JITBen Lewis Lest Squares Spectral Analysis
European Space Agencyrsquos Summer of Code in Space
SOCIS 2012
Wendy Liu Agora OctaveAndrius Sutas Instrument-Control
cdf jgh mdash GNU Octave A free high-level tool for Scientific Computing 1835
What is Octave Octave and
Student projects
Google Summer of Code
GSoC 2011
Daniel Kraft Profiler
GSoC 2012
Jacob Dawid Qt GUIMax Brister JITBen Lewis Lest Squares Spectral Analysis
European Space Agencyrsquos Summer of Code in Space
SOCIS 2012
Wendy Liu Agora OctaveAndrius Sutas Instrument-Control
cdf jgh mdash GNU Octave A free high-level tool for Scientific Computing 1835
What is Octave Octave and
Outline
1 What is OctaveDefinitionHistoryCommunity dynamics
2 Octave and Octave and Octave-ForgeOctave and MatlabOctave and C++Octave and Parallel Computing
cdf jgh mdash GNU Octave A free high-level tool for Scientific Computing 1935
What is Octave Octave and
Outline
2 Octave and Octave and Octave-ForgeOctave and MatlabOctave and C++Octave and Parallel Computing
cdf jgh mdash GNU Octave A free high-level tool for Scientific Computing 2035
What is Octave Octave and
Octave-Forge
Octave-Forge
Octave Forge Is a place for concurrently developing and distributingextension packages for Octave
Each package has a maintainer responsible for updating andreleasing new versions of the package
Some packages are maintained by The Community
Installation via an integrated package manager
cdf jgh mdash GNU Octave A free high-level tool for Scientific Computing 2135
What is Octave Octave and
PKG
1 gtgt pkg install minusforge miscellaneous2 For information about changes from previous versions of the larr
miscellaneous package run news ( miscellaneous ) 3 gtgt pkg list4 Package Name | Version | Installation directory5 minusminusminusminusminusminusminusminusminusminusminusminusminusminusminusminusminusminusminusminusminus+minusminusminusminusminusminusminusminusminus+minusminusminusminusminusminusminusminusminusminusminusminusminusminusminusminusminusminusminusminusminusminusminus6 bim | 1 1 1 | ˜ octavebimminus1117 fpl | 1 3 3 | ˜ octavefplminus1338 general | 1 3 1 | ˜ octavegeneral minus1319 geometry | 1 6 0 | ˜ octavegeometry minus160
10 miscellaneous | 1 2 0 | ˜ octavemiscellaneous minus12011 gtgt pkg load miscellaneous12 gtgt pkg list13 Package Name | Version | Installation directory14 minusminusminusminusminusminusminusminusminusminusminusminusminusminusminusminusminusminusminusminusminus+minusminusminusminusminusminusminusminusminus+minusminusminusminusminusminusminusminusminusminusminusminusminusminusminusminusminusminusminusminusminusminusminus15 bim | 1 1 1 | ˜ octavebimminus11116 fpl | 1 3 3 | ˜ octavefplminus13317 general | 1 3 1 | ˜ octavegeneral minus13118 geometry | 1 6 0 | ˜ octavegeometry minus16019 miscellaneous lowast| 1 2 0 | ˜ octavemiscellaneous minus120
cdf jgh mdash GNU Octave A free high-level tool for Scientific Computing 2235
What is Octave Octave and
PKG
1 gtgt pkg describe bim minusverbose2 minusminusminus3 Package name 4 bim5 Version 6 1 1 17 Short description 8 Package f o r solving Diffusion Advection Reaction ( DAR ) Partial larr
Differential Equations9 Status
10 Not loaded11 minusminusminus12 Provides 13 Matrix assembly14 bim1a_advection_diffusion15 bim1a_advection_upwind16 bim2a_advection_diffusion17 18 Preminusprocessing and Postminusprocessing computations19 bim2c_mesh_properties20 21 gtgt
cdf jgh mdash GNU Octave A free high-level tool for Scientific Computing 2335
What is Octave Octave and
Some interesting packages
usage examples in the wiki
cdf jgh mdash GNU Octave A free high-level tool for Scientific Computing 2435
What is Octave Octave and
Some interesting packages
usage examples in the wiki
cdf jgh mdash GNU Octave A free high-level tool for Scientific Computing 2435
What is Octave Octave and
Some interesting packages
usage examples in the wiki
cdf jgh mdash GNU Octave A free high-level tool for Scientific Computing 2435
What is Octave Octave and
Outline
2 Octave and Octave and Octave-ForgeOctave and MatlabOctave and C++Octave and Parallel Computing
cdf jgh mdash GNU Octave A free high-level tool for Scientific Computing 2535
What is Octave Octave and
Broadcasting
Since 360 Octave automatically broadcasts arrays when usingelementwise binary operators
Corresponding array dimensions must either be equal or one ofthem must be 1
In case all dimensions are equal ordinary element-by-elementarithmetic takes place
When one of the dimensions is 1 the array with that singletondimension gets copied along that dimension until it matches thedimension of the other array
cdf jgh mdash GNU Octave A free high-level tool for Scientific Computing 2635
What is Octave Octave and
Broadcasting
1 x = [ 1 2 3 4 5 6 7 8 9 ] 2 y = [ 1 0 20 3 0 ] 3 x + y4 11 22 335 14 25 366 17 28 39
Without broadcasting x + y would be an error because dimensions do not agree
With broadcasting it is as if the following operation were performed
1 x = [ 1 2 3 4 5 6 7 8 9 ] 2 y = [ 1 0 20 3 0 10 20 3 0 10 20 3 0 ] 3 x + y4 11 22 335 14 25 366 17 28 39
Other notable differences with Matlab listed in the wiki
cdf jgh mdash GNU Octave A free high-level tool for Scientific Computing 2735
What is Octave Octave and
Outline
2 Octave and Octave and Octave-ForgeOctave and MatlabOctave and C++Octave and Parallel Computing
cdf jgh mdash GNU Octave A free high-level tool for Scientific Computing 2835
What is Octave Octave and
dld-functions
Implement an Octave interpreter function in C++
1 include lto c t a v e o c t hgt2
3 DEFUN_DLD ( dld args nargout dld (array) nreturn the elements of larrthe array in reverse ordern )
4 5 octave_value_list retval 6 int nargin = args length ( ) 7
8 if ( nargin = 1)9 print_usage ( )
10 else11 12 Arrayltdoublegt a = args ( 0 ) array_value ( ) 13 if ( error_state )14 15 Arrayltdoublegt b ( a )
source code of the example
cdf jgh mdash GNU Octave A free high-level tool for Scientific Computing 2935
include ltoctaveocthgtDEFUN_DLD(dldargsnargoutdld (array) nreturn the elements of the array in reverse ordern) octave_value_list retval int nargin = argslength () if (nargin = 1) print_usage () else Arrayltdoublegt a = args(0)array_value () if ( error_state) Arrayltdoublegt b (a) double ap = afortran_vec () double bp = bfortran_vec () for (octave_idx_type i = anumel () - 1 j = 0 i gt= 0 i-- j++) bp[i] = ap[j] retval = octave_value (b) return retval
What is Octave Octave and
dld-functions
Implement an Octave interpreter function in C++
16 doublelowast ap = a fortran_vec ( ) 17 doublelowast bp = b fortran_vec ( ) 18 for ( octave_idx_type i = a numel ( ) minus 1 j = 0 i gt= 0 larr
iminusminus j++)19 bp [ i ] = ap [ j ] 20 retval = octave_value ( b ) 21 22 23 return retval 24
source code of the example
cdf jgh mdash GNU Octave A free high-level tool for Scientific Computing 2935
include ltoctaveocthgtDEFUN_DLD(dldargsnargoutdld (array) nreturn the elements of the array in reverse ordern) octave_value_list retval int nargin = argslength () if (nargin = 1) print_usage () else Arrayltdoublegt a = args(0)array_value () if ( error_state) Arrayltdoublegt b (a) double ap = afortran_vec () double bp = bfortran_vec () for (octave_idx_type i = anumel () - 1 j = 0 i gt= 0 i-- j++) bp[i] = ap[j] retval = octave_value (b) return retval
What is Octave Octave and
dld-functions
Implement an Octave interpreter function in C++
1 gtgt mkoctfile dld cc2 gtgt a = randn ( 5 )3 a =4
5 0395421 minus1425232 minus0176544 1055205 22293716 minus0241893 0035004 minus0296543 minus1710613 04443187 minus0752467 minus2220469 2380951 0766246 11961538 1404672 0623112 1182609 0196125 06093259 minus0687019 0646079 2239012 minus0495169 1488314
10
11 gtgt b = dld ( a )12 b =13
14 1488314 minus0495169 2239012 0646079 minus068701915 0609325 0196125 1182609 0623112 140467216 1196153 0766246 2380951 minus2220469 minus075246717 0444318 minus1710613 minus0296543 0035004 minus024189318 2229371 1055205 minus0176544 minus1425232 039542119
20 gtgt
source code of the example
cdf jgh mdash GNU Octave A free high-level tool for Scientific Computing 2935
include ltoctaveocthgtDEFUN_DLD(dldargsnargoutdld (array) nreturn the elements of the array in reverse ordern) octave_value_list retval int nargin = argslength () if (nargin = 1) print_usage () else Arrayltdoublegt a = args(0)array_value () if ( error_state) Arrayltdoublegt b (a) double ap = afortran_vec () double bp = bfortran_vec () for (octave_idx_type i = anumel () - 1 j = 0 i gt= 0 i-- j++) bp[i] = ap[j] retval = octave_value (b) return retval
What is Octave Octave and
liboctave
Use Octaversquos MatrixArray Classes in a C++ application
1 include lti o s t r e a mgt2 include lto c t a v e o c t hgt3
4 int main ( void )5 6
7 Matrix A ( 4 4) 8 for ( octave_idx_type i = 0 i lt 4 i++)9 for ( octave_idx_type j = 0 j lt 4 j++)
10 A (i j ) = 1 0 ( static_castltdoublegt ( i ) +11 static_castltdoublegt ( j ) + 1 0 ) 12
13 ColumnVector b ( 4 1 0 ) 14 ColumnVector x = A solve ( b ) 15
16 std cout ltlt A = ltlt std endl ltlt A ltlt std endl17 ltlt b = ltlt std endl ltlt b ltlt std endl18 ltlt x = ltlt std endl ltlt x ltlt std endl 19
20 return 0 21
source code of the example
cdf jgh mdash GNU Octave A free high-level tool for Scientific Computing 3035
include ltiostreamgtinclude ltoctaveocthgtint main (void) Matrix A (4 4) for (octave_idx_type i = 0 i lt 4 i++) for (octave_idx_type j = 0 j lt 4 j++) A(ij) = 10 (static_castltdoublegt (i) + static_castltdoublegt (j) + 10) ColumnVector b (4 10) ColumnVector x = Asolve (b) stdcout ltlt A = ltlt stdendl ltlt A ltlt stdendl ltlt b = ltlt stdendl ltlt b ltlt stdendl ltlt x = ltlt stdendl ltlt x ltlt stdendl return 0
What is Octave Octave and
liboctave
Use Octaversquos MatrixArray Classes in a C++ application
1 $ mkoctfile minusminuslinkminusstandminusalone standalone cc2 $ a out3 A =4 1 0 5 0 333333 0 2 55 0 5 0 333333 0 2 5 0 26 0333333 0 2 5 0 2 0 1666677 0 2 5 0 2 0 166667 01428578 b =9 1
10 111 112 113 x =14 minus415 6016 minus18017 140
source code of the example
cdf jgh mdash GNU Octave A free high-level tool for Scientific Computing 3035
include ltiostreamgtinclude ltoctaveocthgtint main (void) Matrix A (4 4) for (octave_idx_type i = 0 i lt 4 i++) for (octave_idx_type j = 0 j lt 4 j++) A(ij) = 10 (static_castltdoublegt (i) + static_castltdoublegt (j) + 10) ColumnVector b (4 10) ColumnVector x = Asolve (b) stdcout ltlt A = ltlt stdendl ltlt A ltlt stdendl ltlt b = ltlt stdendl ltlt b ltlt stdendl ltlt x = ltlt stdendl ltlt x ltlt stdendl return 0
What is Octave Octave and
Embedding Octave
You can embed the Octave interpreter in your C++ application
1 include lti o s t r e a mgt2 include lto c t a v e o c t hgt3 include lto c t a v e o c t a v e hgt4 include lto c t a v e p a r s e hgt5
6 int main ( void )7 8 string_vector octave_argv ( 2 ) 9 octave_argv ( 0 ) = embedded
10 octave_argv ( 1 ) = -q 11
12 octave_main ( 2 octave_argv c_str_vec ( ) 1) 13
14
15 octave_value_list out = feval ( version octave_value_list ( ) larr1)
16 std cout ltlt out ( 0 ) string_value ( ) ltlt std endl
source code of the example
cdf jgh mdash GNU Octave A free high-level tool for Scientific Computing 3135
include ltiostreamgtinclude ltoctaveocthgtinclude ltoctaveoctavehgtinclude ltoctaveparsehgtint main (void) string_vector octave_argv (2) octave_argv(0) = embedded octave_argv(1) = -q octave_main (2 octave_argvc_str_vec () 1) octave_value_list out = feval (version octave_value_list () 1) stdcout ltlt out(0)string_value () ltlt stdendl Matrix A (4 4) for (octave_idx_type i = 0 i lt 4 i++) for (octave_idx_type j = 0 j lt 4 j++) A(ij) = 10 (static_castltdoublegt (i) + static_castltdoublegt (j) + 1) ColumnVector b (4 10) out = feval (mldivide octave_value (A) octave_value (b) 1) return 0
What is Octave Octave and
Embedding Octave
You can embed the Octave interpreter in your C++ application
18 Matrix A ( 4 4) 19 for ( octave_idx_type i = 0 i lt 4 i++)20 for ( octave_idx_type j = 0 j lt 4 j++)21 A (i j ) = 1 0 ( static_castltdoublegt ( i ) +22 static_castltdoublegt ( j ) + 1) 23
24 ColumnVector b ( 4 1 0 ) 25
26 out = feval ( mldivide octave_value ( A ) octave_value ( b ) 1) 27
28 return 0 29
source code of the example
cdf jgh mdash GNU Octave A free high-level tool for Scientific Computing 3135
include ltiostreamgtinclude ltoctaveocthgtinclude ltoctaveoctavehgtinclude ltoctaveparsehgtint main (void) string_vector octave_argv (2) octave_argv(0) = embedded octave_argv(1) = -q octave_main (2 octave_argvc_str_vec () 1) octave_value_list out = feval (version octave_value_list () 1) stdcout ltlt out(0)string_value () ltlt stdendl Matrix A (4 4) for (octave_idx_type i = 0 i lt 4 i++) for (octave_idx_type j = 0 j lt 4 j++) A(ij) = 10 (static_castltdoublegt (i) + static_castltdoublegt (j) + 1) ColumnVector b (4 10) out = feval (mldivide octave_value (A) octave_value (b) 1) return 0
What is Octave Octave and
An advanced example
Add a new class to the Octave interpreter and work around Octaversquospass-by-value semantics
source code of the example (cc)
source code of the example (h)
cdf jgh mdash GNU Octave A free high-level tool for Scientific Computing 3235
Copyright (C) 2012 Carlo de Falco ltcarlodefalcogmailcomgt
This program is free software you can redistribute it andor modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation either version 3 of the License or (at your option) any later
version
This program is distributed in the hope that it will be useful but WITHOUT
ANY WARRANTY without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE See the GNU General Public License for more
details
You should have received a copy of the GNU General Public License along with
this program if not see lthttpwwwgnuorglicensesgt
include lt octave oct h gt
include lt myobject h gt
void load_myobject_type ()
myobject register_type ()
myobject_type_loaded = true
mlock ()
std cout ltlt myobject_type_loaded ltlt std endl
const std string amp myobject get_str () const
return str
void myobject set_str ( std string amp _str )
str = _str
PKG_ADD autoload (myobject_get_str myobjectoct)
DEFUN_DLD ( myobject_get_str args
get the str field )
octave_value retval
octave_idx_type nargin = args length ()
if ( nargin lt 1 || nargin gt 1 )
print_usage ()
else
if ( myobject_type_loaded )
load_myobject_type ()
if ( args ( 0 ) type_id () == myobject static_type_id ())
const myobject amp mo = static_cast lt const myobject ampgt ( args ( 0 ) get_rep ())
retval = octave_value ( mo get_str ())
return retval