## DOTTIMES Element-wise Multiplication Operator

Section: Mathematical Operators

### Usage

Multiplies two numerical arrays (elementwise). There are two forms for its use, both with the same general syntax:

      y = a .* b

where `a` and `b` are `n`-dimensional arrays of numerical type. In the first case, the two arguments are the same size, in which case, the output `y` is the same size as the inputs, and is the element-wise product of `a` and `b`. In the second case, either `a` or `b` is a scalar, in which case `y` is the same size as the larger argument, and is the product of the scalar with each element of the other argument. The type of `y` depends on the types of `a` and `b` using type promotion rules. All of the types are preserved under multiplication except for integer types, which are promoted to `int32` prior to multiplication (same as `C`).

### Function Internals

There are three formulae for the dot-times operator, depending on the sizes of the three arguments. In the most general case, in which the two arguments are the same size, the output is computed via:

If `a` is a scalar, then the output is computed via

On the other hand, if `b` is a scalar, then the output is computed via

### Examples

Here are some examples of using the dottimes operator. First, a straight-forward usage of the `.*` operator. The first example is straightforward:

    --> 3 .* 8

    ans =

     24

    -->
    quit

Note, however, that because of the way that input is parsed, eliminating the spaces `3.*8` results in the input being parsed as `3. * 8`, which yields a `double` result:

    --> 3.*8

    ans =

     24

    -->
    quit

This is really an invokation of the `times` operator. Next, we use the floating point syntax to force one of the arguments to be a `double`, which results in the output being `double`:

    --> 3.1 .* 2

    ans =

        6.2000

    -->
    quit

Note that if one of the arguments is complex-valued, the output will be complex also.

    --> a = 3 + 4*i

    a =

        3.0000 +  4.0000i

    --> b = a .* 2.0f

    b =

        6.0000 +  8.0000i

    -->
    quit

If a `complex` value is multiplied by a `double`, the result is promoted to `dcomplex`.

    --> b = a .* 2.0

    b =

        6.0000 +  8.0000i

    -->
    quit

We can also demonstrate the three forms of the dottimes operator. First the element-wise version:

    --> a = [1,2;3,4]

    a =

     1 2
     3 4

    --> b = [2,3;6,7]

    b =

     2 3
     6 7

    --> c = a .* b

    c =

      2  6
     18 28

    -->
    quit

Then the scalar versions

    --> c = a .* 3

    c =

      3  6
      9 12

    --> c = 3 .* a

    c =

      3  6
      9 12

    -->
    quit