NumPHP\Core\NumPHP::eye PHP 메소드

eye() 공개 정적인 메소드

Returns a matrix (NumArray) filled with 0 and 1 on the main diagonal
부터: 1.0.0
public static eye ( integer $mAxis, integer $nAxis ) : NumArray
$mAxis integer size of the m axis
$nAxis integer size of the n axis, if not given `$nAxis` = `$mAxis`
리턴 NumArray
    public static function eye($mAxis, $nAxis = -1)
    {
        $mAxis = (int) $mAxis;
        $nAxis = (int) $nAxis;
        if ($nAxis < 0) {
            $nAxis = $mAxis;
        }
        $eye = self::zeros($mAxis, $nAxis);
        $min = min($mAxis, $nAxis);
        for ($i = 0; $i < $min; $i++) {
            $eye->set($i, $i, 1);
        }
        return $eye;
    }

Usage Example

예제 #1
0
 /**
  * Tests if Helper::isSquareMatrix works with valid square matrix
  */
 public function testCheckSquareMatrixValid()
 {
     $numArray = NumPHP::eye(3);
     $this->assertTrue(Helper::isSquareMatrix($numArray));
 }
All Usage Examples Of NumPHP\Core\NumPHP::eye