| 1 | |
| 2 | <refentry id="multiplies"> |
| 3 | <indexterm id="IndexAst"><primary>*</primary></indexterm> |
| 4 | <refentryinfo><title>Mathematical Operations:Arithmetic and Logic Operations</title></refentryinfo> |
| 5 | <refmeta> |
| 6 | <refentrytitle>*</refentrytitle> |
| 7 | </refmeta> |
| 8 | |
| 9 | |
| 10 | |
| 11 | <refnamediv> |
| 12 | <refname>*</refname> |
| 13 | |
| 14 | <refpurpose> |
| 15 | Multiplication operator. |
| 16 | </refpurpose> |
| 17 | </refnamediv> |
| 18 | |
| 19 | <refsect1> |
| 20 | <title>Description</title> |
| 21 | <para> |
| 22 | Arithmetic operators perform operations of change-sign (negate), don't-change-sign, logical AND logical OR, add, subtract, multiply and divide. Note that a value or an expression may fall between two of these operators, either of which could take it as its left or right argument, as in |
| 23 | <literallayout> |
| 24 | a + b * c. |
| 25 | </literallayout> |
| 26 | </para> |
| 27 | |
| 28 | <para> |
| 29 | In such cases three rules apply: |
| 30 | </para> |
| 31 | |
| 32 | <para> |
| 33 | 1. * and <emphasis>/</emphasis> bind to their neighbors more strongly than + and −. Thus the above expression is taken as |
| 34 | <literallayout> |
| 35 | a + (b * c) |
| 36 | </literallayout> |
| 37 | with * taking b and c and then + taking a and b * c. |
| 38 | </para> |
| 39 | |
| 40 | <para> |
| 41 | 2. <emphasis>+</emphasis> and <emphasis>−</emphasis> bind more strongly than &&, which in turn is stronger than ||: |
| 42 | <literallayout> |
| 43 | a && b - c || d |
| 44 | </literallayout> |
| 45 | is taken as |
| 46 | <literallayout> |
| 47 | (a && (b - c)) || d |
| 48 | </literallayout> |
| 49 | </para> |
| 50 | |
| 51 | <para> |
| 52 | 3. When both operators bind equally strongly, the operations are done left to right: |
| 53 | <literallayout> |
| 54 | a - b - c |
| 55 | </literallayout> |
| 56 | is taken as |
| 57 | <literallayout> |
| 58 | (a - b) - c |
| 59 | </literallayout> |
| 60 | </para> |
| 61 | |
| 62 | <para> |
| 63 | Parentheses may be used as above to force particular groupings. |
| 64 | </para> |
| 65 | </refsect1> |
| 66 | |
| 67 | <refsect1> |
| 68 | <title>Syntax</title> |
| 69 | <synopsis>a <command>*</command> b (no rate restriction)</synopsis> |
| 70 | |
| 71 | <para> |
| 72 | where the arguments <emphasis>a</emphasis> and <emphasis>b</emphasis> may be further expressions. |
| 73 | </para> |
| 74 | </refsect1> |
| 75 | |
| 76 | <refsect1> |
| 77 | <title>Arguments</title> |
| 78 | <para> |
| 79 | The arguments of * can be scalar values or k-rate one |
| 80 | dimensional arrays (vectors), or any combination. If one of the |
| 81 | arguments is an array, so is the value. |
| 82 | </para> |
| 83 | </refsect1> |
| 84 | |
| 85 | <refsect1> |
| 86 | <title>Examples</title> |
| 87 | <para> |
| 88 | Here is an example of the * operator. It uses the file <ulink url="examples/multiplies.csd"><citetitle>multiplies.csd</citetitle></ulink>. |
| 89 | |
| 90 | <example> |
| 91 | <title>Example of the * operator.</title> |
| 92 | |
| 93 | |
| 94 | |
| 95 | <para>See the sections <link linkend="UsingRealTime"><citetitle>Real-time Audio</citetitle></link> and <link linkend="CommandFlags"><citetitle>Command Line Flags</citetitle></link> for more information on using command line flags.</para> |
| 96 | <xi:include href="examples-xml/multiplies.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 97 | </example> |
| 98 | |
| 99 | Its output should include a line like this: |
| 100 | <screen> |
| 101 | |
| 102 | base amplitude * rising expon output = 0.8 * 0.010000 |
| 103 | base amplitude * rising expon output = 0.8 * 0.012589 |
| 104 | .......... |
| 105 | base amplitude * rising expon output = 0.8 * 0.794328 |
| 106 | base amplitude * rising expon output = 0.8 * 0.998466</screen> |
| 107 | </para> |
| 108 | </refsect1> |
| 109 | |
| 110 | <refsect1> |
| 111 | <title>See also</title> |
| 112 | <para><link linkend="MathArtLogic"><citetitle>Arithmetic and Logic Operations</citetitle></link></para> |
| 113 | </refsect1> |
| 114 | |
| 115 | <refsect1> |
| 116 | <title>Credits</title> |
| 117 | <para>Arithmetic on vectors is new in version 6.00</para> |
| 118 | </refsect1> |
| 119 | |
| 120 | </refentry> |