~ubuntu-branches/ubuntu/saucy/gfan/saucy-proposed

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
 * app_matrixproduct.cpp
 *
 *  Created on: Jan 4, 2011
 *      Author: anders
 */

#include "parser.h"
#include "printer.h"
#include "gfanapplication.h"
#include "matrix.h"

class MatrixProductApplication : public GFanApplication
{
public:
  SimpleOption optionTropical;
  bool includeInDefaultInstallation()
  {
    return false;
  }
  const char *helpText()
  {
    return "This program computes the product of two matrices.\n";
  }
  MatrixProductApplication():
    optionTropical("--tropical","Do the computation in the max-plus semi-ring.")
  {
    registerOptions();
  }

  const char *name()
  {
    return "_matrixproduct";
  }

  int main()
  {
    FileParser P(Stdin);

    IntegerMatrix A=rowsToIntegerMatrix(P.parseIntegerVectorList());
    IntegerMatrix B=rowsToIntegerMatrix(P.parseIntegerVectorList());

    pout<<((optionTropical.getValue())?tropicalProduct(A,B):A*B).getRows();

    return 0;
  }
};

static MatrixProductApplication theApplication;