~ubuntu-branches/ubuntu/raring/mdds/raring

« back to all changes in this revision

Viewing changes to src/mixed_type_matrix_test.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Rene Engelhard
  • Date: 2011-07-15 21:08:45 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20110715210845-z7bw2k640m9kqtua
Tags: 0.5.3-1
new upstream release 

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
 *
26
26
 ************************************************************************/
27
27
 
 
28
#include "test_global.hpp"
28
29
#include "mdds/mixed_type_matrix.hpp"
29
 
#include "test_global.hpp"
30
30
 
31
31
#include <sstream>
32
32
#include <cassert>
263
263
    assert(mxsize.first == 6);
264
264
    assert(mxsize.second == 4);
265
265
    mx.resize(6, 6);
 
266
    mx.set_boolean(5, 5, true);
266
267
    mx.dump();
267
268
    mxsize = mx.size();
268
269
    assert(mxsize.first == 6);
269
270
    assert(mxsize.second == 6);
270
271
    mx.resize(3, 6);
 
272
    mx.set_numeric(2, 2, 4.2);
 
273
    mx.set_numeric(2, 3, 3.2);
 
274
    mx.set_numeric(2, 4, 2.2);
 
275
    mx.set_numeric(2, 5, 1.2);
271
276
    mx.dump();
272
277
    mxsize = mx.size();
273
278
    assert(mxsize.first == 3);
690
695
    assert(i == 0);
691
696
}
692
697
 
 
698
template<typename _FilledStoreType>
693
699
void mtm_test_iterator_access_filled(size_t rows, size_t cols)
694
700
{
695
701
    StackPrinter __stack_printer__("::mtm_test_iterator_access_filled");
696
 
    typedef storage_filled<mx_type> store_type;
 
702
    typedef _FilledStoreType store_type;
697
703
 
698
704
    store_type store(rows, cols, matrix_init_element_zero);
699
705
    {
700
706
        cout << "rows: " << rows << "  cols: " << cols << endl;
701
 
        store_type::const_itr_access* itr_access = store.get_const_itr_access();
 
707
        typename store_type::const_itr_access* itr_access = store.get_const_itr_access();
702
708
        traverse_itr_access<store_type>(*itr_access);
703
709
        delete itr_access;
704
710
    }
839
845
    assert(itr == itr_end); // not found.
840
846
}
841
847
 
 
848
/**
 
849
 * Measure the performance of object instantiation for filled storage.
 
850
 */
 
851
void mtm_perf_test_filled_storage_creation()
 
852
{
 
853
    StackPrinter __stack_printer__("::mtm_perf_test_filled_storage_creation");
 
854
    cout << "measuring performance on matrix object creation." << endl;
 
855
    size_t rowsize = 1000;
 
856
    size_t obj_count = 30000;
 
857
    cout << "row size: " << rowsize << "  object count: " << obj_count << endl;
 
858
    for (size_t colsize = 1; colsize <= 3; ++colsize)
 
859
    {
 
860
        StackPrinter __stack_printer2__("::mtm_perf_test_filled_storage_creation::group");
 
861
        cout << "column size: " << colsize << endl;
 
862
        for (size_t i = 0; i < obj_count; ++i)
 
863
            mx_type mx(rowsize, colsize, matrix_density_filled_zero);
 
864
    }
 
865
}
 
866
 
 
867
void mtm_perf_test_filled_storage_set_numeric()
 
868
{
 
869
    StackPrinter __stack_printer__("::mtm_perf_test_filled_storage_set_numeric");
 
870
    cout << "measuring performance on matrix object creation and populating it with numeric data." << endl;
 
871
    size_t rowsize = 1000;
 
872
    size_t obj_count = 30000;
 
873
    cout << "row size: " << rowsize << "  object count: " << obj_count << endl;
 
874
    for (size_t colsize = 1; colsize <= 3; ++colsize)
 
875
    {
 
876
        StackPrinter __stack_printer2__("::mtm_perf_test_filled_storage_set_numeric::group");
 
877
        cout << "column size: " << colsize << endl;
 
878
        for (size_t i = 0; i < obj_count; ++i)
 
879
        {
 
880
            mx_type mx(rowsize, colsize, matrix_density_filled_zero);
 
881
            for (size_t row = 0; row < rowsize; ++row)
 
882
            {
 
883
                for (size_t col = 0; col < colsize; ++col)
 
884
                    mx.set_numeric(row, col, 1.0);
 
885
            }
 
886
        }
 
887
    }
 
888
}
 
889
 
842
890
int main(int argc, char** argv)
843
891
{
844
892
    cmd_options opt;
861
909
    
862
910
        run_tests_on_all_density_types(mtm_test_flag_storage);
863
911
    
864
 
        mtm_test_iterator_access_filled(1, 1);
865
 
        mtm_test_iterator_access_filled(3, 1);
866
 
        mtm_test_iterator_access_filled(1, 3);
867
 
        mtm_test_iterator_access_filled(3, 3);
868
 
        mtm_test_iterator_access_filled(0, 0);
 
912
        mtm_test_iterator_access_filled<storage_filled_nested_array<mx_type> >(1, 1);
 
913
        mtm_test_iterator_access_filled<storage_filled_nested_array<mx_type> >(3, 1);
 
914
        mtm_test_iterator_access_filled<storage_filled_nested_array<mx_type> >(1, 3);
 
915
        mtm_test_iterator_access_filled<storage_filled_nested_array<mx_type> >(3, 3);
 
916
        mtm_test_iterator_access_filled<storage_filled_nested_array<mx_type> >(0, 0);
 
917
 
 
918
        mtm_test_iterator_access_filled<storage_filled_linear<mx_type> >(1, 1);
 
919
        mtm_test_iterator_access_filled<storage_filled_linear<mx_type> >(3, 1);
 
920
        mtm_test_iterator_access_filled<storage_filled_linear<mx_type> >(1, 3);
 
921
        mtm_test_iterator_access_filled<storage_filled_linear<mx_type> >(3, 3);
 
922
        mtm_test_iterator_access_filled<storage_filled_linear<mx_type> >(0, 0);
 
923
 
 
924
        mtm_test_iterator_access_filled<storage_filled_linear_zero<mx_type> >(1, 1);
 
925
        mtm_test_iterator_access_filled<storage_filled_linear_zero<mx_type> >(3, 1);
 
926
        mtm_test_iterator_access_filled<storage_filled_linear_zero<mx_type> >(1, 3);
 
927
        mtm_test_iterator_access_filled<storage_filled_linear_zero<mx_type> >(3, 3);
 
928
        mtm_test_iterator_access_filled<storage_filled_linear_zero<mx_type> >(0, 0);
869
929
    
870
930
        mtm_test_iterator_access_sparse();
871
931
    
872
932
        mtm_test_const_iterator();
873
933
    }
 
934
 
 
935
    if (opt.test_perf)
 
936
    {
 
937
        mtm_perf_test_filled_storage_creation();
 
938
        mtm_perf_test_filled_storage_set_numeric();
 
939
    }
 
940
 
874
941
    cout << "Test finished successfully!" << endl;
875
942
    return EXIT_SUCCESS;
876
943
}