This task is similar to:

   Matrix multiplication
   Matrix transposition


Task

Implement basic element-wise matrix-matrix and scalar-matrix operations, which can be referred to in other, higher-order tasks.

Implement:

   addition
   subtraction
   multiplication
   division
   exponentiation


Extend the task if necessary to include additional basic operations, which should not require their own specialised task.




 
#include <hopper.h>
 
main:
  /* create an integer random array */
  A=-1,{10}rand array(A), mulby(10), ceil, mov(A)
  {","}tok sep 
  {"\ENF","ORIGINAL ARRAY :",A,"\OFF\n","="}reply(90),
  println
  {"Increment :\t"},    ++A,{A}          println
  {"Decrement :\t"},    --A,{A}          println
  {"post Increment: "}, A++,             println
             {*"\t",A}                   println
  {"post Decrement: "}, A--,             println
             {*"\t",A}                   println
  {"A + 5 :\t\t"},      {A} plus (5),    println
  {"5 + A :\t\t"},      {5} plus (A),    println
  {"A - 5 :\t\t"},      {A} minus (5),   println
  {"5 - A :\t\t"},      {5} minus (A),   println
  {"A * 5 :\t\t"},      {A} mul by (5),  println
  {"5 * A :\t\t"},      {5} mul by (A),  println
  {"A / 5 :\t\t"},      {A} div by (5),  println
  {"5 / A :\t\t"},      {5} div by (A),  println
  {"A \ 5 :\t\t"},      {A} idiv by (5), println
  {"5 \ A :\t\t"},      {5} idiv by (A), println
  {"A ^ 5 :\t\t"},      {A} pow by (5),  println
  {"5 ^ A :\t\t"},      {5} pow by (A),  println
  {"A % 5 :\t\t"},      {A} module (5),  println
  {"5 % A :\t\t"},      {5} module (A),  println
  {"SQRT(A) + 5:\t"},   {A} sqrt, plus(5), 
                        tmp=0,cpy(tmp),  println
  {"--> CEIL :\t"}      {tmp},ceil,      println
  {"--> FLOOR :\t"}     {tmp},floor,     println
  {"A + A :\t\t"},      {A} plus (A),    println
  {"A - A :\t\t"},      {A} minus (A),   println
  {"A * A :\t\t"},      {A} mulby (A),   println
  {"A / A :\t\t"},      {A} div by (A),  println
  {"A \ A :\t\t"},      {A} idiv by (A), println
  {"A ^ A :\t\t"},      {A} pow by (A),  println
  {"A % A :\t\t"},      {A} module (A),  println
  {"Etcetera...\n"},                     println
exit(0)
 