Example #1
0
 public function Apply($target)
 {
     if ($target instanceof ALiVE_Matrix) {
         return ALiVE_Matrices_Multiply($target, $this->ToMatrix());
     } else {
         if ($target instanceof ALiVE_Vector) {
             return new ALiVE_2D_Vector($this->Apply($target->ToMatrix()));
         } else {
             if (is_array($target)) {
                 foreach ($target as $vector) {
                     w_assert($vector instanceof ALiVE_Vector);
                 }
                 $result = $this->Apply(ALiVE_Vectors_ToMatrix($target));
                 $ret = array();
                 for ($i = 0; $i < $result->M(); ++$i) {
                     $thismatrix = new ALiVE_Matrix(1, 4);
                     $thismatrix->Set(0, 0, $result->Get($i, 0));
                     $thismatrix->Set(0, 1, $result->Get($i, 1));
                     $thismatrix->Set(0, 2, $result->Get($i, 2));
                     $thismatrix->Set(0, 3, $result->Get($i, 3));
                     $ret[] = new ALiVE_2D_Vector($thismatrix);
                 }
                 return $ret;
             }
         }
     }
     throw new Exception('Invalid projection application argument');
 }
Example #2
0
 public function Opposite()
 {
     $result = new ALiVE_Matrix($this->Order());
     for ($i = 0; $i < $result->M(); ++$i) {
         for ($j = 0; $j < $result->N(); ++$j) {
             $result->Set($i, $j, -$this->Get($i, $j));
         }
     }
     return $result;
 }
Example #3
0
 private function FromMatrix(ALiVE_Matrix $x)
 {
     w_assert($x->M() == 1 && $x->N() == 4);
     $this->Initialize($x->Get(0, 0), $x->Get(0, 1), $x->Get(0, 2));
 }