Example 1
>
|
|
In this first example, M and V are assigned to a Matrix and Vector. When multiplication is attempted using the center dot, an error is returned. Here is the equivalent example using 1-D Maple Input (which shows the underlying Maple syntax):
Solution:
To fix the problem, the dot operator (period) should be used instead of the center dot (asterisk):
Here is the same solution using 1-D Maple Input:
Example 2
>
|
|
Since Maple does not know that and are Matrices when the procedure is defined, it inserts the commutative multiplication operator (asterisk) internally where the space has been used for implicit multiplication. When and are then defined as Matrices, it returns an error because this operator cannot be used for multiplication of Matrices together.
Solution:
Use the dot operator to perform explicit multiplication. Here is a similar procedure that returns the expected result:
>
|
|
Note that implicit multiplication does work for Matrices and Vectors outside a procedure or operator body. In the following examples, and are already defined as Matrices, so Maple correctly interprets the space to perform implicit multiplication of the Matrices together.
This is why it is common for people to attempt implicit multiplication inside a procedure. However, as can be seen in Example 2, those attempts fail and return an error.
Example 3
>
|
|
>
|
|
Implicit multiplication should always work if the items are already Matrices or Vectors. Outside of a procedure body, implicit multiplication will fail when multiplying together function calls that are intended to return Matrices and Vectors but which have not yet been computed. In this example, the 2-D Math parser did not know what type of objects the and function calls would return.
Solution:
Again, use the dot operator to perform explicit multiplication.
>
|
|