Exercise 1 - Arithmetic Array Operators

1 Question

Is this allowed? If no, why not? If yes, what is the result?



1.1

No, elementwise operations for the combination of an array and a scalar operand are not defined for addition.


2 Question

Is this allowed? If no, why not? If yes, what is the result?



2.1

No, elementwise operations for the combination of an array and a scalar operand are not defined for subtraction.


3 Question

Is this allowed? If no, why not? If yes, what is the result?



3.1

Oh yes! The result is {22, 28, 24}.


4 Matrix Multiplication

Write a class that multiplies two matrices using the multiplication operator for matrices.



4.1


4.1.1 Simulation of MatrixMultiplication


Take a look at a value:



5 Question

Is this allowed? If no,why not? If yes,what is the result?



5.1

The result of mult1 is 4.
The result of mult1 is {8, 8}.
The result of mult1 is {{4, 4}, {4, 4}}.
The result of mult1 is {84}.


6 Question

Is this allowed? If yes, what is the result?



6.1

Oh yes! The result is {4, 3.5, 2.5, 4.25, 3}.


7 Question

Is this allowed? If yes, what is the result?



7.1

No. Elementwise operations for dividing a scalar operand with an array is not defined for division.


8 Question

How would you write {{1, 3}, {4, 5}}^2 in Modelica? Write the expression in a class. What is the result?


8.1

The result is {{13, 18}, {24, 37}}.