<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.ice-online.com/index.php?action=history&amp;feed=atom&amp;title=FCALCULATOR</id>
	<title>FCALCULATOR - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.ice-online.com/index.php?action=history&amp;feed=atom&amp;title=FCALCULATOR"/>
	<link rel="alternate" type="text/html" href="https://wiki.ice-online.com/index.php?title=FCALCULATOR&amp;action=history"/>
	<updated>2026-04-09T17:27:39Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.34.1</generator>
	<entry>
		<id>https://wiki.ice-online.com/index.php?title=FCALCULATOR&amp;diff=830&amp;oldid=prev</id>
		<title>ConvertBot: implements a reverse polish calculator on elements of data files.</title>
		<link rel="alternate" type="text/html" href="https://wiki.ice-online.com/index.php?title=FCALCULATOR&amp;diff=830&amp;oldid=prev"/>
		<updated>2020-04-27T22:05:10Z</updated>

		<summary type="html">&lt;p&gt;implements a reverse polish calculator on elements of data files.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;implements a reverse polish calculator on elements of data files.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;LABEL&amp;gt;     - Label for the output file.&lt;br /&gt;
&amp;lt;param 1:N&amp;gt; - Parameters for the fcalc function.&lt;br /&gt;
&lt;br /&gt;
Evaluates the expression contained in the list of &amp;lt;variables/operators/files&amp;gt;&lt;br /&gt;
entries and stores the answer(s) in the output file(s). Reverse Polish Notation&lt;br /&gt;
is used (just like most HP calculators). The NeXtMidas version of calculator&lt;br /&gt;
extends the syntax to allow multiple outputs per calculation. If this syntax&lt;br /&gt;
is not used, it assumes the 1st argument is the name of the single output file&lt;br /&gt;
as in the X-Midas version. This version also allows results or expressions&lt;br /&gt;
to be recomputed as the files are processed by using the /MON switch.&lt;br /&gt;
&lt;br /&gt;
If multiple input files are given with different lengths, the computations&lt;br /&gt;
will stop after then end of the shortest file is reached. The resulting output&lt;br /&gt;
file will have the same size as the *shortest* input file.&lt;br /&gt;
&lt;br /&gt;
Though at least one input for an operator needs to be a file, there is no restriction on order.&lt;br /&gt;
(As of 3.5.1 there is no longer a requirement that the first input be a file)&lt;br /&gt;
&lt;br /&gt;
3 input operators can have 2 of their 3 inputs be constants (as of 3.5.1).&lt;br /&gt;
&lt;br /&gt;
Note1: Since NeXtMidas 2.5.0, the string infinity can be used in computations.&lt;br /&gt;
Note2: Since NeXtMidas 2.6.0, the LOG, LN, and DB operators may return NaN&lt;br /&gt;
       (Not a Number) for negative arguments, and also treat zero arguments as&lt;br /&gt;
       if they were very small positive values, in order to avoid returning&lt;br /&gt;
       -infinity for log(0.0).  The old pre 2.6.0 backwards compatible behavior&lt;br /&gt;
       (incoming arguments were bounded at 1.0e-12 and the absolute value was&lt;br /&gt;
       always taken) is available via the LOG/B, LN/B, and DB/B operators.&lt;br /&gt;
Note3: Note that at the start of each JVM session, the initial seed value is set&lt;br /&gt;
       to 12345678 and this seed is used for the uniformly distributed RANDOM&lt;br /&gt;
       number generation. This consistent non-random setting of seed allows for&lt;br /&gt;
       consistent random data generation for testing across repeated session.&lt;br /&gt;
       SETSEED must be used if a truly random seed is required for each session.&lt;br /&gt;
       Since NeXtMidas 3.1.1: The RANDOM/P are RANDOM/S operators provide&lt;br /&gt;
       alternative random number generation that always are with a random seed.&lt;br /&gt;
&lt;br /&gt;
Operators:&lt;br /&gt;
   +   : addition                        -   : subtraction&lt;br /&gt;
   *   : multiplication                  /   : division&lt;br /&gt;
   ~   : conjugate of complex            ~*  : complex conjugate multiplication&lt;br /&gt;
   ~/  : complex conjugate division&lt;br /&gt;
   **  : power&lt;br /&gt;
&lt;br /&gt;
   Comparators:&lt;br /&gt;
   -----------&lt;br /&gt;
   EQ : equal to&lt;br /&gt;
   LT : less than                      GT : greater than&lt;br /&gt;
   LE : less than or equal to          GE : greater than or equal to&lt;br /&gt;
&lt;br /&gt;
   Trigonometric and Angle Functions:&lt;br /&gt;
   ---------------------------------&lt;br /&gt;
   COS : radians                       ACOS  : principal value (radians)&lt;br /&gt;
   SIN : radians                       ASIN  : principal value (radians)&lt;br /&gt;
   TAN : radians                       ATAN  : principal value (radians)&lt;br /&gt;
                                       ATAN2 : principal value (radians)&lt;br /&gt;
   POLAR : complex rect to polar       RECT  : complex polar to rect&lt;br /&gt;
   PHASE : phase of complex&lt;br /&gt;
