File: app_matrixproduct.cpp

package info (click to toggle)
gfan 0.5%2Bdfsg-6
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 8,348 kB
  • ctags: 5,683
  • sloc: cpp: 39,675; makefile: 454; sh: 1
file content (49 lines) | stat: -rw-r--r-- 970 bytes parent folder | download | duplicates (2)
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;