Beispiel #1
0
 /**
  * Main program.
  *
  * @param array $args Command-line arguments.
  * @return integer $Zero on success; non-zero on failure.
  */
 public static function main($args)
 {
     printf("Demonstration program number 1.\n");
     $status = 0;
     DenseMatrix::main($args);
     SparseMatrixAsArray::main($args);
     SparseMatrixAsVector::main($args);
     SparseMatrixAsLinkedList::main($args);
     return $status;
 }
Beispiel #2
0
     */
    public function getTranspose()
    {
        $result = new DenseMatrix($this->getNumCols(), $this->getNumRows());
        for ($i = 0; $i < $this->getNumRows(); ++$i) {
            for ($j = 0; $j < $this->getNumCols(); ++$j) {
                $result[array($j, $i)] = $this[array($i, $j)];
            }
        }
        return $result;
    }
    /**
     * Main program.
     *
     * @param array $args Command-line arguments.
     * @return integer Zero on success; non-zero on failure.
     */
    public static function main($args)
    {
        printf("DenseMatrix main program.\n");
        $status = 0;
        $mat = new DenseMatrix(6, 6);
        AbstractMatrix::test($mat);
        AbstractMatrix::testTranspose($mat);
        AbstractMatrix::testTimes($mat, $mat);
        return $status;
    }
}
if (realpath($argv[0]) == realpath(__FILE__)) {
    exit(DenseMatrix::main(array_slice($argv, 1)));
}