&lt;br /&gt;
   All functions dealing with angles are by default in radians.&lt;br /&gt;
   To express in degrees, append a D to the operator.&lt;br /&gt;
   To express in cycles, append a C to the operator.&lt;br /&gt;
   This applies to SIN,COS,TAN,ASIN,ACOS,ATAN,ATAN2,PHASE,POLAR,RECT&lt;br /&gt;
&lt;br /&gt;
   COMPLEX NUMBERS&lt;br /&gt;
   ---------------&lt;br /&gt;
   ADDC        : Alias for ~+&lt;br /&gt;
   CMPLX       : Convert a real number &amp;lt;r&amp;gt; into a complex number (&amp;lt;r&amp;gt;,0)&lt;br /&gt;
   CONJ        : Alias for ~&lt;br /&gt;
   DIVC        : Alias for ~/&lt;br /&gt;
   MULC        : Alias for ~*&lt;br /&gt;
   REAL, IMAG  : Get the REAL or IMAGINARY part of a complex number&lt;br /&gt;
   SUBC        : Alias for ~-&lt;br /&gt;
&lt;br /&gt;
   Bit Manipulations:&lt;br /&gt;
   -----------------&lt;br /&gt;
   BOR  : bitwise OR         BAND : bitwise AND&lt;br /&gt;
   BXOR : Exclusive OR       BNOT : Complement&lt;br /&gt;
&lt;br /&gt;
   Miscellaneous (in alphabetical order):&lt;br /&gt;
   -------------------------------------&lt;br /&gt;
   ADD     : Alias for +&lt;br /&gt;
   ABS     : absolute value&lt;br /&gt;
   CEIL    : Get the closest fixed point number above given real number&lt;br /&gt;
   CLIP    : CLIP value to within a MAX,MIN range, i.e. MIN (b, MAX(c,a)) where&lt;br /&gt;
               a=value, b=maximum, c=minimum&lt;br /&gt;
   DB      : Convert number to DB (precise)&lt;br /&gt;
   DB/B    : Convert number to DB (precise &amp;amp; bounded - see Note2 above)&lt;br /&gt;
   DBF     : Convert number to DB (fast, less precise)&lt;br /&gt;
   DEMUX   : demux complex into 2 scalars&lt;br /&gt;
   DIV     : Alias for /&lt;br /&gt;
   DOT     : dot product of two vectors&lt;br /&gt;
   EXP     : natural exponential&lt;br /&gt;
   FIX     : real to integer truncation&lt;br /&gt;
   FLOOR   : Get the closest fixed point number below given real number&lt;br /&gt;
   LOG     : base 10 logarithm&lt;br /&gt;
   LOG/B   : Base 10 logarithm (bounded - see Note2 above)&lt;br /&gt;
   LN      : natural logarithm&lt;br /&gt;
   LN/B    : Natural logarithm (bounded - see Note2 above)&lt;br /&gt;
   MAG     : magnitude of complex&lt;br /&gt;
   MAG2    : magnitude squared&lt;br /&gt;
   MAX     : maximum of 2 values (Alias is MAXIMUM)&lt;br /&gt;
   MIN     : minimum of 2 values (Alias is MINIMUM)&lt;br /&gt;
   MUL     : Alias for *&lt;br /&gt;
   MUX     : mux 2 scalars into complex&lt;br /&gt;
   MOD     : Same as MOD/T&lt;br /&gt;
   MOD/E   : Euclidean Modulo function (always positive)&lt;br /&gt;
   MOD/F   : Floored Modulo function (sign follows divisor)&lt;br /&gt;
   MOD/T   : Truncation Modulo function (Java % operator)&lt;br /&gt;
   POW     : Alias for **&lt;br /&gt;
   POWER2  : Gets the power of 2 number &amp;gt;= given number&lt;br /&gt;
   RANDOM  : Pseudo-random number (0, 1). See Note3 above.&lt;br /&gt;
   RANDOM/P: Pseudo-random number [0, 1) (see java.util.Random - Since 3.1.1)&lt;br /&gt;
   RANDOM/S: Cryptographically secure-random number using [0, 1)&lt;br /&gt;
             (see java.security.SecureRandom - Since 3.1.1)&lt;br /&gt;
   ROUND   : real to integer rounding&lt;br /&gt;
   SQRT    : square root&lt;br /&gt;
   SQUARE  : Square a number&lt;br /&gt;
   SUB     : Alias for -&lt;br /&gt;
   VMUX    : mux 3 scalars into vector&lt;br /&gt;
   VDEMUX  : Demux vector into 3 scalars&lt;br /&gt;
   WRAP    : Wrap data to a range (usually phase to -180 to 180)&lt;br /&gt;
   UNWRAP  : UnWrap data from a range (usually phase to -180 to 180)&lt;br /&gt;
