public function testNoBinary()
 {
     $c = new Octave_controller();
     $nonfile = tempnam("/tmp", "octave_");
     unlink($nonfile);
     $c->octave_binary = $nonfile;
     $c->init();
     $this->assertStringStartsWith("Failed starting the Octave process", $c->lastError);
 }
예제 #2
0
 private static function registerChild($cSocket = NULL)
 {
     $controller = new Octave_controller();
     $controller->cwd = self::$home_directory;
     if (!$controller->init()) {
         Octave_logger::log("Failed starting Octave controller: " . $controller->lastError, LOG_ERR);
         return false;
     }
     $kid = new Octave_client_socket($controller);
     self::$pool[] = $kid;
     if (!$cSocket) {
         return $kid;
     }
     $kid->initSocket($cSocket);
     return $kid;
 }
예제 #3
0
<?php

require "Octave_lib.php";
$c = new Octave_controller();
$c->init();
echo "eye(3):\n";
echo $c->query("eye(3)") . "\n";
/*
eye(3):
 1 0 0
 0 1 0
 0 0 1
*/
$c->run("A=[1,2,3;4,5,6;7,8,9]; B=[9,8,7;6,5,4;3,2,1];");
echo "A=\n" . $c->query("A") . "\n";
echo "B=\n" . $c->query("B") . "\n";
echo "A*B=\n" . $c->query("A*B") . "\n";
/*
A=
 1 2 3
 4 5 6
 7 8 9
B=
 9 8 7
 6 5 4
 3 2 1
A*B=
 30 24 18
 84 69 54
 138 114 90
*/
예제 #4
0
<?php

require dirname(dirname(__FILE__)) . "/include/Octave_lib.php";
$c = new Octave_controller();
$c->init();
echo "\n";
echo "Interactive Octave controller test.\n";
echo "\n";
echo "Type 'quit' to quit.\n";
echo "Type 'run <command>' to run Octave commands without output.\n";
echo "Type 'runRead <command>' to run an Octave command with output.\n";
echo "Type 'query <command>' to run one Octave command and receive the result.\n";
echo "\n";
echo "Example session:\n";
echo "run A=eye(3)\n";
echo "run B=[1,2,3;4,5,6;7,8,9]\n";
echo "query A+2*B\n";
echo "quit\n";
echo "\n";
while (true) {
    $line = readline("> ");
    readline_add_history($line);
    $c->lastError = $payload = "";
    if (strpos($line, " ")) {
        list($command, $payload) = explode(" ", $line, 2);
    } else {
        $command = $line;
    }
    if ($command == "quit") {
        echo "Bye!\n";
        exit;