DOC PREVIEW
Columbia COMS W4115 - Mx - Presentation

This preview shows page 1-2-19-20 out of 20 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 20 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 20 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 20 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 20 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 20 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Mx?GoalsWhat can the language do?Operations and RelationsArray and RangeStatementsFunctions and Function callInternal functionsExample 1: Mr. PotatoOverview of the interpreterCode StatisticsWhy another matrix class?What can we do in Mx with slicing and masking?An example of masking: paint selected entriesThe features of our matrix classThe type systemTesting PlanExample of the Testing DatabaseTesting PlanLessons LearnedMx?A programming language for scientific computation.Related Languages:MatlabIDL Maple, Mathcad, MathematicaGoalsPortability - interpreted and executed by a java interpreter.Efficiency - greatly improves programming efficiency. Program involving many matrix and vector operations are very short in Mx. Ease of use - very simple and quick to startWhat can the language do? Basic matrix operations – addition, multiplication… Advanced operations – matrix slicing and masking. Internal functions – Print, input, load, save, plot, paintOperations and RelationsOperations and RelationsArithmetic OperationsArithmetic Operations*, /, %, /’, ‘, +, -*, /, %, /’, ‘, +, -Logical OperationsLogical Operationsnot and ornot and orRelational OperationsRelational Operations>, >=, <, <=, ==, !>, >=, <, <=, ==, !==Array and RangeArray and RangeRange SpecifierRange Specifier ::i.e.. A[1:10, 1:2]i.e.. A[1:10, 1:2]::::i.e.. A[1::2]i.e.. A[1::2]Array Constructor Array Constructor [1,2;3,4] [1,2;3,4]StatementsStatementsBlock Statement Block Statement {}{}iteration iteration for (n = 1:100);for (n = 1:100);loop loop Assignments Assignments ==Conditional StatementsConditional Statementsif (exp) <stat>;if (exp) <stat>;if (exp) <stat> else if (exp) <stat> else <stat><stat>Break and ContinueBreak and Continuebreak;break;continue;continue;Functions and Function callFunctions and Function callSelf Defined Self Defined FunctionsFunctionsfunc <id> (para-list) func <id> (para-list) = exp;= exp;func <id> (para-list)func <id> (para-list){}{}Function CallFunction Callid(para-list);id(para-list);Note: can either be Note: can either be stand-lone or right stand-lone or right value depends on if it value depends on if it has returned valuehas returned valueInternal functionsInternal functions•Console outputprint() print arguments to the standard output one by one.•Picture drawingpaint() draws a matrix in a new window as an imageplot() takes a matrix and plots it as a graph•Colorcolor() sets the current color (in RGB)colormap() take a matrix with rows as RGB, and sets a colormap.•File I/O functionsload( file, type, m, n )save( matrix, file, type )•Matrix generatorzeros( m, n )random( m, n )•matrix operatorinv( matrix )flip( matrix )Example 1: Example 1: Mr. PotatoMr. PotatoA = load( "potato.dat", "byte", 128,128 );colormap(1);paint( [ A, flip(A), mirror(A), flip(mirror(A));A', flip(A'), mirror(A'), flip(mirror(A'))] );return 0;Overview of the interpreterOverview of the interpreterCurrently the Mx programming language is implemented Currently the Mx programming language is implemented interpretively.interpretively.The interpreter parses and executes the user input or The interpreter parses and executes the user input or programs in files, and generates printed output and/or programs in files, and generates printed output and/or pictures.pictures.The parser of the interpreter is written in Antlr, and the rest The parser of the interpreter is written in Antlr, and the rest routines are in Java.routines are in Java.For a small portion of our code, we tried macro expansion in For a small portion of our code, we tried macro expansion in Java.Java.Adequate functionalities made our project quite large, Adequate functionalities made our project quite large, luckily most of the functions are tested and work well luckily most of the functions are tested and work well (maybe we have forgotten the existences of some (maybe we have forgotten the existences of some functions?)functions?)Code StatisticsCode StatisticsParts Front-endInterpreterMatrix classtest codeStatistics(lines)481 2090 2731 941Total 5891 lines (generated code not included)(partial, currently in CVS)Why another matrix class?Why another matrix class?•The Mx programming language has important functionalities: in-place matrix slicing and masking•Existing Java matrix classes do not support theseWhat can we do in Mx with slicing What can we do in Mx with slicing and masking?and masking?A = zeros(256,256);A[10:40,:] = 1;A[25::50,60::50] = random(50,50);A[A>=0.75 or A<=0.25] = 0.5;A[100:199,100:199] = random(100,100) + A[0::100,0::100]*A[0::100, 100::100] ;An example of masking: paint An example of masking: paint selected entriesselected entriesA = load( "mri-anat.sdt", "short", 256, 256 );B = load( "mri-func.fdt", "float", 256, 256 );A = flip(A');B = flip(B');paint( A );colormap(4);opaint( B, B>0.7, 0, 0, 0.7, 1.0 );The features of our matrix classThe features of our matrix classArithmetic operations: + - * / ...Arithmetic operations: + - * / ...Sharing data between matricesSharing data between matricesMatrix slicing and maskingMatrix slicing and maskingInversion and solving linear equationsInversion and solving linear equationsComparing matricesComparing matricesPainting and plottingPainting and plottingTranspose, flipping and mirroringTranspose, flipping and mirroringAnd more...And more...The type systemThe type systemTesting PlanTesting Plan•3 Stages:3 Stages:•Unit TestingUnit TestingCreation of our own library using Matlab as Creation of our own library using Matlab as guidance. guidance. Library contains its own unit testing program.Library contains its own unit testing program.•Regressive TestingRegressive TestingCreation of a script to automate regressive testing Creation of a script to automate regressive testing written in tclwritten in tclTakes a database of one or more *.mx programsTakes a database of one or more *.mx programsSee exampleSee exampleExample of the Testing DatabaseExample of the Testing Database;;; samples.tdb: a sample of testing;;; samples.tdb: a sample of testing;;; database for the Mx;;; database for the Mx;; assign;; assign1 2 3 4 { a = [1,2;3.4]; return a; }1 2 3 4 { a = [1,2;3.4]; return a; };; transpose;; transpose1 3 2 4 { a = [1.2;3,4]’ ; return a;}1 3 2 4 { a = [1.2;3,4]’ ; return a;};; transpose transpose;; transpose transpose1 2 3 4 { a = [1,2;3,4]’’ ; return


View Full Document

Columbia COMS W4115 - Mx - Presentation

Documents in this Course
YOLT

YOLT

13 pages

Lattakia

Lattakia

15 pages

EasyQL

EasyQL

14 pages

Photogram

Photogram

163 pages

Espresso

Espresso

27 pages

NumLang

NumLang

6 pages

EMPATH

EMPATH

14 pages

La Mesa

La Mesa

9 pages

JTemplate

JTemplate

238 pages

MATVEC

MATVEC

4 pages

TONEDEF

TONEDEF

14 pages

SASSi

SASSi

16 pages

JTemplate

JTemplate

39 pages

BATS

BATS

10 pages

Synapse

Synapse

11 pages

c.def

c.def

116 pages

TweaXML

TweaXML

108 pages

Load more
Download Mx - Presentation
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Mx - Presentation and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Mx - Presentation 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?