code: public function diagonal($m = null, $n = null, $c = 1)
      {
          $R = new self($m, $n);
          for ($i = 0; $i < $m; ++$i) {
              $R->set($i, $i, $c);
          }
  
          return $R;
      }
docs: diagonal.
  
  Generate a diagonal matrix
  
  @param int $m Row dimension
  @param int $n Column dimension
  @param mixed $c Diagonal value
  
  @return Matrix Diagonal matrix