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

// pragma ..
#include <iostream>
#include <string>
#include <algorithm>

#include "rmatrix.h"

int main()
{
    int yourMark(1);
    
//* 2-es
    rmatrix<int>         m1(3,4,5);  // creates matrix of 3x4x5 of integers 0
    rmatrix<double>      m2(2,2,2);  // creates matrix of 2x2x2 of doubles 0.0
    rmatrix<std::string> m3(5,4,3);  // creates matrix of 5x4x3 of strings ""

    m1.at(2,3,4) = 5;       // m1(2,3,4) = 5
    m3.at(0,1,2) = "Hello"; // m3(0,1,2) = "Hello"
    m1.at(0,0,0) = 4;       // m1(0,0,0) = 4

    if ( sizeof(m3) < 40  &&  // avoid stupid implementations
                 m2.size() == 2*2*2 && m3.size() == 5*4*3 ) // logical size
        yourMark += m1.at(2,3,4) - m1.at(0,0,0);
//*/

//* 3-as 
    const rmatrix<int> cm = m1;
    --m1(0,0,0);
    yourMark += cm(0,0,0) - m1(0,0,0); 
//*/
 
//* 4-es
    if ( 0  == cm(1,2,3)  &&  ! cm.stored(1,2,3) )
        ++yourMark; // stores only explicitly assigned elements
    m1(1,2,3) = 0;  // stores 0 at m1(1,2,3)
    if ( 0 != m1(1,2,3)  ||  ! m1.stored(1,2,3) )
        --yourMark;     
//*/
            
//* 5-os
    int elements_in_cm = 0;
    int elements_in_m1 = 0; 
    for ( rmatrix<int>::const_iterator ci1 = cm.begin(); ci1 != cm.end(); ++ci1)
        ++elements_in_cm;
    for ( rmatrix<int>::const_iterator ci2 = m1.begin(); ci2 != m1.end(); ++ci2)
        ++elements_in_m1;
    yourMark += (elements_in_cm + 1 == elements_in_m1);
//*/

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