#include <pvm++/pvm++.hh>

// default value for maimum size of generated matrices
static const unsigned int MaxNumOfRowsColumns = 100;

// default value for maximum size of elements of generated matrices
static const double MaxValueOfElements = 10.0;

// the different Id for the Pvm::Struct-derivations.
static const Pvm::StructId MatricesId = 1;
static const Pvm::StructId CoordsId = 2;
static const Pvm::StructId ResultId = 3;
static const Pvm::StructId CompletedId = 4;

typedef std::vector< double > DoubleVector;
typedef std::vector< DoubleVector > DoubleMatrix;

// a Pvm::Struct to transmit the matrices that should be multiplied
struct TransmitMatrices:public Pvm::Struct
{
  PvmSetStructId (MatricesId);
  PvmRegistration ()
  {
    Pvm::Register (MatrixA);
    Pvm::Register (MatrixB);
    Pvm::Register (RowsA);
    Pvm::Register (ColumnsA_RowsB);
    Pvm::Register (ColumnsB);
  }
  DoubleMatrix MatrixA;
  DoubleMatrix MatrixB;
  int RowsA;
  int ColumnsA_RowsB;		// RowsB == ColumnsA
  int ColumnsB;
};

// a Pvm::Struct to transmit the number of the row to calculate next.
struct TransmitCoords:public Pvm::Struct
{
  PvmSetStructId (CoordsId);
  PvmRegistration ()
  {
    Pvm::Register (Row);
  }
  int Row;
};

// a Pvm::Struct to transmit the result of the calculated row.
struct TransmitResult:public Pvm::Struct
{
  PvmSetStructId (ResultId);
  PvmRegistration ()
  {
    Pvm::Register (Row);
    Pvm::Register (Result);
  }
  int Row;
  DoubleVector Result;
};

// an empty Pvm::Struct to inform the multiplier, that they should end working 
static Pvm::EmptyStruct JobCompleted (CompletedId);


syntax highlighted by Code2HTML, v. 0.9.1