÷ƒ’À;è TeX output 1995.02.24:1529‹ÿÿÿÿ …(ö ýb´{ K… ý°¸óHm#½R½p cmss10ëHT‘þE‹ela–éÐUser's“Guideޤ ®„ØcÕÁGŽŽ¡–UUóKñ`y cmr10ÄPš¸ãekk‘ÿqÇa“Janh˜unen,“óßê cmmi10Å:Ž–Ç‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž‘m™Ä3ŽŽ¡‘&3.1.1Ž‘FThe–UUif“statemen¸ãt‘ñ,‘üÅ:Ž–Ç‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž‘m™Ä3ŽŽ¡‘&3.1.2Ž‘FThe–UUwhile“statemen¸ãt‘Ž‘üÅ:Ž–Ç‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž‘m™Ä4ŽŽ¡‘&3.1.3Ž‘FThe–UUrepGeat“statemen¸ãt‘”¢‘üÅ:Ž–Ç‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž‘m™Ä5ŽŽ¡‘&3.1.4Ž‘FThe–UUfor“statemen¸ãt‘”²‘üÅ:Ž–Ç‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž‘m™Ä5ŽŽ¡‘3.2Ž‘&Expressions–UUand“assignmen¸ãts‘ ‘üÅ:Ž–Ç‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž‘m™Ä5ŽŽ¡‘&3.2.1Ž‘FOpGerators‘ñK‘üÅ:Ž–Ç‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž‘m™Ä5ŽŽ¡‘&3.2.2Ž‘FA¸ãtomic‘UUexpressions‘¿\‘üÅ:Ž–Ç‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž‘m™Ä6ŽŽ¡‘&3.2.3Ž‘FAssignmen¸ãts‘›ç‘üÅ:Ž–Ç‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž‘m™Ä7ŽŽ¡‘3.3Ž‘&De ning‘UUfunctions‘ͱ‘üÅ:Ž–Ç‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž‘m™Ä8ŽŽ¡‘3.4Ž‘&The–UUpacš¸ãk‘ÿqÇage“mec˜hanism‘âð‘üÅ:Ž–Ç‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž‘m˜Ä11ŽŽ¤ؽÉ4Ž‘W‘ÿ «riting‘ÕTt- les’u@11ŽŽ¡5Ž‘Program–ÕTcoQÇde“represen®9tations’$12ŽŽ¡6Ž‘W‘ÿ «riting–ÕTC-tela“ les’Z݃13ŽŽ¡7Ž‘Inš®9terfacing–%Òissues“Here“w˜e“explain“the“main“mec˜hanisms“to“comm˜unicate“with“otherޤ ®‘programs–ášand“data“ les“from“T›ÿ «ela.‘ABHo®9w“to“extend“T˜ela“bš®9y“y˜our“o˜wn“C/C++“functionsŽ¡‘has–ÕTbQÇeen“explained“in“the“previous“section.’â`†18ŽŽ¤ؼ‘Ä7.1Ž‘&Matlab‘UUin¸ãterfacing‘”Í‘üÅ:Ž–Ç‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž‘m˜Ä18ŽŽ¡‘7.2Ž‘&HDF‘UUin¸ãterfacing‘†ž‘üÅ:Ž–Ç‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž‘m˜Ä18ŽŽŽŽŒ‹* …(ö ýb´{Ÿ„€ÕÁGŽÉ1.‘ª¨In®9troQÇduction’€½ÓÄ2ŽŽ K… ý¬Pë‘7.3Ž‘&ASCIGI‘UU les‘‘üÅ:Ž–Ç‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž‘m˜Ä19ŽŽ©ؼ‘7.4Ž‘&Graphics‘UUformats‘ í³‘üÅ:Ž–Ç‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž“‘ü:Ž‘m˜Ä19ŽŽŸ(ÁŠâ1Ž‘ÖÿInŠ=trouÂductionŽŸ¿×ÄT‘ÿ*ªela–žis“a“nš¸ãumerical“computing“en˜vironmen˜t“mainly“targeted“for“n˜umerical“sim˜ulation“pre-“and“p•Gostpro“cessingޤ ®wš¸ãork.‘btThe–¥language“suppGorts“arbitrary“rank“arra˜ys“(hence“the“name,›¹T‘ÿ*ªensor“Language),˜and“has“pGo•¸ãw“erfulŽ¡programming–UUcapabilities“including“F90“stš¸ãyle“v˜ector“notation.ަThe–Ðon-line“help“is“in¸ãtended“to“bšGe“the“primary“source“of“do˜cumen¸ãtation.›E\The“command“Éhelp“Ä(É??Ä)˜giv¸ães“helpŽ¡of–ÊVreservš¸ãed“w˜ords,‘ç—in˜trinsic“functions,›ç—standard“functions,˜and“user“functions.‘ÐËThe“function“doGcview()“canŽ¡bšGe–“Ä".‘PÝThe“GNU‘ò|Readline“library“is“the“ rst“la•¸ãy“er›ò•in“teracting˜with˜the˜user.‘PÝThis˜libraryŽ¡mak¸ães– it“easy“to“mošGdify“and“reexecute“previous“commands.‘VZThe“most“imp˜ortanš¸ãt“k˜ey“com˜binations“are“(CtrlŽ¡means–UUkš¸ãeeping“Con˜trol“do˜wn“when“pressing“the“k˜ey):ŽŸ´å‘óߤN cmtt9ÂCtrl-P‘*†FGet–¹–Previous“lineޤ Š=‘Ctrl-N‘*†FGet–¹–Next“lineŽ¡‘Ctrl-F‘*†FForward–¹–cursor“one“character“positionŽ¡‘Ctrl-B‘*†FBackward–¹–cursor“one“character“positionŽ©z‘Ctrl-A‘*†FSet–¹–cursor“position“at“beginning“of“lineŽ¡‘Ctrl-E‘*†FSet–¹–cursor“position“at“End“of“lineŽ¡‘Ctrl-K‘*†FDelete–¹–(Kill)“text“beyond“cursor“positionަ‘TAB‘8³Try–¹–to“complete“reserved“word,“identifier“or“filenameŽ¡‘Enter‘/?ÜExecute–¹–command“line“(cursor“need“not“be“at“end“position)ŽŽŽŒ‹¦ …(ö ýb´{Ÿ„€ÕÁGŽÉ2.‘ñÄSimple›ÕTin•®9teractiv“e˜use’OÙûÄ3ŽŽ K… ý¸Û(‘ÂCtrl-C‘*†FInterrupt–¹–command“during“command“executionŽŸ Š=‘Ctrl-D‘*†FQuit–¹–Tela“(must“be“alone“in“line)ŽŸ:AÄY‘ÿ*ªou›•±ha•¸ãv“e˜probably˜used˜other˜soft“w“are˜whic“h˜also˜uses˜the˜GNU–• Readline˜library‘ÿ*ª,‘¥Èe.g.‘2Ûthe˜GNU“debuggerޤ ®ÉgdbÄ.‘w~If–¬’yš¸ãour“terminal“is“propGerly“con gured,‘Âay˜ou“can“use“the“arro˜w“k˜eys“instead“of“Ctrl-P‘ÿ*ª,“Ctrl-N,“Ctrl-FŽ¡and–)èCtrl-B‘)Þto“mo•¸ãv“e–)èin“the“history“bu er.‘cNY‘ÿ*ªou“should“get“familiar“with“these“commands“as“sošGon“as“p˜ossible,Ž¡since–Üàit“will“greatly“spGeed“up“yš¸ãour“w˜orking“with“T›ÿ*ªela.‘hThe“command“completion“is“able“to“complete“T˜elaŽ¡reserv•¸ãed›ƒ]w“ords,‘Žßfunction˜names˜(either˜in“trinsic,–Žßstandard,“or˜user-de ned),“v‘ÿqÇariables˜names˜and˜ lenames.Ž¡Filename–$"completion“is“in•¸ãv“ok“ed–$"if“the“T‘ÿ*ªAB‘$k¸ãey“is“pressed“inside“a“string“(\...").‘aaThis“can“bGe“useful“with“theŽ¡Ésource–UUÄcommand,“for“example.Ž©ؼT‘ÿ*ªela–Ø:uses“the“X‘Øwindoš¸ãw“system“to“displa˜y“graphics.‘HThe“graphics“is“displa˜y˜ed“b˜y“a“separate“program,‘ñ@namedŽ¡PlotMTV,–Ÿbut“calling“it“is“transparenš¸ãt“to“the“user.‘N×The“DISPLA‘ÿ*ªY‘žòen˜vironmen˜t“v‘ÿqÇariable“m˜ust“bšGe“prop˜erlyŽ¡de ned,–UUotherwise“the“graphics“will“not“w¸ãork.ަT‘ÿ*ªry–PËenš¸ãtering“the“follo˜wing“commands“ rst“(\Å>“Ä\“means“the“T‘ÿ*ªela“prompt“whic˜h“y˜ou“ob˜viously“do“not“t˜ypGe):ŽŸj‘Â>‘¹–x=0:0.1:4*piŽŸ Š=‘>‘¹–plot(x,sin(x))ŽŸ:AÄThe–oW rst“command“creates“a“vš¸ãector“of“real“n˜um˜bGers“ranging“from“0“to“4“times“Pi“with“step“0.1“and“assignsŽ¡the–@vš¸ãector“to“v‘ÿqÇariables“x.‘j°The“second“command“then“plots“sin(x)“v˜ersus“x.‘j°A‘@ graph“of“sin(x)“should“appGearŽ¡in–UUa“new“PlotMTV“windo¸ãw,“if“not,“the“system“is“not“propGerly“installed.ަIn–â_Matlab,›ù]an“expression“is“prin¸ãted“if“there“is“no“semicolon“at“the“end“of“command“line.‘KuIn“T‘ÿ*ªela,˜ho•¸ãw“ev“er,˜anŽ¡expression–ûòis“prinš¸ãted“if“it“is“not“assigned“to“an˜y“v‘ÿqÇariable,‘ Óregardless“of“an˜y“semicolon.‘SüIn“fact,‘ ÓT‘ÿ*ªela“in˜ternallyŽ¡inserts–¥a“semicolon“at“the“end“of“ev¸ãery“command“line“bGefore“actually“parsing“it.‘`ßThe“insertion“is“not“doneŽ¡when–UUreading“commands“from“a“ le.ަThis–UUleads“us“to“the“next“topic:›qÇho¸ãw“to“execute“commands“from“a“ le.˜T¸ãypGeŽŸj‘Â>‘¹–source("demo")ŽŸ:AÄA–Ußmenš¸ãu“of“c˜hoices“appšGears,‘Vbut“let“us“ rst“explain“what“the“Ésource“Äcommand“do˜es.‘sdIt“lo˜oks“for“ le“namedŽ¡\demo.t"–in“the“currenš¸ãt“TELAP–ÿ*ªA“TH‘í(if–the“ le“name“con˜tains“a“p•Gerio“d,‘Ethe–\.t"“is“not“appGended).‘±%TheŽ¡TELAP–ÿ*ªA“TH‘ê¡is–ê¼a“list“of“directories“where“input“ les“are“searc¸ãhed,‘similar“in“function“to“the“Unix“P–ÿ*ªA“TH.‘ê¼TheŽ¡ le–Žé\demo.t"“is“found“in“some“standard“directory“and“commands“in“it“are“executed.‘/£The“curren¸ãt“TELAP–ÿ*ªA“THŽ¡can–UUbGe“seen“b¸ãy“giving“the“command“Ételapath()Ä.ަWhen–ñreading“commands“from“a“t- le,‘)there“should“bGe“a“semicolon“at“the“end“of“eacš¸ãh“statemen˜t“(or“actuallyŽ¡separating–UUthe“consecutivš¸ãe“statemen˜ts,“but“the“di erence“is“unessen˜tial“here).ަOK,–ÀÏnoš¸ãw“pla˜y“with“the“demos.‘´4Press“a“n˜um˜bGer“and“ENTER‘À³to“the“men˜us,‘Û­to“get“bac˜k“to“command“lev˜elŽ¡select‘UUQuit.ަThe–Ôõtš¸ãypical“and“recommended“w˜a˜y“to“use“T‘ÿ*ªela“when“dev˜eloping“something“bigger“than“one“line“is“theŽ¡folloš¸ãwing:‘¶ÁOpGen–wÒan“editor“windo˜w“and“a“shell“(Xterm)“executing“T‘ÿ*ªela“on“y˜our“w˜orkstation.‘Ù>Create“a“t- le,Ž¡for–Udexample“\mine.t"“with“the“editor“and“write“some“T‘ÿ*ªela“commands“in“it.‘qóRemem¸ãbGer“to“use“semicolons“asŽŽŽŒ‹%î …(ö ýb´{Ÿ„€ÕÁGŽÉ3.‘ª¨Basics–ÕTof“the“language’P-4Ä4ŽŽ K… ý¬Pëstatemenš¸ãt–h_separators.‘ªæT‘ÿ*ªry“it“out“b˜y“t˜yping“Ésource(\mine.t")“Äin“the“T‘ÿ*ªela“windo˜w.‘ªæY‘ÿ*ªou“m˜ust“ha˜v˜e“startedޤ ®T›ÿ*ªela–³õfrom“the“same“directory“where“\mine.t"“lies,‘Ëor“y¸ãou“can“use“the“T˜ela“Écd“Äcommand“to“c¸ãhange“to“thatŽ¡directory‘ÿ*ª.–\(See›§Éhelp‘ŒcdÄ.)“Doing˜this˜repGeatedly˜y•¸ãou˜only˜need˜sa“v“e˜the˜ le˜from˜the˜editor˜and˜press˜Ctrl-PŽ¡ENTER‘ain–aT‘ÿ*ªela“windoš¸ãw“to“execute“the“ le“with“c˜hanges“y˜ou“just“made.‘•$This“is“only“sligh˜tly“clumsier“thanŽ¡program›íÆdev•¸ãelopmen“t˜with˜T‘ÿ*ªurbGo˜P“ascal˜in˜the˜old˜times:‘>instead˜of˜a˜single˜k“eypress˜y“ou˜no“w˜ha“v“e˜to˜pressŽ¡three–UUkš¸ãeys“and“switc˜h“the“windo˜w“with“the“mouse“once“to“execute“the“program!ŽŸ(ºâ3Ž‘ÖÿBasics–…of“the“languageŽŸ¿×ÄThe–Î rst“thing“to“bšGe“men¸ãtioned“ab˜out“the“T‘ÿ*ªela“language“is“that“it“is“in“man¸ãy“resp˜ects“similar“to“C,“or“C++.Ž¡So›×hm•¸ãuc“h˜so˜that˜I–×Fusually˜use˜the˜GNU“Emacs˜C++˜mo•Gde˜to˜edit˜T‘ÿ*ªela˜co“de,‘÷ìsince˜there˜is˜not˜a˜sp“eci cŽ¡T‘ÿ*ªela–mošGde“(ma¸ãyb˜e“yš¸ãou“could“con˜tribute“one?).‘ÔThere“is“an“Éif“Ästatemen˜t“(3.1.1),‘šða“Éwhile“Ästatemen˜t“(3.1.2)Ž¡and–Éùa“Éfor“Ästatemenš¸ãt“(3.1.4).‘Ï´There“are“of“course“man˜y“syn˜tactic“di erences“also,‘ç"but“t˜w˜o“of“them“are“theŽ¡most‘UUfundamen¸ãtal:Ž©ؼ1.‘,¾In–†7C,“a“semicolon“ends“a“statemenš¸ãt“whilst“in“T‘ÿ*ªela“a“semicolon“is“a“separator“bGet˜w˜een“successiv˜e“statemen˜ts.Ž¡T‘ÿ*ªela's–vuse“of“semicolons“is“equiv‘ÿqÇalenš¸ãt“to“P˜ascal“rather“than“C‘vin“this“respGect.‘ÔThis“means“for“example“thatŽ¡the–UUrighš¸ãt“brace“is“usually“follo˜w˜ed“b˜y“a“semicolon“in“T‘ÿ*ªela,“or“at“least“that“a“semicolon“doGes“no“harm“there.ަ2.›”JIn–¶+C‘¶the“assignmen¸ãt“is“an“opGerator,‘Îai.e.˜Ça=b‘WÃÄis“synš¸ãtatically“an“expression“not“a“statemen˜t.‘”JIn“T‘ÿ*ªela“theŽ¡assignmenš¸ãt–¾is“a“statemen˜t.‘¬This“is“also“similar“to“P˜ascal.‘¬This“implies“that“the“use“of“assignmen˜t“is“moreŽ¡restricted–UUin“T‘ÿ*ªela“than“it“is“in“C“or“C++.ŽŸ"tÐó0ÂÖN  cmbx12Û3.1Ž‘ÀFloš w–€of“con˜trol“statemen˜tsޤNÄThe–UUfolloš¸ãwing“subsubsections“describGe“the“T‘ÿ*ªela“con˜trol“structures.ŽŸ -"É3.1.1Ž‘##‚The–ÕTif“statemen®9tŽ¡ÄThe–UUÉif“Ästatemenš¸ãt“has“the“follo˜wing“syn˜tax“(Çstmt‘H-Ä=“statemen˜t):ޤÚÜ‘Âif‘¹–(expr)Ž© Š=‘',ÂstmtŽŸþ³ÄorŽ¡‘Âif‘¹–(expr)ަ‘+æXstmtަ‘elseަ‘+æXstmtŽŸþ³ÄThe–ù)conditional“expression“Çexpr‘ ¶Ämš¸ãust“bGe“enclosed“in“paren˜theses.‘SThere“m˜ust“bšGe“no“semicolon“b˜et•¸ãw“een‘ù)Çstmtޤ ®Äand‘UUÉelseÄ.ŽŸؼThe–):expression“mš¸ãust“ev‘ÿqÇaluate“to“in˜teger“scalar“or“arra˜y‘ÿ*ª.‘ívThe“condition“is“considered“true“if“the“scalar“isŽ¡nonzero–UUor“if“all“the“arraš¸ãy“elemen˜ts“are“nonzero.‘qÇExamples:ŽŽŽŒ‹4¤ …(ö ýb´{Ÿ„€ÕÁGŽÉ3.‘ñÄBasics–ÕTof“the“language’NæÄ5ŽŽ K… ý¬Pë‘Âif‘¹–(x!=0)ޤ Š=‘+æXformat("x–¹–is“nonzero,“x=``\n",x)‘æX//“notice“no“semicolonŽ¡‘else‘¹–{Ž¡‘+æXx–¹–=“1;Ž¡‘+æXformat("x–¹–was“zero“and“is“now“1\n");//“this“semicolon“is“optionalŽ¡‘};‘ s,//–¹–this“semicolon“separates“this“if“stmt“from“the“next“stmt,“if“anyŽŸY·ÄNested–UUÉif“Ästatemenš¸ãts“are“written“in“the“follo˜wing“st˜yle:Ž©5à‘Âif–¹–(a“==“1)“{Ž¡‘+æX/*–¹–action“for“a==1“*/Ž¡‘}–¹–else“if“(a“==“2)“{Ž¡‘+æX/*–¹–action“for“a==2“*/Ž¡‘}–¹–else“if“(a“==“3)“{Ž¡‘+æX/*–¹–action“for“a==3“*/Ž¡‘}–¹–else“{Ž¡‘',Â/*–¹–action“for“none“of“the“above“*/Ž¡‘};ŽŸ ¸É3.1.2Ž‘##‚The–ÕTwhile“statemen®9tŽŸNÄThe–UUÉwhile“ÄloGop“statemenš¸ãt“has“the“follo˜wing“syn˜tax:ަ‘Âwhile‘¹–(expr)Ž¡‘+æXstmt‘¹–;ŽŸY·ÄF‘ÿ*ªor‘UUexample:ަ‘+æXÂwhile–¹–(!found)“{Ž¡‘>̰LookForIt();Ž¡‘>̰counter++Ž¡‘+æX};ŽŸY·ÄThe– ÿstatemenš¸ãt“is“executed“un˜til“Çexpr›ŒÄev‘ÿqÇaluates“to“true.‘X«The“"trueness"“of“Çexpr˜Äis“similar“to“the“Éif“Ästatemen¸ãtŽŸ ®(3.1.1):‘qÇa–UUscalar“and“all“elemenš¸ãts“of“an“in˜teger“arra˜y“m˜ust“bšGe“nonzero“for“Çexpr‘hâÄto“b˜e“true.ŽŸ ¸É3.1.3Ž‘##‚The–ÕTrepQÇeat“statemen®9tŽŸNÄThe–UUÉrepQÇeat“ÄloGop“statemen¸ãt“has“the“formަ‘ÂrepeatŽ¡‘+æXstmt1;Ž¡‘+æXstmt2;Ž¡‘+æX...Ž¡‘until‘¹–expr;ŽŸY·ÄThe–ý¿statemen¸ãts“Çstmt1–[Ä,›'ÚÇstmt2“Ä,˜...›kare–ý¿iterated“un¸ãtil“Çexpr‘LÄev‘ÿqÇaluates“to“true“(nonzero).˜The“statemen¸ãts“areŽŸ ®alw•¸ãa“ys–UUexecuted“at“least“once.‘qÇIt“is“analogous“to“the“ÉrepQÇeat“Ästatemenš¸ãt“in“P˜ascal.ŽŽŽŒ‹@ …(ö ýb´{Ÿ„€ÕÁGŽÉ3.‘ª¨Basics–ÕTof“the“language’P-4Ä6ŽŽ K… ý¬PëÉ3.1.4Ž‘##‚The–ÕTfor“statemen®9tŽŸNÄThe–UUÉfor“ÄloGop“statmen¸ãt“has“the“formŽ©´å‘Âfor–¹–(initstmt;“expr;“updatestmt)“stmt;ŽŸؼÄIt–UUis“equiv‘ÿqÇalenš¸ãt“to“the“Éwhile“Ästatemen˜tŽŸ´å‘Âinitstmt;ޤ Š=‘while–¹–(expr)“{Ž¡‘+æXstmt;Ž¡‘+æXupdatestmt;Ž¡‘};ŽŸؼÄThe–²^syn¸ãtax“is“rather“similar“to“C,“but“there“is“a“di erence:‘ Kthe“Çinitstmt‘òØÄ,‘ÒöÇup‘ÿ}'datestmt›¥6Äand“Çstmt˜Äare“statemen¸ãts,ޤ ®not–i›expressions.›#4On“the“other“hand“there“is“no“comma“opGerator“in“T‘ÿ*ªela.˜Thš¸ãus“y˜ou“cannot“write“Éfor(i=0,j=0;Ž¡i<10;‘ÕTi++)–UUÄbut“instead“yš¸ãou“m˜ust“writeަ‘Âfor–¹–({i=1;“j=1};“i<=10;“i++)“{“/*“...“*/“};ŽŸؼÄW‘ÿ*ªe››in•¸ãten“tionally˜c“hanged˜the˜loGop˜running˜from˜1,–¬not˜0,“to˜remind˜that˜in˜T‘ÿ*ªela˜the˜ rst˜arra¸ãy˜index˜is˜1,Ž¡not–UU0“as“in“C.ŽŸ# Û3.2Ž‘ÀExpressions–€and“assignmen tsޤNÄThe–UUfolloš¸ãwing“subsubsections“describGe“T‘ÿ*ªela“expressions“and“assignmen˜t“statemen˜ts.ŽŸ ÖòÉ3.2.1Ž‘##‚OpQÇeratorsŽ¡ÄExpressions–xõare“compšGosed“of“atomic“expressions“and“op˜erators.‘ܨA¸ãtomic“expressions“can“b˜e“v‘ÿqÇariable“names,ޤ ®literal–Êconstanš¸ãts“(in˜tegers,–Œèreals,“imaginary‘Êconstan˜ts,“c˜haracters,“arra˜y›Êconstructors,“and˜strings),“functionŽ¡calls,‘ȶor–~parra¸ãy“references.‘íOpšGerators“usually“ob˜ey“the“precedence“rules“in“other“programming“languagesŽ¡where–UUpšGossible.‘qÇThe“op˜erators“are,“from“lo•¸ãw“est–UUto“highest“precedence:ަ‘ÂOperators–!Associativity“Meaningޤ Š=‘---------–!-------------“-------Ž¡‘:‘FßÊnon-associative‘ŸîVector‘¹–creationŽ¡‘||‘B&4left‘K™`Logical‘¹–ORŽ¡‘&&‘B&4left‘K™`Logical‘¹–ANDŽ¡‘==–¹–!=‘3ùrleft‘K™`Equality“and“nonequalityŽ¡‘>–¹–>=“<“<=‘!left‘K™`Greater“than“etc.Ž¡‘+–¹–-‘=lžleft‘K™`Addition“and“subtractionŽ¡‘*–¹–**“/“mod‘Y„left‘K™`Pointwise“multiplication,Ž¡’ÌŒDmatrix‘¹–multiplication,Ž¡’ÌŒDpointwise‘¹–division,ŽŽŽŒ‹FŽ …(ö ýb´{Ÿ„€ÕÁGŽÉ3.‘ñÄBasics–ÕTof“the“language’NæÄ7ŽŽ K… ý¬Pë’ÌŒDÂmodulus‘¹–operationޤ Š=‘-–¹–+‘=lžnon-associative‘ŸîUnary“minus“and“plusŽ¡‘^–FßÊright“ExponentiationŽ¡‘!‘FßÊnon-associative‘ŸîLogical‘¹–NOTŽ¡‘.'–¹–'‘8³non-associative‘ŸîTranspose,“Hermitian“transposeŽ©ؼÄIn–aÍF‘ÿ*ªortran,‘¤ëthe“opšGerator“É**“Äw¸ãould“b˜e“exp˜onenš¸ãtiation,‘¤ëin“T‘ÿ*ªela“it“is“matrix“m˜ultiplication.‘—/In“C‘aˆÊ^“Äw˜ouldޤ ®bšGe–×Ãlogical“X¸ãOR,“in“T‘ÿ*ªela“it“is“exp˜onenš¸ãtiation.‘ùIn“Matlab“É*“Ädenotes“matrix“m˜ultiplication“and“É.*“ÄpGoin˜t˜wiseŽ¡mš¸ãultiplication,‘‡Åin–J{T‘ÿ*ªela“É*“Äis“pGoin˜t˜wise“m˜ultiplication“and“É**“Äis“the“matrix“proGduct.‘Q:There“are“no“matrixŽ¡pšGo•¸ãw“er–ð and“division“op˜erators“in“T›ÿ*ªela“as“there“are“in“Matlab.‘AðThe“equiv‘ÿqÇalen¸ãt“of“matrix“division“in“T˜ela“isŽ¡the–²çfunction“Élinsolv®9eÄ.‘Š}The“vš¸ãector“creation“opGerator“uses“the“notation“Éa:step:bÄ,‘ÊKwhic˜h“follo˜ws“the“MatlabŽ¡con•¸ãv“en“tion.›2In–K“F‘ÿ*ªortran-90“the“step“is“the“last“mem¸ãbGer,‘€ºÉa:b:stepÄ.˜The“set“of“opGerators“is“the“same“as“in“C,“withŽ¡the– addition“of“vš¸ãector“creation,‘;matrix“m˜ultiplication,–;mošGdulus,“exp˜onen¸ãtiation,“transp˜ose– and“HermitianŽ¡transp•Gose›âop“erators.‘  These˜additional˜op“erators˜follo•¸ãw˜Matlab˜con“v“en“tions˜except˜for˜the˜di erence˜inŽ¡pGoin•¸ãt“wise–UUand“matrix“nature“of“m¸ãultiplication.ŽŸ ÖòÉ3.2.2Ž‘##‚A®9tomic‘ÕTexpressionsŽŸNÄA¸ãtomic–UUexpressions“can“bGe:ŽŸ´å‘Âvariable–¹–names‘*†Fa,“b_89,“$x,“$_x9$ޤ Š=‘integer–¹–constants‘Y„0,“23Ž¡‘real–¹–constants‘*†F1.23,“4.5E3,“0.03Ž¡‘imaginary–¹–constants‘æX1.23i,“4.5E3i,“0.03iŽ¡‘characters‘=lž'a'Ž¡‘array–¹–constructors‘Ÿî#(1,2,3),“#(a,b;“c,d)Ž¡‘strings‘K™`"with–¹–possible“escape“sequences\n"Ž¡‘function–¹–calls‘*†Ff(),“f(1),“f(a+b,g(c))Ž¡‘array–¹–references‘!a[i,j],“a[1],“a[1:imax,2:jmax-1]Ž¡‘mapped–¹–references‘Y„a<[i,j]>,“a<[1]>ަÄV‘ÿ*ªariable–‚Ônames,‘Ž3or“anš¸ãy“iden˜ti er“names“for“that“matter,‘Ž3start“with“a“letter.‘úCThe“rest“of“the“c˜haracters“canޤ ®also–UUbGe“digits“or“underscores.‘qÇThe“dollar“sign“is“also“accepted“as“a“\letter"“in“iden¸ãti ers.Ž©ؼImaginary–»œconstanš¸ãts“are“obtained“from“real“constan˜ts“b˜y“appGending“Éi“Äwith“no“in˜terv˜ening“white“space.‘>ŠThereŽ¡is–Qno“explicit“notation“for“complex“constan•¸ãts,‘Ry“ou›Qm“ust˜use˜the˜addition˜or˜subtraction˜opGerators˜as˜in˜É2+3iŽ¡Äor–¶©É0.5-0.75iÄ.›•ÂThe“w•¸ãa“y–¶©to“denote“the“imaginary“unit“\i"“is“to“write“É1iÄ.˜Notice“that“\i"“here“is“part“of“theŽ¡synš¸ãtax.‘6—There–£Äis“no“prede ned“v‘ÿqÇariable“or“constan˜t“named“\i",‘ÇHand“2+3*i“will“generally“not“w˜ork“as“expGectedŽ¡(unless–UUyš¸ãou“ha˜v˜e“assigned“Éi–ÕT=“1iÄ,–UUbut“this“is“not“recommended).ަCharacter–Ô…constanš¸ãts“are“equiv‘ÿqÇalen˜t“to“their“ASCI•GI‘Ôdco“des–Ô…(in˜tegers)“if“used“in“arithmetic“expressions.‘ïWThisŽ¡practice–UUis“similar“to“C.ަArraš¸ãy–¾¦constructors“are“a“bit“more“complicated.‘­ºSyn˜tactically“an“arra˜y“constructor“has“the“formŽ¡É#(Çc–ÿ}'omp“onent-list‘òØÉ)Ä,‘ö2where›ÖÇc“omp“onent-list‘ÈÞÄconsists˜of˜expressions˜separated˜b¸ãy˜commas˜and/or˜semicolons.Ž¡Commas–Gfdenote“appšGending“the“comp˜onenš¸ãts“to“form“a“v˜ector.‘GûF‘ÿ*ªor“example,‘ƒêÉ#(1:5,10)“Äwill“proGduce“theŽŽŽŒ‹N® …(ö ýb´{Ÿ„€ÕÁGŽÉ3.‘ñÄBasics–ÕTof“the“language’NæÄ8ŽŽ K… ý¬Pëin•¸ãteger›óv“ector˜É#(1,2,3,4,5,10)Ä,‘IÚand˜É#(1,2.3,4:-1:1,34)˜ÄproGduces˜É#(1,–î‡2.3,“4,“3,“2,“1,“34)Ä.‘¼¡The˜lastޤ ®example–UUgivš¸ães“a“real“v˜ector“bšGecause“one“of“the“comp˜onenš¸ãts“w˜as“fractional“n˜um˜bGer.Ž©ؼA‘!semicolon–5in“the“arraš¸ãy“constructor“denotes“compGosing“a“higher-rank“arra˜y“of“the“compGonen˜ts,‘owhic˜h“m˜ustŽ¡bGe›òñlo•¸ãw“er-rank˜arra“ys˜(or˜scalars).‘JœF‘ÿ*ªor˜example,‘Xa˜matrix˜can˜bGe˜constructed˜from˜its˜ro“w˜v“ectors˜Év1˜ÄandŽ¡Év2–[òÄbš¸ãy“É#(v1;v2)Ä.‘…žThe“precedence“of“a“semicolon“inside“arra˜y“constructor“is“lo˜w˜er“than“the“precedence“of“aŽ¡comma,–UUth¸ãus“É#(a,b;‘ÕTc,d)“Äwill“construct“of“2x2“matrix.ަThe–¬Narraš¸ãy“constructors“w˜ork“for“higher“rank“arra˜ys“as“w˜ell.‘v³The“result“of“arra˜y“constructor“using“commasŽ¡has–¡Ûrank“equal“to“the“highest“rank“of“the“compšGonen¸ãts,‘´üand“the“ranks“of“the“comp˜onenš¸ãts“ma˜y“not“di er“b˜yŽ¡more–”…than“one.‘/VThe“impšGortan¸ãt“exception“is“the“case“where“all“the“comp˜onen¸ãts“are“scalars;‘´in“this“case“theŽ¡result–45is“a“vš¸ãector.‘hThe“semicolon“arra˜y“constructor“alw˜a˜ys“proGduces“a“result“whic˜h“has“rank“one“greaterŽ¡than–êºthe“rank“of“the“compGonen•¸ãts,‘ whic“h›êºm“ust˜b•Ge˜same˜for˜all˜comp“onen•¸ãts˜in˜the˜semicolon˜case.‘N>Using˜arra“yŽ¡constructors–UUfor“higher-rank“compšGonen¸ãts“has“b˜een“rare“in“practice.ަNotice–ðÄthat“the“commas“and“semicolons“ha•¸ãv“e–ðÄcompletely“di erenš¸ãt“meaning“inside“arra˜y“constructors“thanŽ¡outside‘UUthem.ަStrings–UUmaš¸ãy“con˜tain“escapGe“sequences“similar“to“C“language“strings.ަArraš¸ãy–Lreferences“follo˜w“the“P˜ascal“syn˜tax,‘,Jseparating“the“dimensions“with“a“comma.‘u­The“indices“ma˜y“bGeŽ¡v•¸ãectors,›UUwhic“h˜follo“ws˜the˜F‘ÿ*ªortran-90˜and˜Matlab˜arra“y˜syn“tax˜ideas˜(\gather"˜opGerations).ަIn–†­addition“to“normal“arraš¸ãy“references,‘“T‘ÿ*ªela“also“suppGorts“Çmapp–ÿ}'e“d‘6Äarra˜y–†­references.‘ÐIn“mappGed“referencingŽ¡the–qÔindex“ob‘Ž8jects“mš¸ãust“all“agree“in“t˜ypGe“(they“are“usually“arra˜ys).‘ÇDThe“n˜um˜bGer“of“indices“m˜ust“bGe“equal“toŽ¡the–UUrank“of“the“indexed“arraš¸ãy“and“the“result“will“ha˜v˜e“size“equal“to“an“index“ob‘Ž8ject.‘qÇF‘ÿ*ªor“example,Ž©´å‘ÂA<[1:5,1:5]>ŽŸؼÄwill–Á:proGduce“the“ rst“ vš¸ãe“diagonal“elemen˜ts“of“matrix“A‘Áas“a“v˜ector.‘@iMappšGed“indexing“can“b˜e“used“to“extractŽ¡N-dimensional–9àcompGonenš¸ãt“subsets“from“M-dimensional“arra˜ys,‘?^bGoth“N›9Ùand“M˜bGeing“arbitrary‘ÿ*ª.‘h The“functionŽ¡Éin®9tpQÇol–p[Ä(linear“in¸ãterpšGolation)“can“b˜e“though¸ãt“as“a“generalization“of“mapp˜ed“indexing,‘·where“the“\index"Ž¡expressions–UUneed“not“bGe“in¸ãtegers.ŽŸ ÖòÉ3.2.3Ž‘##‚Assignmen®9tsŽŸNÄAssignmenš¸ãts–UUcan“tak˜e“the“follo˜wing“three“forms:ަ‘Âvariable–¹–=“expr“;ޤz‘variable[index1,...]–¹–=“expr“;Ž¡‘[var1,var2,...]–¹–=“fname(expr1,expr2,...)“;ŽŸؼÄThe–L› rst“form“is“a“simple“assignmen¸ãt,‘Šmwhere“the“v›ÿqÇalue“of“the“expressions“is“assigned“to“a“v˜ariable.‘WšTheޤ ®second–¼form“is“the“\scatter"“opGeration,‘ÕÆor“indexed“assignmenš¸ãt.‘¦ The“indices“follo˜w“the“same“rules“as“if“theŽ¡arraš¸ãy–UUreference“appGears“on“the“righ˜t-hand-side“of“an“assignmen˜t“(see“previous“subsubsection).ŽŽŽŒ‹ \ …(ö ýb´{Ÿ„€ÕÁGŽÉ3.‘ª¨Basics–ÕTof“the“language’P-4Ä9ŽŽ K… ý¬PëThe–1third“form“is“actually“not“an“assignmenš¸ãt“but“a“function“call“with“sev˜eral“output“argumen˜ts“a“la“Matlab.ޤ ®The–'output“v‘ÿqÇariables“mš¸ãust“bGe“separated“b˜y“commas“(In“Matlab“the“commas“ma˜y“bGe“left“out.)‘>The“outputŽ¡v‘ÿqÇariables–UUmš¸ãust“bGe“simple“iden˜ti ers,“not“expressions.‘qÇF‘ÿ*ªor“example,“y˜ou“cannot“sa˜yޤêÈ‘Â[b[1],b[2]]–¹–=“f();‘*†F//“WRONG!!!Ž©ŸÄY‘ÿ*ªou–UUm¸ãust“use“auxiliary“v‘ÿqÇariables,“as“inŽ¡‘Â[b1,b2]–¹–=“f();ŽŸ Š=‘b[1]–¹–=“b1;“b[2]“=“b2;ަÄThere–UUare“some“cš¸ãhances“that“this“limitation“migh˜t“bGe“remo˜v˜ed“in“some“future“v˜ersion.ŽŸ"ûÑÛ3.3Ž‘ÀDe ning‘€functionsŽŸNÄExamples–UUof“function“de nition“statemen¸ãts:ŽŸ5‘Âfunction–¹–f()“{“/*“body“*/“};‘Ÿî//“the“simplest“formޤz‘function–¹–f(x)“{“/*“body“*/“};Ž¡‘function–¹–y=f(x)“local(a)“{“/*“...“*/;“y“=“sin(x)“};Ž¡‘function–¹–[x,y]“=“f(a,b)“{“/*“...“*/“};Ž¡‘function–¹–[x,y;z,w]“=“f(a,b;n)“global“{“/*“...“*/“};ŽŸ7 ÄThe–0 de nition“alw•¸ãa“ys–0 bGegins“with“the“reservš¸ãed“w˜ord“ÉfunctionÄ.‘e‹After“Éfunction“Äcomes“the“output“argumen˜tޤ ®sp•Geci cation›Q(p“ossibly˜empt•¸ãy),‘follo“w“ed˜b“y˜the˜function˜name˜and˜input˜argumen“t˜list,‘pGossible˜ÉloQÇcal˜ÄorŽ¡Églobal–UUÄdeclarations“and“ nally“the“function“b•Go“dy–UUenclosed“in“curly“braces.Ž©ؼInput–r%argumenš¸ãts“are“passed“b˜y“reference.‘È6They“ma˜y“not“bšGe“mo˜di ed“in“the“function“b˜o˜dy›ÿ*ª.‘È6(If“y¸ãou“try˜,‘yYy¸ãouŽ¡get–IÁa“wš¸ãarning“message.)‘mëTh˜us“the“calling“program“ma˜y“Çthink‘]NÄthat“the“input“argumen˜ts“are“passed“b˜y“v‘ÿqÇalueŽ¡evš¸ãen–Xthough“they“actually“aren't.‘ïÑIn“C++“the“t˜ypGe“of“the“input“argumen˜ts“w˜ould“bGe“Éconst‘¤Tt®9ypQÇe&Ä,‘‰ÙandŽ¡in–PœF‘ÿ*ªortran-90“they“wš¸ãould“correspGond“to“the“\in˜ten˜t“input"“argumen˜ts.‘p4Input“argumen˜ts“are“listed“follo˜wingŽ¡the–UUfunction“name“bGoth“when“de ning“and“calling“a“function.ަOutput–}øargumenš¸ãts“are“listed“in“brac˜k˜ets“bšGefore“the“\É=Ä"“sign“and“the“function“name“b˜oth“in“de nition“andŽ¡calling–³õphases.‘¦If“there“is“only“one“output“argumenš¸ãt,‘Ëthe“brac˜k˜ets“ma˜y“bšGe“dropp˜ed“(see“the“third“exampleŽ¡abGo•¸ãv“e).‘mâOutput›I§argumen“ts˜are˜also˜passed˜b“y˜reference,‘Kýbut˜ob“viously˜they˜ma“y˜and˜should˜b•Ge˜mo“di ed˜b¸ãyŽ¡the–UUfunction“b•Go“dy‘ÿ*ª.ަBy–£Idefault,‘Ææinput“argumenš¸ãts“are“obligatory“and“outputs“argumen˜ts“are“optional.‘6nThat“is,‘Ææthe“calling“programŽ¡mš¸ãust–2supply“all“input“argumen˜ts,‘9vbut“it“ma˜y“lea˜v˜e“out“some“or“all“of“the“output“argumen˜ts.‘f*F‘ÿ*ªor“example,‘9vifŽ¡Éf–UUÄis“de ned“asŽŸêÈ‘Âfunction–¹–[a,b,c]“=“f(x,y)“{“/*“...“*/“};ŽŽŽŒ‹ iw …(ö ýb´{Ÿ„€ÕÁGŽÉ3.‘ñÄBasics–ÕTof“the“language’IæÄ10ŽŽ K… ý¬Pëall–UUthe“follo¸ãwing“are“legal“call“forms“for“ÉfÄ:ŽŸ´å‘Â[X,Y,Z]–¹–=“f(2+3i,sin(X+y));‘Ÿî//“use“all“output“argumentsޤz‘[X,Y]–¹–=“f(1,2);‘Ÿî//“ignore“the“third“output“argumentŽ¡‘X–¹–=“f(1,2);‘*†F//“ignore“second“and“thirdŽ¡‘[]–¹–=“f(1,2);‘%̰//“ignore“allŽŸؼÄThe–Ïdefault“bGehaš¸ãvior“of“obligatory“and“optional“argumen˜ts“can“bGe“c˜hanged“b˜y“using“the“semicolon“insideޤ ®argumen•¸ãt›òñlist.‘PûA“t˜most˜one˜semicolon˜ma“y˜appGear˜inside˜an˜argumen“t˜list.‘PûThe˜rule˜is˜simple:‘@•all˜argumen“tsŽ¡Çb–ÿ}'efor“e‘¾qÄthe–þsemicolon“are“obligatory‘ÿ*ª,›(Gthat“is,˜required,˜and“all“argumen¸ãts“Çafter‘£Äthe“semicolon“are“optional.Ž¡This–UUrule“applies“to“bGoth“input“and“output“argumen¸ãt“lists.‘qÇExamples:ŽŸ´å‘Âfunction–¹–f1(x,y;z,w)“{“/*“...“*/“};ޤz‘function–¹–[a;b]“=“f2(x,y)“{“/*“...“*/“};Ž¡‘function–¹–[a;]“=“f3()“{“/*“...“*/“};Ž¡‘function–¹–[a;b]“=“f4(x;y)“{“/*“...“*/“};ŽŸؼÄF‘ÿ*ªunction–WìÉf1“Ähas“t•¸ãw“o–Wìobligatory“input“argumenš¸ãts“and“t˜w˜o“optional“ones.‘yŒIt“has“no“output“argumen˜ts.‘yŒ(It“is,ޤ ®ho•¸ãw“ev“er,‘QŸpGermissible–P±to“assign“the“\v›ÿqÇalue"“of“Éf1“Äto“a“v˜ariable“as“in“Éx=f1(0,0)Ä.‘p;The“v˜ariable“Éx“Ähas“the“v¸ãoidŽ¡v‘ÿqÇalue–ÝKafter“the“assignmenš¸ãt.‘ ¨The“v˜oid“v‘ÿqÇalue“ma˜y“bGe“created“explicitly“b˜y“using“an“expression“consisting“ofŽ¡just–UUthe“colon“\É:Ä",“and“it“doGesn't“output“anš¸ãything“when“prin˜ted.)Ž©ؼF‘ÿ*ªunction–f‘Éf2“Ähas“to“obligatory“input“argumenš¸ãts,‘jàsince“there“is“no“semicolon“in“the“input“argumen˜t“list.‘¥zOneŽ¡of–pñthe“t•¸ãw“o–pñpGossible“output“argumen¸ãts“is“obligatory“and“the“other“one“is“optional.‘ÄšF‘ÿ*ªunction“Éf3“Ähas“no“inputŽ¡argumenš¸ãts–Þbut“one“obligatory“output“argumen˜t.‘J Notice“that“the“semicolon“ma˜y“bGe“also“the“ rst“or“last“thingŽ¡in–UUthe“argumenš¸ãt“list.‘qÇFinally‘ÿ*ª,“function“Éf4“Ähas“bGoth“input“and“output“optional“and“obligatory“argumen˜ts.ަWhether–´for“not“an“optional“input“argumenš¸ãt“is“presen˜t“can“bGe“tested“e.g.‘<#b˜y“the“standard“function“Éisde nedÄ,Ž¡whicš¸ãh–é returns“1“if“the“argumen˜t“is“de ned“and“0“if“it“is“unde ned.‘M¯The“test“will“fail“also“if“the“caller“suppliedŽ¡the–™argumenš¸ãt“but“it“w˜as“bšGound“to“an“unde ned“v‘ÿqÇariable;‘×Êthis“b˜ehaš¸ãvior“is“usually“what“is“w˜an˜ted“since“passingŽ¡an–UUunde ned“v‘ÿqÇariable“as“argumenš¸ãt“is“practically“the“same“as“not“passing“an˜y“argumen˜t“at“all.ަThe–Árole“of“obligatory“and“optional“input“argumenš¸ãts,‘Üand“also“the“meaning“of“optional“output“argumen˜ts,Ž¡is–Û.clear.‘QBut“what“abGout“obligatory“output“argumen•¸ãts,‘ü¤wh“y–Û.should“an•¸ãy“one›Û.w“an“t˜to˜use˜suc“h˜things?‘QTheŽ¡answš¸ãer–Xis“simple:‘wthey“correspGond“to“argumen˜ts“that“are“Çb‘ÿ}'oth‘dÄinput“Çand‘`ŠÄoutput.‘yÌBy“making“an“outputŽ¡argumenš¸ãt–‚Tobligatory“y˜ou“force“the“caller“to“bind“it“to“some“v‘ÿqÇariable,‘“whic˜h“probably“has“some“initial“v‘ÿqÇalueŽ¡that–UUthe“function“b•Go“dy–UUma¸ãy“use.ަMa•¸ãybGe›6”w“e˜should˜pause˜for˜a˜while˜and˜recall˜the˜impGortan“t˜concepts˜in“troGduced˜in˜this˜subsection.‘ƒByŽ¡default,‘qOinput–8„argumenš¸ãts“are“obligatory“and“output“argumen˜ts“are“optional.‘SHo˜w“it“could“bGe“otherwise?Ž¡Input–šargumenš¸ãts“are“read“in“the“function“b•Go“dy‘ÿ*ª,‘ëIso–šthey“ma˜y“not“bGe“unde ned.‘@By“making“the“outputŽ¡argumenš¸ãts–ÍÞoptional“b˜y“default“w˜e“allo˜w“the“caller“the“freedom“to“ignore“some“output“argumen˜ts.‘ÛaTheŽŽŽŒ‹ t{ …(ö ýb´{Ÿ„€ÕÁGŽÉ3.‘ñÄBasics–ÕTof“the“language’IæÄ11ŽŽ K… ý¬Pësemicolon–(‚mošGdi es“the“default“b˜eha•¸ãvior.‘ëNEv“erything–(‚to“the“left“of“the“semicolon“b˜ecomes“obligatory“andޤ ®evš¸ãerything–±fto“the“righ˜t“of“the“semicolon“bGecomes“optional.‘…ùInput/output“argumen˜ts“should“bGe“declared“asŽ¡obligatory–UUoutput“argumen¸ãts.Ž©ؼThere–ü…is“still“one“thing“abšGout“function“declaration,‘Inamely“the“ÉglobalÄ/ÉloQÇcal“Ädeclaration“that“ma¸ãy“b˜e“placedŽ¡in›ÕcbGet•¸ãw“een˜the˜input˜argumen“t˜list˜and˜the˜function˜b•Go“dy‘ÿ*ª.‘ññThe˜declaration˜ma•¸ãy˜tak“e˜one˜of˜four˜pGossibleŽ¡forms:ŽŸ‹‘Âlocal‘3ùr//–¹–Everything“is“automatically“local.“The“default.ޤ Š=‘global‘/?Ü//–¹–Everything“is“automatically“global.Ž¡‘local(a,b,...)‘ s,//–¹–The“listed“symbols“are“local,“others“are“global.Ž¡‘global(a,b,...)–¹–//“The“listed“symbols“are“global,“others“are“local.ŽŸ)aÄAll–ä)\free"“sym¸ãbšGols“that“app˜ear“in“the“function“b˜o˜dy“are“either“lo˜cal“to“the“function“or“global.‘L\F‘ÿ*ªree"“sym¸ãb˜olޤ ®means–OÌa“symš¸ãbGol“whic˜h“is“not“one“of“the“input“or“output“argumen˜ts,‘Pèhas“not“bGeen“declared“autoglobal“usingŽ¡the–ñwstandard“function“ÉautoglobalÄ,‘€and“is“not“used“as“a“function“name“in“the“function“b•Go“dy‘ÿ*ª.‘F.By‘ñwdefault,Ž¡all–¯Afree“sym¸ãbšGols“are“lo˜cal.‘ŒThis“corresp˜onds“to“the“Matlab“con•¸ãv“en“tion.‘ŒBy–¯Ainserting“the“w¸ãord“Églobal“ÄwithŽ¡no–«sv‘ÿqÇariable“list,›Àúho•¸ãw“ev“er,˜y“ou–«scan“makš¸ãe“all“free“sym˜bGols“refer“to“the“globally“visible“sym˜bGols.‘t!By“insertingŽ¡ÉloQÇcal(a,b,...)‘¹wÄyš¸ãou–ådeclare“the“listed“sym˜bšGols“as“lo˜cal;‘y-other“sym¸ãb˜ols“remain“global.‘¹wThis“corresp˜onds“toŽ¡the– #practice“normally“used“in“compiled“languages“sucš¸ãh“as“C,“C++“and“P˜ascal.‘“1And“ nally‘ÿ*ª,‘8–b˜y“using“theŽ¡Églobal(a,b,...)‘VerboseMode(on)ޤ Š=‘0Ž¡‘>1–¹–+“2.3*piŽ¡‘BLOCK[SET[PLUS[1,TIMES[2.3,pi]]],NOP]Ž¡‘Source–¹–file:“"stdin"Ž¡‘no–¹–input“args,“no“output“args,“no“locals,“stack“frame“size“1.Ž¡‘Maximum–¹–number“of“operands“is“3.Ž¡‘0‘!MUL‘Ÿî$0,2.3,piŽ¡‘4‘!INC‘Ÿî$0Ž¡‘6‘!PRI‘Ÿî$0Ž¡‘8.22566ަÄAlternativ•¸ãely›ÿ*ª,‘"Ãy“ou–can“in•¸ãv“ok“e–T˜ela“with“the“{v¸ãerbšGose“or“-v“ ag.‘\µThe“FlatCo˜de“of“an¸ãy“Çsour–ÿ}'c“e‘À[Ä'd‘(É??Ä)‘\µfunctionޤ ®can–UUbGe“seen“b¸ãy“using“Çdisasm‘¸Ä(É??Ä):ަÊ>disasm(mean)Ž¡Disassembly–?ýof“'mean',“Source“file:“"std.t"Ž¡1–?ýinput“arg,“1“output“arg,“no“locals,“stack“frame“size“4.Ž¡Maximum–?ýnumber“of“operands“is“4.Ž¡0‘$¿ëCALL‘ÿôsum,1,$3,$1Ž¡5‘$¿ëCALL‘ÿôlength,1,$0,$1Ž¡10‘îDIV‘?ñ$2,$3,$0ަÄThe–UUde nition“of“Çme‘ÿ}'an‘¸ÄisަÊfunction–?ýy“=“mean(x)Ž¡//–?ýmean(x)“computes“the“arithmetic“mean“of“a“numeric“array“x.Ž¡{Ž¡‘ÿôy=sum(x)/length(x)Ž¡};ŽŽŽŒ‹¥` …(ö ýb´{Ÿ„€ÕÁGŽÉ6.‘ª¨W‘ÿ «riting–ÕTC-tela“ les’ZÁÄ14ŽŽ K… ý¬Pëand–UUyš¸ãou“can“easily“guess“what“eac˜h“of“the“FlatCoGde“instructions“do.Ž©ؼC-tela–yRcoGde“is“another“w•¸ãa“y–yRto“write“new“functions“for“T›ÿ*ªela.‘ݽMan¸ãy“T˜ela“builtin“functions“are“written“inޤ ®C-tela;‘zthose– whicš¸ãh“are“not“are“either“in“nativ˜e“t-coGde“or“are“so-called“in˜trinsic“functions“(meaning“that“theyŽ¡generate–ƒvirtual“macš¸ãhine“instructions“directly“lik˜e“macros).‘ÇPC-tela“cošGde“can“b˜e“compiled“in¸ãto“ob‘Ž8ject“ lesŽ¡using–ê¡the“program“Ételakk‘ÿ\ra“Ä(É??Ä).‘N6The“ob‘Ž8ject“ les“can“bGe“either“statically“or“dynamically“link¸ãed“with“the“restŽ¡of–UUthe“T‘ÿ*ªela“k¸ãernel.ަThere–#üexists“a“standard“function“Çt2ct‘ÔÄ(É??Ä)‘ݽto“translate“t-cošGde“in¸ãto“C-tela“co˜de.‘ݽThe“con•¸ãv“ersion–#üis“madeŽ¡pGossible–Gbš¸ãy“the“fact“eac˜h“FlatCošGde“instruction“can“b˜e“made“to“corresp˜ond“simple“C-tela“co˜dings.‘mAs“of“thisŽ¡writing,›Ujho•¸ãw“ev“er,˜the–UfT‘ÿ*ªela“compiling“scš¸ãheme“is“still“somewhat“incomplete“and“under“dev˜elopmen˜t.‘qùWhen“itŽ¡is–UUfully“functional,“yš¸ãou“can“go“all“the“w˜a˜y“from“t-coGde“do˜wn“to“ob‘Ž8ject“coGde“automatically‘ÿ*ª.ŽŸ(ÁŠâ6Ž‘ÖÿW‘þž¸riting–…C-tela“ lesŽŸ¿×ÄC-tela–^; les“are“C++“cošGde“equipp˜ed“with“T‘ÿ*ªela's“function“header“syn¸ãtax.‘ŒzThere“is“a“prepro˜cessor,–`uctpp,“thatŽ¡translates–UUC-tela“in“ordinary“C++.‘qÇCalling“ctpp“is“the“respšGonsibilit¸ãy“of“the“to˜ol“program“Ételakk‘ÿ\ra“Ä(É??Ä).ަLet–UUus“bšGegin“with“an“example“of“a“C-tela“source“ le“(let“it“b˜e“mine.ct):ŽŸ‰ffÕÁGŸ @‘Â//–¹–Our“first“C-tela“exampleŽŸz‘[]–¹–=“myfn(x)ޤ Š=‘/*–¹–myfn(x)“checks“that“x“is“a“positive“scalar“and“outputs“it.Ž¡‘',ÂError‘¹–codes:Ž¡‘',Â1:–¹–x“is“not“a“positive“scalar“*/Ž¡‘{Ž¡‘+æXif–¹–(!x.IsScalar())“return“1;Ž¡‘+æXswitch–¹–(x.kind())“{Ž¡‘>̰case‘¹–Kint:Ž¡‘Q³if–¹–(x.IntValue()“<=“0)“return“1;Ž¡‘Q³break;Ž¡‘>̰case‘¹–Kreal:Ž¡‘Q³if–¹–(x.RealValue()“<=“0)“return“1;Ž¡‘Q³break;Ž¡‘>̰case‘¹–Kcomplex:Ž¡‘Q³return‘¹–1;Ž¡‘>̰default:Ž¡‘Q³return‘¹–1;Ž¡‘+æX}Ž¡‘+æXcout–¹–<<“"myfn:“x“=“"“<<“x“<<“'\n';Ž¡‘+æXreturn‘¹–0;Ž¡‘}ŽŸ&e‰ffÕÁGŸª¨ÄY‘ÿ*ªou–UUcan“compile“it“using“Ételakk‘ÿ\ra“Ä(É??Ä):ŽŸ´å‘Âunix>–¹–telakka“-c“mine.ctŽŽŽŒ‹®= …(ö ýb´{Ÿ„€ÕÁGŽÉ6.‘ñÄW‘ÿ «riting–ÕTC-tela“ les’YyöÄ15ŽŽ K… ý¬PëThen–UUfrom“T‘ÿ*ªela“yš¸ãou“can“link“the“ob‘Ž8ject“ le“and“test“m˜yfn“as“follo˜ws.Ž©À-‘Â>link("mine.o")ޤ Š=‘>help‘¹–myfnŽ¡‘myfn(x)–¹–checks“that“x“is“a“positive“scalar“and“outputs“it.Ž¡‘>myfn(2)Ž¡‘myfn:–¹–x“=“2Ž¡‘>myfn(-2)Ž¡‘Warning–¹–from“C-function“'myfn':Ž¡‘"s,x–¹–is“not“a“positive“scalar.Ž¡‘>myfn(2+3.4i)Ž¡‘Warning–¹–from“C-function“'myfn':Ž¡‘"s,x–¹–is“not“a“positive“scalar.Ž¡‘>myfn(#(1.2,3,4))Ž¡‘Warning–¹–from“C-function“'myfn':Ž¡‘"s,x–¹–is“not“a“positive“scalar.ޤäÄThere–UUare“sevš¸ãeral“pGoin˜ts“to“bGe“noticed“with“this“simple“example:Ž¡Ê-–?ýThe“function“is“declare“using“the“[...]“=“f(...)“type“syntax.ޤ ®-–?ýThe“/*“...“*/“comment“immediately“following“the“header“is“"hot".Ž¡‘ úThe–?ýTela“help“command“finds“and“displays“the“comment,“up“to“lineŽ¡‘ ú"Error‘?ýcodes:".Ž¡-–?ýThe“function“should“return“zero“on“success,“positive“integer“onŽ¡‘ únonfatal–?ýerror“and“negative“integer“on“fatal“error.“The“error“codesŽ¡‘ úshould–?ýbe“listed“in“the“comment,“following,“one“per“line,“theŽ¡‘ ú"Error–?ýcodes:"“line.Ž¡-–?ýAll“C++“constructs“are“available,“in“addition“several“classes“andŽ¡‘ útheir–?ýassociated“members“from“Tela“headers.“The“function“argumentsŽ¡‘ ú("x"–?ýin“our“case)“are“of“type“Tobject“and“they“can“be“e.g.“outputtedŽ¡‘ úusing–?ýcout“<<“x.ŽŸäÄRules–for“argumenš¸ãt“syn˜tax“are“v˜ery“similar“to“those“found“in“T‘ÿ*ªela.‘U[Output“argumen˜ts“are“enclosed“in“squareŽ¡brac•¸ãk“ets–!ùand“input“argumenš¸ãts“in“paren˜theses.‘`¨Optional“argumen˜ts“are“separated“from“obligatory“argumen˜tsŽ¡with–'a“semicolon,‘P\parameters“to“the“righ¸ãt“of“the“semicolon“are“optional“and“parameters“on“the“left“handŽ¡side–àÌof“the“semicolon“are“obligatory‘ÿ*ª.‘,If“there“is“no“semicolon“in“the“output“argumen¸ãt“list,‘ªthen“all“outputŽ¡argumenš¸ãts–êÿare“optional.‘2ÆIf“there“is“no“semicolon“in“the“input“argumen˜t“list,‘jthen“all“input“argumen˜ts“areŽ¡obligatory‘ÿ*ª.›…In–[½addition,‘Wit“is“pGossible“to“use“the“ellipsis“(...)˜notation“to“denote“an“arbitrary“n•¸ãum“bGer‘[½ofŽ¡optional–× argumenš¸ãts.‘G®The“ellipsis“is“only“allo˜w˜ed“as“the“last“thing“in“a“parameter“(either“input“or“output)“list.Ž¡The–:ãfolloš¸ãwing“function“has“t˜w˜o“obligatory“output“argumen˜ts,‘@-one“optional“output“argumen˜t,‘@-t˜w˜o“obligatoryŽ¡input–UUargumenš¸ãts,“and“an˜y“n˜um˜bGer“of“optional“input“argumen˜ts,“the“ rst“of“whic˜h“is“named“c:ަ‘Â[x,y;–¹–z]“=“f(a,b;“c...)ŽŸäÄThe–f—function“b•Go“dy–f—can“refer“to“the“argumenš¸ãts“simply“b˜y“name,‘jèand“they“are“of“class“T‘ÿ*ªob‘Ž8ject.‘¥ŽActually“theŽ¡argumenš¸ãt–«3lists“are“implemen˜ted“using“four“C++“function“parameters:‘„the“input“argumen˜t“list“(argin),‘À«theŽŽŽŒ‹· …(ö ýb´{Ÿ„€ÕÁGŽÉ6.‘ª¨W‘ÿ «riting–ÕTC-tela“ les’ZÁÄ16ŽŽ K… ý¬Pëlength–Reof“the“input“argumenš¸ãt“list“(Nargin),‘Rüthe“output“argumen˜t“list“(argout),‘Rüand“the“length“of“the“outputޤ ®argumenš¸ãt–ü©list“(Nargout).‘gÄNargin“and“Nargout“are“of“t˜ypGe“in˜t.‘gÄargin“and“argout“are“arra˜ys“of“pGoin˜ters“toŽ¡T‘ÿ*ªob‘Ž8ject.›3nThe–šInamed“argumen¸ãts“are“just“C‘špreproGcessor“macros.˜F‘ÿ*ªor“example,‘¿²if“x“is“the“ rst“input“argumen¸ãt,Ž¡its–UUde nition“isŽ©£t‘Â#define–¹–x“(*(argin[0]))ŽŸÇJÄThe–kÂpGoinš¸ãters“con˜tained“in“the“argumen˜t“arra˜ys“are“protected“against“moGdi cation“b˜y“the“C++“k˜eyw˜ordŽ¡const.›gIn–5addition“the“input“arra¸ãy“individual“ob‘Ž8jects“are“also“const.˜The“C++“compiler“will“therefore“giv¸ãeŽ¡an–Äûerror“message“if“yš¸ãou“try“to“assign“or“otherwise“moGdify“an“input“argumen˜t.‘A©Also“Nargin“and“Nargout“carryŽ¡the–UUconst“attribute,“bGecause“c¸ãhanging“them“is“unnecessary‘ÿ*ª.ŽŸؼEllipsis–øargumenš¸ãts“ha˜v˜e“no“names“and“therefore“m˜ust“bGe“referenced“using“the“argin“and“argout“arra˜ysŽ¡explicitly›ÿ*ª.‘¦This–¼is“easy˜,‘ÕÅfor“example“to“proGcess“all“input“argumenš¸ãts“starting“from“the“second“one“(whic˜h“isŽ¡*argin1,–UUrememš¸ãbGer“that“in“C“arra˜ys“start“with“subscript“0),“y˜ou“could“use“a“coGde“lik˜e“this:ަ‘Âstatic–¹–void“Process(const“Tobject&“obj)“{“/*“...“*/“}ŽŸz‘[]–¹–=“myfunc(x...)ޤ Š=‘/*–¹–Help“message“...“*/Ž¡‘{Ž¡‘+æX/*–¹–...“*/Ž¡‘+æXfor–¹–(int“i=1;“ḭProcess(*argin[i]);Ž¡‘+æX/*–¹–...“*/Ž¡‘}ŽŸÇJÄAs–…men¸ãtioned“earlier,‘ÞC-tela“cošGde“is“C++“co˜de“equipp˜ed“with“the“T‘ÿ*ªela-likš¸ãe“function“header“syn˜tax.‘ XInŽŸ ®addition–UUto“this,“there“are“also“some“small“restrictions“on“C-tela“source“ les:ަ‘Â1.–¹–The“function“header“must“be“on“one“line,“and“the“first“characterŽ¡‘(the–¹–left“square“bracket)“must“be“on“first“column.Ž©z‘2.–¹–The“right“brace“which“ends“the“C-tela“function“body“must“be“in“theŽ¡‘first–¹–column.“No“other“right“brace“inside“the“function“body“may“be“inŽ¡‘first‘¹–column.ަ‘3.–¹–You“cannot“temporarily“remove“C-tela“functions“from“your“sourceŽ¡‘file–¹–using“preprocessor“directies,“e.g.“by“enclosing“the“lines“inŽ¡‘#if–¹–0“...“#endif.“If“you“want“to“do“this,“you“must“also“enclose“theŽ¡‘function–¹–headers“in“a“comment.ŽŸÇJÄThese–Crules“should“not“limit“yš¸ãour“programming“capabilities“in“an˜y“serious“w˜a˜y‘ÿ*ª,‘)Fand“most“of“the“time“y˜ou“doޤ ®not›UUha•¸ãv“e˜to˜ev“en˜think˜abGout˜them.ŽŸؼThen–†what“can“yš¸ãou“do“with“the“T‘ÿ*ªela“ob‘Ž8jects,‘’,that“are“of“t˜ypGe“T›ÿ*ªob‘Ž8ject“in“C++?‘ÊFirstly˜,‘’,ev¸ãery“T˜ob‘Ž8ject“hasŽ¡a–UUtag“con¸ãtaining“that“ob›Ž8ject's“kind.‘qÇThe“pGossible“kinds“are“(from“header“ le“ob˜ject.H):ŽŽŽŒ‹ÂÍ …(ö ýb´{Ÿ„€ÕÁGŽÉ6.‘ª¨W‘ÿ «riting–ÕTC-tela“ les’ZÁÄ17ŽŽ K… ý¸Û(‘Âenum–¹–Tkind“{‘K™`//“Object“kinds“(types)ޤ Š=‘+æXKint,‘YÆ"//–¹–Integer“scalarŽ¡‘+æXKreal,‘U Œ//–¹–Real“scalarŽ¡‘+æXKcomplex,‘FßÊ//–¹–Complex“scalarŽ¡‘+æXKIntArray,‘B&4//–¹–Integer“array“(n-dimensional)Ž¡‘+æXKRealArray,‘=lž//–¹–Real“arrayŽ¡‘+æXKComplexArray,‘/?Ü//–¹–Complex“arrayŽ¡‘+æXKObjectArray,‘3ùr//–¹–Object“(pointer)“array,“currently“not“usedŽ¡‘+æXKfunction,‘B&4//–¹–User-defined“function,“written“in“TelaŽ¡‘+æXKCfunction,‘=lž//–¹–Compiled“and“linked“C-Tela“functionŽ¡‘+æXKIntrinsicFunction,‘Ÿî//–¹–Special“"functions"“generating“inline“code:“abs,“min,“max“..Ž¡‘+æXKvoid,‘U Œ//–¹–Empty“value,“when“printed“prints“nothingŽ¡‘+æXKundef‘U Œ//–¹–Undefined“value,“the“default“for“new“symbolsŽ¡‘};ŽŸÍVÄLet–UUus“then“list“the“most“useful“T‘ÿ*ªob‘Ž8ject“public“mem¸ãbGers:ŽŸ(3¼‘Âclass–¹–Tobject“{Ž¡‘"s,/*–¹–...“*/Ž¡‘+æX//–¹–---“constructorsŽ¡‘+æXTobject();‘zÙìsevš¸ãeral“data“windo˜ws,‘Cgpressing“the“GIF‘>æbutton“will“include“all“data“windo˜ws“in“the“ le.‘jOPressing“Shift-GŽ¡under–Ú¢these“circumstances“will“include“only“the“currenš¸ãt“data“windo˜w.‘®The“GIF‘Ú€sa˜ving“will“w˜ork“propGerlyŽŽŽŒ‹ä¡ …(ö ýb´{Ÿ„€ÕÁGŽÉ7.‘=ŸInš®9terfacing–Ž8issues“Here“w˜e“explain“the“main“mec˜hanisms“to“comm˜unicate“with“other“programs“and“data“ les“from“T‘ÿ «ela.‘¯gHo˜w“to“extend“T‘ÿ «ela“b˜y“y˜our“o˜wn“C/C++“functions“has“bQÇeen“explained“in“the“previous“section.Ä20ŽŽ K… ý¬Pëonly–Éeif“the“whole“windoš¸ãw“is“visible“on“y˜our“w˜orkstation“screen“(or“in“the“virtual“screen,‘æii.e.‘Íøit“m˜ust“bGe“inŽŸ ®video-RAM).ŽŽŽŒøòƒ’À;è…(öÕÁGóHm#½R½p cmss10ó7ò"Vff cmbx10ó0ÂÖN  cmbx12óßê cmmi10óKñ`y cmr10óߤN cmtt9ùóóßßßßßß