public function testBipolar2double() { // test a 1x4 $booleanData1 = [true, false, true, false]; $checkData1 = [1, -1, 1, -1]; $matrix1 = Matrix::createRowMatrix(BiPolarUtil\bipolar2double($booleanData1)); $checkMatrix1 = Matrix::createRowMatrix($checkData1); $this->assertTrue($matrix1->equals($checkMatrix1)); // test a 2x2 $booleanData2 = [[true, false], [false, true]]; $checkData2 = [[1, -1], [-1, 1]]; $matrix2 = Matrix::matrixFromDoubles(BiPolarUtil\bipolar2double($booleanData2)); $checkMatrix2 = Matrix::matrixFromDoubles($checkData2); $this->assertTrue($matrix2->equals($checkMatrix2)); }
/** * Get the data held by the index. * * @param int $index * The index to read or -1 to get the * index as an array of doubles. * @return double[] Return the data held at the specified index. */ public function getData($index = -1) { if ($index >= 0) { return BiPolarUtil\bipolar2double($this->data[$index]); } return BiPolarUtil\bipolar2double($this->data); }