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.




      DIM a(1,2), b(1,2), c(1,2)
      a() = 7, 8, 7, 4, 0, 9 : b() = 4, 5, 1, 6, 2, 1
 
      REM Matrix-Matrix:
      c() = a() + b() : PRINT FNshowmm(a(), "+", b(), c())
      c() = a() - b() : PRINT FNshowmm(a(), "-", b(), c())
      c() = a() * b() : PRINT FNshowmm(a(), "*", b(), c())
      c() = a() / b() : PRINT FNshowmm(a(), "/", b(), c())
      PROCpowmm(a(), b(), c()) : PRINT FNshowmm(a(), "^", b(), c()) '
 
      REM Matrix-Scalar:
      c() = a() + 3 : PRINT FNshowms(a(), "+", 3, c())
      c() = a() - 3 : PRINT FNshowms(a(), "-", 3, c())
      c() = a() * 3 : PRINT FNshowms(a(), "*", 3, c())
      c() = a() / 3 : PRINT FNshowms(a(), "/", 3, c())
      PROCpowms(a(), 3, c()) : PRINT FNshowms(a(), "^", 3, c())
      END
 
      DEF PROCpowmm(a(), b(), c())
      LOCAL i%, j%
      FOR i% = 0 TO DIM(a(),1)
        FOR j% = 0 TO DIM(a(),2)
          c(i%,j%) = a(i%,j%) ^ b(i%,j%)
        NEXT
      NEXT
      ENDPROC
 
      DEF PROCpowms(a(), b, c())
      LOCAL i%, j%
      FOR i% = 0 TO DIM(a(),1)
        FOR j% = 0 TO DIM(a(),2)
          c(i%,j%) = a(i%,j%) ^ b
        NEXT
      NEXT
      ENDPROC
 
      DEF FNshowmm(a(), op$, b(), c())
      = FNlist(a()) + " " + op$ + " " + FNlist(b()) + " = " + FNlist(c())
 
      DEF FNshowms(a(), op$, b, c())
      = FNlist(a()) + " " + op$ + " " + STR$(b) + " = " + FNlist(c())
 
      DEF FNlist(a())
      LOCAL i%, j%, a$
      a$ = "["
      FOR i% = 0 TO DIM(a(),1)
        a$ += "["
        FOR j% = 0 TO DIM(a(),2)
          a$ += STR$(a(i%,j%)) + ", "
        NEXT
        a$ = LEFT$(LEFT$(a$)) + "]"
      NEXT
      = a$ + "]"