/** * @param InputInterface $input * @param OutputInterface $output * * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ protected function execute(InputInterface $input, OutputInterface $output) { $matrixA = new NumArray([[49, -525, 7, -315], [-525, 6921, -3279, 3483], [7, -3279, 8178, -328], [-315, 3483, -328, 624556]]); $output->writeln('<comment>Matrix A:</comment>'); $output->writeln($matrixA->__toString()); $output->writeln('<info>Cholesky:</info>'); $time = microtime(true); $matrixL = LinAlg::cholesky($matrixA); $timeDiff = microtime(true) - $time; $output->writeln($matrixL->__toString()); $output->writeln('<info>Time for calculation: ' . $timeDiff . ' sec</info>'); }
/** * @param InputInterface $input * @param OutputInterface $output * * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ protected function execute(InputInterface $input, OutputInterface $output) { $matrix = new NumArray([[-3, 4, 7 / 6], [2, 0.1, 0], [23, -5, 8]]); $output->writeln('<comment>Matrix:</comment>'); $output->writeln($matrix->__toString()); $output->writeln('<info>Inverse:</info>'); $time = microtime(true); $inv = LinAlg::inv($matrix); $timeDiff = microtime(true) - $time; $output->writeln($inv->__toString()); $output->writeln('<info>Time for calculation: ' . $timeDiff . ' sec</info>'); }
/** * @param InputInterface $input * @param OutputInterface $output * @return int|null|void * * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ protected function execute(InputInterface $input, OutputInterface $output) { $matrixA = new NumArray([[11.0, 44.0, 1.0], [0.1, 0.4, 3.0], [0.0, 1.0, -1.0]]); $output->writeln('<comment>Matrix A:</comment>'); $output->writeln($matrixA->__toString()); $vectorB = new NumArray([1.0, 1.0, 1.0]); $output->writeln('<comment>Vector b:</comment>'); $output->writeln($vectorB->__toString()); $time = microtime(true); $gaussianResult = self::gaussianEliminationPivoting($matrixA, $vectorB); $xVector = self::backSubstitution($gaussianResult['M'], $gaussianResult['b']); $timeDiff = microtime(true) - $time; $output->writeln('<info>Solution of A*x=b?</info>'); $output->writeln('<comment>Vector x:</comment>'); $output->writeln($xVector->__toString()); $output->writeln('<info>Time for calculation: ' . $timeDiff . ' sec</info>'); }
/** * @param InputInterface $input * @param OutputInterface $output * * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ protected function execute(InputInterface $input, OutputInterface $output) { $matrixA = new NumArray([[1, 6, 1], [2, 3, 2], [4, 2, 1]]); $output->writeln('<comment>Matrix A:</comment>'); $output->writeln($matrixA->__toString()); $output->writeln('<info>LU decomposition</info>'); $time = microtime(true); list($matrixP, $matrixL, $matrixU) = LinAlg::lud($matrixA); $timeDiff = microtime(true) - $time; $output->writeln('<comment>Matrix P:</comment>'); $output->writeln($matrixP->__toString()); $output->writeln('<comment>Matrix L:</comment>'); $output->writeln($matrixL->__toString()); $output->writeln('<comment>Matrix U:</comment>'); $output->writeln($matrixU->__toString()); $output->writeln('<info>Time for calculation: ' . $timeDiff . ' sec</info>'); }