AppendixB:TestandDemoFunctions
865
assert(cond)
assert(cond,errmsg)
assert(cond,errmsg,...)
assert(cond,msg_id,errmsg,...)
Calledwithasingleargumentcond,assertproducesanerrorifcondis
false(numericzero).
Anyadditionalargumentsarepassedtotheerrorfunctionforprocessing.
assert(observed,expected)
Produceanerrorifobservedisnotthesameasexpected.
Note that observed d and d expected d can n be e scalars, , vectors, matrices,
strings,cellarrays,orstructures.
assert(observed,expected,tol)
Produce anerror if observedis not the same as expectedbut equality
comparisonfornumericdatausesatolerancetol.
If tolis positive thenitis anabsolute tolerance whichwillproducean
errorifabs(observed-expected)>abs(tol).
Iftolisnegativethenitisarelativetolerancewhichwillproduceanerror
ifabs(observed-expected)>abs(tol*expected).
Ifexpectediszerotolwillalwaysbeinterpretedasanabsolutetolerance.
Iftolisnotscalaritsdimensionsmustagreewiththoseofobservedand
expectedandtestsareperformedonanelement-by-elementbasis.
Seealso: [fail],page865,[test],page859,[error],page207,[isequal],page148.
[FunctionFile]
fail
(
code
)
[FunctionFile]
fail
(
code
,
pattern
)
[FunctionFile]
fail
(
code
,
"
warning
"
)
[FunctionFile]
fail
(
code
,
"
warning
"
,
pattern
)
Returntrueifcodefailswithanerrormessagematchingpattern,otherwiseproduce
anerror.
codemustbeintheformofastringthatispassedtotheOctaveinterpreterviathe
evalinfunction,i.e.,a(quoted)stringconstantorastringvariable.
Notethatifcoderunssuccessfully,ratherthanfailing,theerrorprintedis:
expected error r <.> > but got none
Ifcalledwithtwoarguments,thereturnvaluewillbetrueonlyifcode failswithan
errormessagecontainingpattern(case sensitive). . Ifthecodefails s withadifferent
errorthantheonespecifiedinpatternthenthemessageproducedis:
expected <pattern>
but got t <text of actual error>
Theanglebracketsarenotpartoftheoutput.
Whencalledwiththe"warning"optionfailwillproduceanerrorifexecutingthe
codeproducesnowarning.
Seealso: [assert],page864,[error],page207.
Pdf file specification - Split, seperate PDF into multiple files in C#.net, ASP.NET, MVC, Ajax, WinForms, WPF
Explain How to Split PDF Document in Visual C#.NET Application
pdf print error no pages selected; break pdf file into multiple files
Pdf file specification - VB.NET PDF File Split Library: Split, seperate PDF into multiple files in vb.net, ASP.NET, MVC, Ajax, WinForms, WPF
VB.NET PDF Document Splitter Control to Disassemble PDF Document
break pdf; cannot select text in pdf
866
GNUOctave
B.2 DemonstrationFunctions
[Command]
demo name
[Command]
demo namen
[FunctionFile]
demo
(
"name"
)
[FunctionFile]
demo
(
"name"
,
n
)
Runexamplecodeblocknassociatedwiththefunctionname.
Ifnisnotspecified,allexamplesarerun.
Thepreferredlocationforexamplecodeblocksisembeddedwithinthescriptm-file
immediatelyfollowingthecodethatitexercises.Alternatively,theexamplesmaybe
storedinafilewiththesamenamebutnoextensionlocatedonOctave’sloadpath.
To separate examples from regular r script t code e all l lines are prefixed by y %!. . Each
examplemustalsobeintroducedbythekeyword"demo"flushlefttotheprefixwith
nointerveningspaces. Theremainderoftheexamplecancontainarbitrary y Octave
code. Forexample:
%!demo
%! t t = 0:0.01:2*pi;
%! x x = sin (t);
%! plot t (t, x);
%! title ("one e cycle of a sine e wave");
%! #-------------------------------------------------
%! # # the e figure e window shows one cycle e of a a sine wave
Notethatthecodeisdisplayedbeforeitisexecutedsothatasimplecommentatthe
endsufficesfor labelingwhat is beingshown. . For r plots,labelingcan n alsobe done
withtitleortext. Itisgenerallynotnecessarytousedisporprintfwithinthe
demo.
Demos are run in n a a stand-alone e function n environment t with h no access s to external
variables.Thismeansthateverydemomusthaveseparateinitializationcode.Alter-
natively,alldemoscanbecombinedintoasinglelargedemowiththecode
%! input ("Press <enter> to continue: : ", "s");
betweenthesections,butthisusageisdiscouraged.Othertechniquestoavoidmultiple
initializationblocksincludeusingmultipleplotswithanewfigurecommandbetween
eachplot,orusingsubplottoputmultipleplotsinthesamewindow.
Finally, because demo o evaluates within n a functioncontext t it is not possible tode-
finenewfunctions withinthe code. . Anonymous s functions makea goodsubstitute
in most t instances. . If f functionblocks must be used thenthe code e eval(example
("function",n))willallowOctavetoseethem. Thishasitsownproblems,how-
ever,asevalonlyevaluatesonelineorstatementatatime.Inthiscasethefunction
declarationmustbewrappedwith"if1<demostuff>endif"where"if"isonthe
samelineas"demo".Forexample:
%!demo if 1
%! function n y = = f(x)
%!
y = x;
%! endfunction
%! f(3)
%! endif
TIFF Image Viewer| What is TIFF
The TIFF specification contains two parts: Baseline TIFF (the core of an easy way to convert TIFF file formats into such as Bitmap, Png, Gif, Jpeg, PDF, MS-Word
cannot select text in pdf file; split pdf into multiple files
C# Word: How to Generate Barcodes in C# Word with .NET Library
these supported 1d and 2d barcode types that can be easily inserted into MS Word file (.docx Create Micro PDF-417 in C# Word, Create Intelligent Mail in C# Word.
split pdf into individual pages; split pdf files
AppendixB:TestandDemoFunctions
867
Seealso: [rundemos],page867,[example],page867,[test],page859.
[Command]
example name
[Command]
example namen
[FunctionFile]
example
(
"name"
)
[FunctionFile]
example
(
"name"
,
n
)
[FunctionFile]
[s, idx] = = example
(...)
Displaythecodeforexamplenassociatedwiththefunctionname,butdonotrunit.
Ifnisnotspecified,allexamplesaredisplayed.
Whencalledwithoutputarguments,theexamplesarereturnedintheformofastring
s,withidx indicatingtheendingpositionofthevariousexamples.
Seedemoforacompleteexplanation.
Seealso: [demo],page866,[test],page859.
[FunctionFile]
rundemos
()
[FunctionFile]
rundemos
(
directory
)
Executebuilt-indemosforallm-filesinthespecifieddirectory.
DemoblocksinanyC++sourcefiles(*.cc)willalsobeexecutedforusewithdynam-
icallylinkedoct-filefunctions.
If no o directory is s specified, , operate e on n all l directories in Octave’s search path for
functions.
Seealso: [demo],page866,[runtests],page867,[path],page192.
[FunctionFile]
runtests
()
[FunctionFile]
runtests
(
directory
)
Executebuilt-intestsforallm-filesinthespecifieddirectory.
TestblocksinanyC++sourcefiles(*.cc)willalsobeexecutedforusewithdynami-
callylinkedoct-filefunctions.
If no o directory is s specified, , operate e on n all l directories in Octave’s search path for
functions.
Seealso: [rundemos],page867,[test],page859,[path],page192.
[FunctionFile]
speed
(
f
,
init
,
max_n
,
f2
,
tol
)
[FunctionFile]
[order, n, T_f, T_f2] = speed
(...)
Determinetheexecutiontimeofanexpression(f)forvariousinputvalues(n).
Thenarelog-spacedfrom1tomax
n. Foreachn,aninitializationexpression(init)
iscomputedtocreateanydataneededforthetest.Ifasecondexpression(f2)isgiven
thentheexecutiontimesofthetwoexpressionsarecompared.Whencalledwithout
outputargumentstheresultsareprintedtostdoutanddisplayedgraphically.
f
Thecodeexpressiontoevaluate.
max_n
Themaximumtestlengthtorun. Thedefaultvalueis100. Alternatively,
use[min_n,max_n]orspecifythenexactlywith[n1,n2,...,nk].
DocImage SDK for .NET: Web Document Image Viewer Online Demo
Microsoft PowerPoint: PPTX, PPS, PPSX; PDF: Portable Document Format; TIFF: Tagged Image File Format; XPS: XML Paper Specification. Supported Browers: IE9+;
add page break to pdf; split pdf by bookmark
VB.NET TWAIN: Overview of TWAIN Image Scanning in VB.NET
It includes the specification, data source manager and sample code. scan many pages into TIFF document file using your for scanning many pages into PDF document
break pdf file into parts; break a pdf apart
868
GNUOctave
init
Initializationexpressionforfunctionargumentvalues. Usekforthetest
numberandnfor thesizeof the test. . This s shouldcompute valuesfor
allvariablesusedbyf. Notethatinit t willbeevaluatedfirstfor k=0,
sothingswhichareconstantthroughoutthetestseriescanbecomputed
once. Thedefaultvalueisx=randn(n,1).
f2
Analternativeexpressiontoevaluate,sothatthespeedoftwoexpressions
canbedirectlycompared.Thedefaultis[].
tol
Toleranceusedtocomparetheresultsofexpressionf andexpressionf2.
Iftolispositive,thetoleranceisanabsoluteone. Iftolisnegative,the
tolerance is a relative one. . The e default is s eps. . If f tol is Inf, then no
comparisonwillbemade.
order
ThetimecomplexityoftheexpressionO(an
p
). Thisisastructurewith
fieldsaandp.
n
ThevaluesnforwhichtheexpressionwascalculatedANDtheexecution
timewasgreaterthanzero.
T_f
Thenonzeroexecutiontimesrecordedfortheexpressionf inseconds.
T_f2
Thenonzeroexecutiontimesrecordedfortheexpressionf2inseconds.If
required,themeantimeratioissimplymean(T_f./T_f2).
Theslopeoftheexecutiontimegraphshowstheapproximatepoweroftheasymptotic
runningtimeO(n
p
).Thispowerisplottedfortheregionoverwhichitisapproximated
(thelatterhalfofthegraph). Theestimatedpowerisnotveryaccurate,butshould
besufficient to determine thegeneralorder of an n algorithm. . Itshouldindicate e if,
forexample,theimplementationisunexpectedlyO(n
2
)ratherthanO(n)becauseit
extendsavector eachtimethroughtheloopratherthanpre-allocatingstorage. . In
thecurrentversionofOctave,thefollowingisnottheexpectedO(n).
speed ("for r i i = = 1:n, y{i} = = x(i); ; endfor", "", , [1000, , 10000])
Butitisifyoupreallocatethecellarrayy:
speed ("for r i i = = 1:n, y{i} = = x(i); ; endfor", ...
"x = rand d (n, , 1); ; y y = cell (size (x));", [1000, 10000])
Anattemptismadetoapproximatethecostofindividualoperations,butitiswildly
inaccurate. Youcanimprovethestabilitysomewhatbydoingmoreworkforeachn.
Forexample:
speed ("airy(x)", , "x = rand d (n, , 10)", [10000, 100000])
Whencomparingtwodifferentexpressions(f,f2),theslopeofthelineonthespeedup
ratiographshouldbelargerthan1ifthenewexpressionisfaster. Betteralgorithms
haveashallowslope.Generally,vectorizinganalgorithmwillnotchangetheslopeof
theexecutiontimegraph,butwillshiftitrelativetotheoriginal. Forexample:
speed ("sum m (x)", "", [10000, 100000], , ...
"v = 0; for i = 1:length (x), v v += x(i); ; endfor")
Thefollowingisamorecomplexexample. Iftherewasanoriginalversionofxcorr
usingforloopsandasecondversionusinganFFT,thenonecouldcomparetherun
speedfor various lags as follows, , or r for a fixed d lag withvarying vector r lengths s as
follows:
C# Imaging - C# Code 128 Generation Guide
add minimum left and right margins that go with specification. to a bitmap and save it to image file //Bitmap bmp Create Code 128 on PDF, Multi-Page TIFF, Word
pdf link to specific page; break pdf into multiple files
XImage.Barcode Generator for .NET, Technical Information Details
PDF to Tiff; C#: Convert PDF to HTML; C#: Convert PDF to Jpeg; C# File: Compress PDF; C# File: Merge PDF; C# File: Split PDF; C# Page: Insert
acrobat split pdf; break a pdf apart
AppendixB:TestandDemoFunctions
869
speed ("xcorr (x, , n)", "x = = rand d (128, , 1);", , 100,
"xcorr_orig (x, n)", , -100*eps)
speed ("xcorr (x, , 15)", "x = rand (20+n, 1);", , 100,
"xcorr_orig (x, n)", , -100*eps)
Assumingoneofthetwoversionsisinxcorr
orig,thiswouldcomparetheirspeedand
theiroutputvalues. NotethattheFFTversionisnotexact,soonemustspecifyan
acceptabletoleranceonthecomparison100*eps.Inthiscase,thecomparisonshould
becomputedrelatively,asabs((x-y)./y)ratherthanabsolutelyasabs(x-y).
Typeexample("speed")toseesomerealexamplesordemo("speed")torunthem.
XImage.Twain for .NET, Technical Information Details
PDF to Tiff; C#: Convert PDF to HTML; C#: Convert PDF to Jpeg; C# File: Compress PDF; C# File: Merge PDF; C# File: Split PDF; C# Page: Insert
break pdf documents; acrobat split pdf bookmark
XImage.OCR for .NET, Technical Information Details
PDF to Tiff; C#: Convert PDF to HTML; C#: Convert PDF to Jpeg; C# File: Compress PDF; C# File: Merge PDF; C# File: Split PDF; C# Page: Insert
pdf file specification; pdf format specification
XImage.Barcode Reader for .NET, Technical Information Details
PDF to Tiff; C#: Convert PDF to HTML; C#: Convert PDF to Jpeg; C# File: Compress PDF; C# File: Merge PDF; C# File: Split PDF; C# Page: Insert
pdf insert page break; pdf will no pages selected
VB Imaging - Micro PDF 417 VB Barcode Generation
Micro PDF-417 barcode symbol, which is compatible with established ISO/IEC barcode specification and standard VB Code to Create Micro PDF 417 on PPTX File.
pdf separate pages; can print pdf no pages selected
AppendixC:TipsandStandards
871
AppendixC TipsandStandards
ThischapterdescribesnoadditionalfeaturesofOctave.Insteaditgivesadviceonmaking
effectiveuseofthefeaturesdescribedinthepreviouschapters.
C.1 WritingCleanOctavePrograms
Herearesometips foravoidingcommonerrorsinwritingOctavecodeintendedforwide-
spreaduse:
 Sinceallglobalvariablessharethesamenamespace,andallfunctionsshareanother
namespace,youshouldchooseashortwordtodistinguishyourprogramfromother
Octaveprograms. Thentakecaretobeginthenamesofallglobalvariables,constants,
andfunctionswiththechosenprefix. Thishelpsavoidnameconflicts.
Ifyouwriteafunctionthat youthink oughttobeaddedto Octaveunder acertain
name,suchas fiddle_matrix,don’t callit by that name inyour program. . Callit
mylib_fiddle_matrixinyourprogram,andsendmailtomaintainers@octave.org
suggestingthat it beaddedtoOctave. . If f andwhenit is, the name canbechanged
easilyenough.
If one prefix is insufficient, your package may use two or three alternative common
prefixes,solongastheymakesense.
Separatetheprefixfromtherestofthesymbolnamewithanunderscore‘_’.Thiswill
beconsistentwithOctaveitselfandwithmostOctaveprograms.
 Whenyouencounteranerrorcondition,callthefunctionerror(orusage).Theerror
andusagefunctionsdonotreturn. SeeSection2.5[Errors],page35.
 Pleaseputacopyrightnoticeonthefile e ifyougivecopies toanyone. . Usethesame
linesthatappearatthetopofthefunctionfilesdistributedwithOctave. Ifyouhave
notsignedpaperstoassignthecopyrighttoanyoneelse,thenplaceyournameinthe
copyrightnotice.
C.2 TipsonWritingComments
Herearetheconventionstofollowwhenwritingcomments.
‘#’
Commentsthatstartwithasinglesharp-sign,‘#’,shouldallbealignedtothe
samecolumnontherightofthesourcecode. Suchcommentsusuallyexplain
howthecodeonthesamelinedoesitsjob.IntheEmacsmodeforOctave,the
M-; (indent-for-comment) commandautomatically inserts sucha ‘#’inthe
rightplace,oralignssuchacommentifitisalreadypresent.
‘##’
Commentsthatstartwithadoublesharp-sign,‘##’,shouldbealignedtothe
same level of indentationas the code. . Such h comments usually y describe the
purposeofthefollowinglinesorthestateoftheprogramatthatpoint.
The indentation commands s of the e Octave e mode in n Emacs, , such h as s M-; ; (indent-for-
comment) and TAB (octave-indent-line) automatically indent comments according to
these conventions, depending on the number of f semicolons. . See Section “Manipulating
Comments”inTheGNUEmacsManual.
872
GNUOctave
C.3 ConventionalHeadersforOctaveFunctions
Octavehasconventionsforusingspecialcommentsinfunctionfilestogiveinformationsuch
aswhowrotethem. Thissectionexplainstheseconventions.
Thetopofthefileshouldcontainacopyrightnotice,followedbyablockofcomments
thatcanbeusedasthehelptextforthefunction. Hereisanexample:
## Copyright t (C) ) 1996, 1997, 2007 John W. Eaton
##
## This file e is part of Octave.
##
## Octave e is free e software; you u can n redistribute e it t and/or
## modify y it under r the terms of f the e GNU General Public
## License as published d by the e Free Software Foundation;
## either r version n 3 of the e License, , or (at t your r option) any
## later version.
##
## Octave e is distributed d in the e hope e that it will be useful,
## but WITHOUT ANY WARRANTY; without even the e implied
## warranty of MERCHANTABILITY or FITNESS FOR R A A PARTICULAR
## PURPOSE. . See e the e GNU U General Public License for more
## details.
##
## You should have received a copy y of the e GNU U General Public
## License along with Octave; see the e file COPYING. . If f not,
## see <http://www.gnu.org/licenses/>.
## usage: : [IN, , OUT, PID] = = popen2 2 (COMMAND, ARGS)
##
## Start a subprocess with h two-way communication. . COMMAND
## specifies s the e name of the command to start. . ARGS S is an
## array of strings containing options for r COMMAND. . IN N and
## OUT are the file ids s of the e input and streams s for r the
## subprocess, and PID is the process s id d of the subprocess,
## or -1 if COMMAND could not be executed.
##
## Example:
##
## [in, , out, pid] = = popen2 2 ("sort", "-nr");
## fputs s (in, , "these\nare\nsome\nstrings\n");
## fclose e (in);
## while e (ischar r (s s = = fgets (out)))
##
fputs (stdout, , s);
## endwhile
## fclose e (out);
Octave uses the first blockof commentsinafunctionfile thatdo notappear tobea
copyrightnoticeasthehelptextfor the file. . ForOctavetorecognizethe e first comment
AppendixC:TipsandStandards
873
block as s acopyright t notice, , it must t start with h the word ‘Copyright’ after r stripping the
leadingcommentcharacters.
After the copyright noticeandhelptextcomeseveralheadercommentlines,eachbe-
ginningwith‘##header-name:’.Forexample,
## Author: jwe
## Keywords: : subprocesses s input-output
## Maintainer: jwe
Hereisatableoftheconventionalpossibilitiesforheader-name:
‘Author’
Thislinestatesthenameandnetaddressofatleasttheprincipalauthorofthe
library.
## Author: John W. Eaton <jwe@octave.org>
‘Maintainer’
This lineshouldcontain a a singlename/address as intheAuthor r line, or r an
addressonly,or thestring‘jwe’. . Ifthereisnomaintainer r line,theperson(s)
intheAuthorfieldarepresumedtobethemaintainers. Theexampleaboveis
mildlybogusbecausethemaintainerlineisredundant.
The idea a behind the ‘Author’ and ‘Maintainer’ lines s is s to make possible e a
functionto“sendmailtothe maintainer”withouthaving to minethe name
outbyhand.
Besuretosurroundthenetworkaddresswith‘<...>’ifyouincludetheperson’s
fullnameaswellasthenetworkaddress.
‘Created’ This s optional line e gives s the e original creation date of the file. . For r historical
interestonly.
‘Version’ IfyouwishtorecordversionnumbersfortheindividualOctaveprogram,put
theminthisline.
‘Adapted-By’
Inthis headerline,placethenameofthepersonwhoadaptedthelibraryfor
installation(tomakeitfitthestyleconventions,forexample).
‘Keywords’
This linelistskeywords. . Eventually,it t willbeusedby anaproposcommand
toallowpeoplewillfindyourpackagewhenthey’relookingforthingsbytopic
area. Toseparatethekeywords,youcanusespaces,commas,orboth.
Just about every Octave functionought tohave the ‘Author’ ’ and‘Keywords’header
comment lines. . Usetheothers s ifthey areappropriate. . Youcanalsoputinheaderlines
withotherheadernames—theyhavenostandardmeanings,sotheycan’tdoanyharm.
C.4 TipsforDocumentationStrings
As noted d above, documentation is s typically in n acommentedheader r block on n an Octave
functionfollowingthecopyrightstatement. Thehelpstringshownaboveisanunformat-
ted string andwillbe displayed as s is s by y Octave. . Here e are some tips s for r the writing of
documentationstrings.
874
GNUOctave
 Everycommand,function,orvariableintendedforuserstoknowaboutshouldhavea
documentationstring.
 AninternalvariableorsubroutineofanOctaveprogrammightas s wellhaveadocu-
mentationstring.
 Thefirstlineofthedocumentationstringshouldconsistofasummaryofthefunction.
Subsequentlinesmayexpandthegeneralnatureofthefunction.
Aftertheintroductionthereshouldbeparagraphsdescribingthemeaningandusage
ofeachinput,followedbythemeaningandusageofeachoutput.
Finally,theremaybemoregeneralinformationsuchasnotesaboutthealgorithmused,
referencestoscientificpapers,notesaboutanyincompatibilitieswithmatlab,etc.
 For r consistency, , phrase the verb b in the e first sentence e of a documentation string as
aninfinitive with“to”omitted. . For r instance,use“ReturnthefrobofAandB.”in
preferenceto“ReturnsthefrobofAandB.” Usuallyitlooksgoodtodolikewisefor
therestofthefirstparagraph.Subsequentparagraphsusuallylookbetteriftheyhave
propersubjects.
 Writedocumentationstrings s intheactivevoice,not thepassive,andin n the present
tense,notthefuture.Forinstance,use“ReturnalistcontainingAandB.”insteadof
“AlistcontainingAandBwillbereturned.”
 Avoid d using theword “cause”(or r its equivalents) unnecessarily. . Insteadof,“Cause
Octavetodisplaytextinboldface,”justwrite“Displaytextinboldface.”
 Usetwospacesbetweentheperiodmarkingtheendofasentenceandthewordwhich
opensthenext sentence. . ThisconventionhasnoeffectfortypesetformatslikeT
E
X,
butimprovesthereadabilityof the documentationinfixed-widthenvironments such
astheInforeader.
 Donotstartorendadocumentationstringwithwhitespace.
 Format t thedocumentationstringsothat it fits withinan80-column n screen. . Itis s a
goodideaformostlinestobenowiderthan60characters.
However,ratherthansimplyfillingtheentiredocumentationstring,youcanmakeit
muchmorereadablebychoosinglinebreakswithcare.Useblanklinesbetweentopics
ifthedocumentationstringislong.
 Donotindentsubsequentlinesofadocumentationstringsothatthetextislinedup
inthesource codewiththetextofthefirstline. . Thislooksniceinthesourcecode,
butlooksbizarrewhenusersviewthedocumentation.Rememberthattheindentation
beforethestartingdouble-quoteisnotpartofthestring!
 Whenchoosingvariablenamestrytoadheretothefollowingguidelines.
vectors:
x,y,z,t,w
matrices: A,B,M
strings:
str,s
filenames: fname
cells,cellstrs:
c,cstr
Documents you may be interested
Documents you may be interested