/*
 *  mmatrix.cpp  - the client code for multidimension matrix
 *  (C) Porkolab Zoltan, ELTE, Budapest, Hungary
 *  (C) 2003
 */

#include <iostream>
#include <string>
#include <algorithm>

#include "mmatrix.h"

int main()
{
    int yourMark(1);
    
//* 2-es
    mmatrix<int>::index i1;     // represents the index as N element array
    i1.put(3).put(4).put(5);    // three dimensions
    mmatrix<int>    m1(i1);     // creates matrix of 3x4x5 of integers 0

    mmatrix<double>::index i2;
    i2.put(2).put(2);           // two dimensions
    mmatrix<double> m2(i2);     // creates matrix of 2x2 of doubles 0.0

    mmatrix<std::string>::index i3;
    i3.put(2).put(2).put(5).put(5); // four dimensions
    mmatrix<std::string> m3(i3);    // creates matrix of 2x2x5x5 of strings ""

    if ( sizeof(i3) < 40 && sizeof(m3) < 40 ) // avoid stupid implementations
        yourMark = m2.dim();    // dimension of m2 (==2)

//*/

//* 3-as
    i1.reset();     
    i1.put(2).put(3).put(4);     
    m1.at(i1) = 5;              // m1(2,3,4) = 5
   
    i3.reset();
    i3.put(0).put(1).put(2).put(3);
    m3.at(i3) = "Hello";        // m3(0,1,2,3) = "Hello"
 
    mmatrix<int>::index i4;
    i4.put(0).put(0).put(0);
    m1.at(i4) = 4;              // m1(0,0,0) = 4

    yourMark += m1.at(i1) - m1.at(i4);
//*/

//* 4-es
    const mmatrix<int> cm = m1;
    --m1[i4];

    yourMark += cm[i4] - m1[i4]; 
//*/
 
//* 5-os 
    --m1[i1];       // m1(2,3,4) = 4
    mmatrix<int>::iterator i = find( m1.begin(), m1.end(), 4);
    if ( m1.end() != i )    // hopefully i refer to m1(2,3,4)
        ++ *i;
    yourMark = m1[i1];
//*/

    std::cout << "Your mark is " << yourMark << std::endl;
    return 0;
}