&lt;br /&gt;
   Stack Operations:&lt;br /&gt;
   ----------------&lt;br /&gt;
   PUSH : push top of stack (duplicate)&lt;br /&gt;
   POP  : pop the top of stack (discard)&lt;br /&gt;
   &amp;lt;&amp;gt;   : swaps the top two values on the stack&lt;br /&gt;
   ?:   : compare top of stack to zero and select top-1 if &amp;gt; or top-2&lt;br /&gt;
          if not &amp;quot;D=(C&amp;gt;0)?A:B&amp;quot;&lt;br /&gt;
&lt;br /&gt;
   &amp;gt;name : pops the top of the stack to the named output file&lt;br /&gt;
   &amp;lt;name : pushes contents of named input file onto the stack&lt;br /&gt;
&lt;br /&gt;
  All entries are treated first as operators.  If the entry does not match any&lt;br /&gt;
  of the supported operators, it is tested to be a results parameter. If it can&lt;br /&gt;
  not be evaluated as a result, it is assumed to be a file name. Therefore, the&lt;br /&gt;
  operators identified above cannot be used as variable names.  The &amp;lt;name form&lt;br /&gt;
  for input files avoids trying to parse them as operators or constants.&lt;br /&gt;
&lt;br /&gt;
  NOTE: When using in-line file trimming the &amp;lt;name input file form may be&lt;br /&gt;
  necessary to avoid generating errors while trying to parse them as constants&lt;br /&gt;
  or operators.&lt;br /&gt;
&lt;br /&gt;
  The conversion of each numeric input parameter is handled by the Convert.s2o()&lt;br /&gt;
  routine. Thus, in-line calculations can be used within a parameter even though&lt;br /&gt;
  that argument is treated using reverse polish by the rest of the fcalculator&lt;br /&gt;
  command.&lt;br /&gt;
&lt;br /&gt;
  NOTE: FIX and ROUND do NOT convert the file format to fixed point. Use the&lt;br /&gt;
        /type switch to alter the output file format.&lt;br /&gt;
&lt;br /&gt;
  NOTE: Operations are defined in the Operators.cnf file. New operators may be&lt;br /&gt;
        added and defined in this file and the code is generated with the&lt;br /&gt;
        command:&lt;br /&gt;
          nM&amp;gt; GENERATE OPER ALL&lt;br /&gt;
&lt;br /&gt;
Examples:&lt;br /&gt;
 1. Standard form:&lt;br /&gt;
      fcalc/type=l outfile infile1 infile2 + infile3 *&lt;br /&gt;
&lt;br /&gt;
 2. Explicit form (for 1st difference):&lt;br /&gt;
      fcalc &amp;lt;infile1 &amp;lt;infile1(1:) - &amp;gt;outfile&lt;br /&gt;
&lt;br /&gt;
 3. Explicit form multiple output:&lt;br /&gt;
      fcalc &amp;lt;infile push 2 / &amp;gt;outfile1 10 * &amp;gt;outfile2&lt;br /&gt;
&lt;br /&gt;
 4. Code snippet to show how this command can be used in a pipe and results and&lt;br /&gt;
    expressions. In this example, the output of fcalc changes as the Multiplier&lt;br /&gt;
    control (gc.multiplier) is changed (see nxm.sys.test.test_fcalculator for&lt;br /&gt;
    a detailed implementation of this example).&lt;br /&gt;
&lt;br /&gt;
      ...&lt;br /&gt;
      pipe on&lt;br /&gt;
        panel/setup/controls=gc&lt;br /&gt;
        gcontrol lval multiplier &amp;quot;Multiplier&amp;quot; 2 1 10 1&lt;br /&gt;
        ...&lt;br /&gt;
        waveform,OUT=_wave,FORM=SF,ELEM=5e9,SHAPE=CONST,AMP=1&lt;br /&gt;
        fcalc/mon _out _wave gc.multiplier.value-1 *&lt;br /&gt;
      pipe off&lt;br /&gt;
&lt;br /&gt;
Switches:&lt;br /&gt;
  /MON        - Treat results and expressions as variables that can be changed&lt;br /&gt;
                as the file(s) are processed. Usually used in a pipe section.&lt;br /&gt;
  /TL         - The number of elements to be read each process loop [DEF=1024]&lt;br /&gt;
  /TYPE=D|F|L - Data type for calculations (defaults to F)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
SEE ALSO: CALCULATOR, nxm.sys.libm.Operators.cnf, nxm.sys.libm.ArgStack.java,&lt;br /&gt;
SEE ALSO: nxm.sys.test.test_fcalculator.mm&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:NXM_Explain]]&lt;/div&gt;</summary>
		<author><name>ConvertBot</name></author>
		
	</entry>
</feed>