ones() 공개 정적인 메소드

Returns a NumArray filled with 1
부터: 1.0.0
public static ones ( ) : NumArray
리턴 NumArray
예제 #1
0
파일: Abs.php 프로젝트: raslin/NumPHP
 /**
  * @return array
  */
 public function run()
 {
     $result = [];
     for ($i = 100; $i <= 1000; $i += 100) {
         $numArray = NumPHP::ones($i, $i);
         $time = microtime(true);
         $numArray->abs();
         $timeDiff = microtime(true) - $time;
         $result[$i] = new TestRun($i, $timeDiff);
     }
     return $result;
 }
예제 #2
0
 /**
  * Tests NumArray::getSize on scalar
  */
 public function testGetSize()
 {
     $numArray = NumPHP::ones();
     $this->assertSame(1, $numArray->getSize());
 }
예제 #3
0
 /**
  * Tests if InvalidArgumentException will be thrown, when using LinAlg::solve with not align matrix and vector
  *
  * @expectedException        \NumPHP\LinAlg\Exception\InvalidArgumentException
  * @expectedExceptionMessage Can not solve a linear system with matrix (4, 4) and matrix (3)
  */
 public function testSolveNotAlign()
 {
     $matrix = NumPHP::identity(4);
     $vector = NumPHP::ones(3);
     LinAlg::solve($matrix, $vector);
 }
예제 #4
0
 /**
  * Tests if Helper::isSquareMatrix works with invalid square matrix
  */
 public function testCheckSquareMatrixInvalid()
 {
     $numArray = NumPHP::ones(2, 3);
     $this->assertFalse(Helper::isSquareMatrix($numArray));
 }
예제 #5
0
파일: EyeTest.php 프로젝트: raslin/NumPHP
 /**
  * Tests NumPHP::eye with argument 1
  */
 public function testEye1()
 {
     $numArray = NumPHP::eye(1);
     $expectedNumArray = NumPHP::ones(1, 1);
     $this->assertNumArrayEquals($expectedNumArray, $numArray);
 }
예제 #6
0
 /**
  * Tests if InvalidArgumentException will be thrown, when using NumArray::reshape
  * with wrong size
  *
  * @expectedException        \NumPHP\Core\Exception\InvalidArgumentException
  * @expectedExceptionMessage Total size of new array must be unchanged
  */
 public function testReshapeInvalidArgumentException()
 {
     $numArray = NumPHP::ones(2, 3);
     $numArray->reshape(2, 2);
 }
예제 #7
0
 /**
  * Tests NumPHP::onesLike with 3x2 matrix
  */
 public function testOnesLike()
 {
     $numArray = new NumArray([[1, 1], [1, 1], [1, 1]]);
     $expectedNumArray = NumPHP::ones(3, 2);
     $this->assertNumArrayEquals($expectedNumArray, NumPHP::onesLike($numArray));
 }