Algorithms Cheat Sheet
-
Upload
rgt89hw-g0h8- -
Category
Documents
-
view
218 -
download
0
Transcript of Algorithms Cheat Sheet
-
8/14/2019 Algorithms Cheat Sheet
1/9
Identifiers and Declaring VariableIn Jython, you dont need to declare the variable type.
Java Visual Basic Jythonint x=0; ' Using explicit typing.
Di x !s Integer = 0' Using local type in"erence. Di x = 0
x=0
stringx=hello;
' Using explicit typing. Di x !s #tring = $hello$' Using local type in"erence. Di x = $hello$
x=hello
In Jython, you can easily change a variable type %ithout any conse&uences. or exa ple(x=hellox=)y=*.+x=x-y
In this exa ple x %ent "or a string to an integer to a "loat.
ExpressionsNumeric Operators
Operator Description+ Addition- Subtraction* Multiplication/ Division// Truncating Division% Modulo (Remainder of Division** !o"er #perator +var $nar !lus-var $nar Minus
Mathematical Built-in FunctionsFunction Descriptionabs(var Absolute valuepo"(&' an be used in place of ** operator po"(&' 'modulo Ternar po"er-modulo (& ** % moduloround(var)' n Returns a value rounded to t e nearest , -n or (, **-n ' " ere n defaults to divmod(&' Returns a tuple of t e .uotient and t e remainder of division
Comparison OperatorsOperator Description
0reater t an1 2ess t an
3 0reater t an or e.ual13 2ess t an or e.ual!3 4ot e.ual33 5.ual
Bitwise OperatorsOperator Description6 7it"ise and operator copies a bit to t e result if a bit appears in bot operands88 7it"ise or operator copies a bit to t e result if it e&ists in eit er of t e operands9 7it"ise &or operator copies a bit to t e result if it e&ists in onl one operand: 7it"ise negation operator flips t e bits' and returns t e e&act opposite of eac bit
http://www.jython.org/jythonbook/en/1.0/OpsExpressPF.html#id1http://www.jython.org/jythonbook/en/1.0/OpsExpressPF.html#id3http://www.jython.org/jythonbook/en/1.0/OpsExpressPF.html#id3http://www.jython.org/jythonbook/en/1.0/OpsExpressPF.html#id1 -
8/14/2019 Algorithms Cheat Sheet
2/9
hift OperatorsOperator Descriptionx
-
8/14/2019 Algorithms Cheat Sheet
3/9
list(se.uence onverts a given se.uence into a listlong(value )' base onverts to a long using a base if a string is givenoct(value onverts an integer to a string representing t at number as an octalord(value onverts a c aracter into its integer valuerepr(value onverts obBect into an e&pression string? Same as enclosing e&pression in
reverse .uotes ( x + y ? Returns a string containing a printable andevaluable representation of t e obBect
set(se.uence onverts a se.uence into a setstr(value onverts an obBect into a string Returns a string containing a printable
representation of t e value' but not an evaluable stringtuple(se.uence onverts a given se.uence to a tupleunic r(value onverts integer to a $nicode c aracter
Modif#ing a %ist'ethod (as)s er"or#edappend*value+ Add a value to t e end of a listextend*list+ Add anot er list to t e end of a listinsert*index, value+ Sorts t e items contained "it in t e list and returns t e list
%ist Methods'ethod (as)s er"or#edindex Returns t e inde& of t e first value in t e list " ic matc es a given value?
count Returns t e number of items in t e list " ic e.ual a given value?sort Sorts t e items contained "it in t e list and returns t e listreverse Reverses t e order of t e items contained "it in t e list' and returns t e list
tatements if
o /valuates an expression and executes one or ore state ents %hen the expression is truei" x y(
1=y elif and else
o 2hese are optional and execute state ents only %hen previous expressions in the i" bloc3 are"alse. !n i" bloc3 can include ultiple eli" state ents./xa ple +(
i" x y(1=y
else(1=x
/xa ple (i" x y(
1=yeli" x4y
1=xelse(
1=0 &hile %oop
o 5epeatedly executes one or ore state ents in a loop as long as an expression re ains true.x=0%hile x +000(
x6=+ for %oop
o 5epeatedly executes one or ore state ents in a loop as long as the index does not e&ual therange. 2he initial index de"aults to + and is incre ented by + on each iteration.
-
8/14/2019 Algorithms Cheat Sheet
4/9
"=+"or index in range7+08(
"="-index
continueo 2e porarily interrupts the execution o" a progra loop, s3ipping any re aining state ents in the
body o" the loop "or the current pass. 2he continue state ent does not cause an i ediate exit"ro the loop as a brea3 or return state ent %ould do, but instead continues %ithin the loop "oras long as the stated "or or %hile condition holds true.
even9ist=:nu 9ist=:,*,* ),),* ,>,*),>, ,* ,>?"or value in nu list(
i" value @ A= 0continue
even9ist.append7value8 brea'
o 2er inates the execution o" a "or or %hile loop. #tate ents in the loop that appear a"ter the brea3state ent are not executed.
even9ist=:x=+0%hile 2rue(
i" x==0(brea3
i" B+--x==+(even9ist.append7x8
xB=+
(#thon Modulesomplete list can be found at ttp //"""?B t on?org/docs/librar /inde&progress? tml
Cu eric and athe atical odules ath E athe atical "unctions c ath E athe atical "unctions "or co plex nu bers deci al E Deci al "ixed point and "loating point arith etic rando E Fenerate pseudoBrando nu bers itertools E unctions creating iterators "or e""icient looping "unctools E Gigher order "unctions and operations on callable obHects operator E #tandard operators as "unctions
e"ore using any "unction %ithin these odules, use the i port state ent
/xa ple
i port ath
x= ath.su 7:+, ,*, , ,),>,
-
8/14/2019 Algorithms Cheat Sheet
5/9
DomainsDomain States UOM Description
BeamPosition: Az
All Scans Degrees Contributes to the scan azimuth offset. This is cumulative suchthat multiple modulations will sum to a final solution.
BeamPosition: El
All Scans Degrees Contributes to the scan elevation offset. This is cumulative suchthat multiple modulations will sum to a final solution.
ConicalRotationRate
Conical Scan Hz The rate, measured in Hz, of the Conical Scan element.
ConicalScan StartAngle
Conical Scan Degrees The starting point, measured in degrees, of a Conical Scan, with0 degrees being the top of the scan, and rotating cloc wise.
ConicalSquint
Conical Scan Degrees The S!uint Angle of the Conical Scan, measured in degrees.
Slew Rate Continuous
Scan
Degrees"s The angular speed of the beam during a scan segment, measure
in degrees per secondScan Extent Continuous
ScanDegrees The total angular distance of a scan segment, measured in
degrees.
Power #ower $ilowatts The pea power measured at the antenna feedport, measured inilowatts.
PR #%& #icoseconds The duration of the #%& in picoseconds
ERP '%# d() The effective radiated power *'&+ onl -
Axial Ratio #olarization d( The ratio between the +a or and +inor a/is, measured indecibels.
Ma!or Axis"ilt
#olarization Degrees The angle between the +a or a/is of the polarization and thehorizontal a/is of the coordinate s stem, measured in degrees.
Polarization RotationRate
#olarization Hz The number of times per second that the polarizationmechanicall rotates through the same +a or a/is tilt.
PulseDuration
#ulse #icoseconds The duration of the #ulse, measured in picoseconds.
R#: OnPulse
#ulse +egahertz Contributes to offset the scoped fre!uenc . This is cumulativesuch that multiple modulations will sum to a final solution.
P$ase: OnPulse
#ulse Degrees Contributes to the phase offset on pulse. This is cumulative suchthat multiple modulations will sum to a final solution.
R#: Carrier % +egahertz The carrier fre!uenc , measured in megahertz.R#: O%%set Dela , Time
&nterval+egahertz Contributes to offset the scoped fre!uenc . This is cumulative
such that multiple modulations will sum to a final solution.
P$ase:O%%set
Dela , Time&nterval
Degrees Contributes offset to the scoped phase. This is cumulative suchthat multiple modulations will sum to a final solution.
time&uration
TemporalStates
#icoseconds Sets the duration of the temporal state.
position Switch String A 1pseudo domain1 for setting switch position b position in analgorithm e/pression.
-
8/14/2019 Algorithms Cheat Sheet
6/9
la'el Switch String A 1pseudo domain1 for setting switch position b label in analgorithm e/pression.
#stem VariablesVariable
NameDescription
timeIn cope 2he scoped li"eti e o" this state. 2he value starts at 0 on entranceto this state and incre ents %ith each execution step until thestate 7or its parenting container8 exits. 2i e is easured inpicoseconds.
container*ime
2he scoped li"eti e o" this state's parenting container. 2he valuestarts at 0 on entrance into the container and incre ents %itheach execution ti e step until the container co pletes and exits.
2i e is an integer easured in picoseconds.
random eed 2he rando i1er seed this si ulation is using. I" the algorith usesa rando i1er routine it should seed the rando i1er %ith this value"irst. rando #eed ay be Cone.
global*ime 2he global ti e o" the si ulation. 2i e is an integer easured inpicoseconds.
+elper FunctionGelper ethods available to #tates(
getK5I getKrevK5I
setK5I iringLrder
get5
getKrev5
set5 iringLrder
getKulseDuration
getKrevKulseDuration
setKulseDuration iringLrder
set5 LnKulse iringLrder
setKhaseLnKulse iringLrder
getKreviousMave"or
get#canKosition
-
8/14/2019 Algorithms Cheat Sheet
7/9
get /K#ID
Gelper ethods available to #%itches(
set iringLrder yKosition
set iringLrder y9abel
Debugginglogger.in"o7NvariableO6str7variablePalue88
Configuration File?xml version="1.0" encoding="UTF-8"?>
-
8/14/2019 Algorithms Cheat Sheet
8/9
-
8/14/2019 Algorithms Cheat Sheet
9/9