introduction to gnu/octaveacmsc/sfd2011/octavsfdr9.pdf · introductionoctave codecomparisons...
Post on 23-Mar-2020
43 Views
Preview:
TRANSCRIPT
Introduction Octave Code Comparisons
Introduction to GNU/Octave
A. Mani
9/1B, Jatin Bagchi RoadKolkata-700029 India
Department of Pure Mathematics, C.U.E-Mail: a.mani .cms@gmail .com
Homepage: http://www.logicamani.co.cc
Software Freedom Day’2011, Kolkata
Introduction Octave Code Comparisons
ABSTRACT
In this talk, I will give a brief introduction to GNU/Octave with someemphasis on migration issues.
Introduction Octave Code Comparisons
Myself
• Research in Mathematics (Algebra, Rough Sets, Algebraic Logic,Logic and Ordered Structures.)
• Teaching and Independent Consultancy in Statistics, R, KDD, FOSSand Specifications.
• FOSS Activism: Ilug-Cal.info (www.ilug-cal.info), Fedora QA,LQ (www.linuxquestions.org), ...
Introduction Octave Code Comparisons
Octave
• is a software for Numeric Computations (not symbolic).• respects the four freedoms of FOSS: to use, to share, to modify andto distribute modifications. Licensed GNU GPL-2, 3
• performs best in GNU/Linux 64-bit, Free BSD.• Extensible scripting language (interpreted) with good graphicssupport.
• Octave is not Naive.
Introduction Octave Code Comparisons
Installation
• Package manager of GNU/Linux distro:Octave-audio, -image, ...• Vast collection of Contributed Packages (Tool boxes):
http://octave.sf.net/.• 725 Page Manual:
http://www.gnu.org/software/octave/doc/interpreter• > pkg install image ∗ .gz• > pkg list• Compilation from source: GNU/Make, GCC (compulsory).
Introduction Octave Code Comparisons
IDE
• Octave-mode (Emacs), QtOctave, XOctave, OctaveNB, Geany• Octavegtk, fltk, ... (for GUI programs)
Introduction Octave Code Comparisons
Matrices
• > A= [1,2,3;4,3,2;7,2,9], eig(A)
• > b = [3,2,2]′, inv(A) ∗ b, A\b• > lu(A),comp(eye(3)A;B zeros(2,2))• > a = 3 : 6,b = 5 : 9,c = [ab] (concatenation)• > (inv(A′A)) ∗A′ == pinv(A)
• > x = linspace(0,2 ∗ pi ,100);• > y = cos(sin(x)), plot(x ,z ,′ :′
,x ,y ,′−′), grid ,xlabel(′angle′), print(′ab.eps ′,′−deps ′)
Introduction Octave Code Comparisons
Basic Tasks
• > save abc Save Workspace as abc.mat• > save filename vbl .• > load filename Load vbl.• > clear var − name• Function: cast(val , type): int64, uint64,logical, char,double, doublecomplex.
• Define a Class from a Struct: class(< struct >,< name >)
Introduction Octave Code Comparisons
Functions
• use unique names for each function• function [out1,out2, ..] = name(input1, ...)
• < function body >• endfunction• script name = function name• Variable number of arguments functionval = smallest(varargin)• Unnamed arguments
Introduction Octave Code Comparisons
Scripts
• Just put the code in a file : alertscr.m• To run: > scr
• Comments: %, #
• Remember: > what
• Scripts can be ’standalone’.
Introduction Octave Code Comparisons
Solvers
• Polynomial: > c = [2,1,0,6,7,9], roots(c)• Solvers for sets of nonlinear equations• All Standard Optimization Problems• Many More ...
Introduction Octave Code Comparisons
Tool Boxes: Examples
• Fuzzy Computations:fuzzy-logic-toolkit, fl-core• Image Processing: image• Signal Processing: signal• Optimization: optim• Video Processing (via ffmpeg) :video• 3D Visualization: vrml
Introduction Octave Code Comparisons
Other Languages
• FORTRAN, C, C++, Python ... code can be used within Octave• Typically as dynamically linked libraries (shared libraries)• Easy to write C, C++ code that uses libraries of Octave likeliboctave.so
• FORTRAN-77, C: Long Robust Algorithms
Introduction Octave Code Comparisons
Code: Octave vs Matlab
• Some Octave constructs will not work in Matlab• –traditional mode more compatible• %, # for comments. C style increment decrement.• default search paths for file names - octave is better• printf - Octave, fprintf - Matlab• Whitespace [1,2] ′ , Line Breaks: rand(1... rand(1,
• 2)
Introduction Octave Code Comparisons
Code: Octave vs Matlab
• 90% Code compatibility• Many tool boxes have exact equivalents• OR contain the functionality of specific Tool Boxes.• Need a specific Tool Box?• Get it Done if you do not have the time.
Introduction Octave Code Comparisons
Octave vs Scilab
• Scilab-often better, not mlab code compatible• Graphics, Parallel, NN, GA, Speed: Scilab• Support: http://www.scilab.in/Completed_Books• Fuzzy Computation, Optim: Octave• Scilab Image Processing; SIVP Toolboxes• Code Sprints:
http://www.gnu.org/software/octave/sprint.html
Introduction Octave Code Comparisons
References I
http://www.gnu.org/software/octave
http://octave.sourceforge.net
http://www.scilab.org
Baudin, M,Scilab is not Naive, 2010http://forge.scilab.org/index.php/p
top related