ones() public static method

Returns a NumArray filled with 1
Since: 1.0.0
public static ones ( ) : NumArray
return 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));
 }