Commit a832eab1 authored by Alexandre Duret-Lutz's avatar Alexandre Duret-Lutz

Implement a new compression inspired from simple-9.

* src/misc/intvcmp2.cc, src/misc/intvcmp2.hh: New files.
* src/misc/Makefile.am: Add them.
* src/tgbatest/intvcmp2.cc: New test.
* src/tgbatest/Makefile.am: Add it.
* src/tgbatest/intvcomp.test: Call it.
parent 1d1872ab
2011-05-01 Alexandre Duret-Lutz <adl@lrde.epita.fr>
Implement a new compression inspired from simple-9.
* src/misc/intvcmp2.cc, src/misc/intvcmp2.hh: New files.
* src/misc/Makefile.am: Add them.
* src/tgbatest/intvcmp2.cc: New test.
* src/tgbatest/Makefile.am: Add it.
* src/tgbatest/intvcomp.test: Call it.
2011-04-15 Alexandre Duret-Lutz <adl@lrde.epita.fr>
* src/misc/intvcomp.cc: Low-level fine-tuning.
......
......@@ -38,6 +38,7 @@ misc_HEADERS = \
hash.hh \
hashfunc.hh \
intvcomp.hh \
intvcmp2.hh \
ltstr.hh \
minato.hh \
memusage.hh \
......@@ -56,6 +57,7 @@ libmisc_la_SOURCES = \
escape.cc \
freelist.cc \
intvcomp.cc \
intvcmp2.cc \
memusage.cc \
minato.cc \
modgray.cc \
......
This diff is collapsed.
// Copyright (C) 2011 Laboratoire de Recherche et Developpement de
// l'Epita (LRDE).
//
// This file is part of Spot, a model checking library.
//
// Spot is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// Spot is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
// License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Spot; see the file COPYING. If not, write to the Free
// Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
#ifndef SPOT_MISC_INTVCMP2_HH
# define SPOT_MISC_INTVCMP2_HH
#include <vector>
namespace spot
{
/// \addtogroup misc_tools
/// @{
/// \brief Compress an int array of size \a n into a int array.
///
/// The destination array should be at least \a dest_size large An
/// assert will be triggered if \a dest_size is too small. On
/// return, \a dest_size will be set to the actually number of int
/// filled in \a dest
void
int_array_array_compress2(const int* array, size_t n,
int* dest, size_t& dest_size);
/// \brief Uncompress an int array of size \a array_size into a int
/// array of size \a size.
///
/// \a size must be the exact expected size of uncompressed array.
void
int_array_array_decompress2(const int* array, size_t array_size,
int* res, size_t size);
/// @}
}
#endif // SPOT_MISC_INTVCMP2_HH
......@@ -38,6 +38,7 @@ check_PROGRAMS = \
expldot \
explprod \
intvcomp \
intvcmp2 \
ltlprod \
mixprod \
powerset \
......@@ -56,6 +57,7 @@ expldot_SOURCES = powerset.cc
expldot_CXXFLAGS = -DDOTTY
explprod_SOURCES = explprod.cc
intvcomp_SOURCES = intvcomp.cc
intvcmp2_SOURCES = intvcmp2.cc
ltl2tgba_SOURCES = ltl2tgba.cc
ltlprod_SOURCES = ltlprod.cc
mixprod_SOURCES = mixprod.cc
......
// Copyright (C) 2011 Laboratoire de Recherche et Developpement de
// l'Epita (LRDE).
//
// This file is part of Spot, a model checking library.
//
// Spot is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// Spot is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
// License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Spot; see the file COPYING. If not, write to the Free
// Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
#include <iostream>
#include "misc/intvcmp2.hh"
#include <cstring>
int check_aa(int* data, int size, unsigned expected = 0)
{
int* comp = new int[size * 2];
size_t csize = size * 2;
spot::int_array_array_compress2(data, size, comp, csize);
std::cout << "AC[" << csize << "] ";
for (size_t i = 0; i < csize; ++i)
std::cout << comp[i] << " ";
std::cout << std::endl;
int* decomp = new int[size + 30];
spot::int_array_array_decompress2(comp, csize, decomp, size);
std::cout << "AD[" << size << "] ";
for (int i = 0; i < size; ++i)
std::cout << decomp[i] << " ";
std::cout << std::endl;
int res = memcmp(data, decomp, size * sizeof(int));
if (res)
{
std::cout << "*** cmp error *** " << res << std::endl;
std::cout << "AE[" << size << "] ";
for (int i = 0; i < size; ++i)
std::cout << data[i] << " ";
std::cout << std::endl;
}
if (expected && (csize * sizeof(int) != expected))
{
std::cout << "*** size error *** (expected "
<< expected << " bytes, got " << csize * sizeof(int)
<< " bytes)" << std::endl;
res = 1;
}
std::cout << std::endl;
delete[] comp;
delete[] decomp;
return !!res;
}
int check(int* comp, int size, unsigned expected = 0)
{
return
//check_vv(comp, size, expected) +
//check_av(comp, size, expected) +
check_aa(comp, size, expected);
}
int main()
{
int errors = 0;
int comp1[] = { 1, 0, 0, 0, 0, 0, 3, 3, 4, 0, 0, 0 };
errors += check(comp1, sizeof(comp1) / sizeof(*comp1));
int comp2[] = { 3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8, 9, 7, 9, 3, 1 };
errors += check(comp2, sizeof(comp2) / sizeof(*comp2));
int comp3[] = { 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1,
0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0,
0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1,
0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1,
0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0 };
errors += check(comp3, sizeof(comp3) / sizeof(*comp3));
int comp4[] = { 1, 2, 1, 2, 1, 2, 2, 0 }; // 32 bits
errors += check(comp4, sizeof(comp4) / sizeof(*comp4), 4);
int comp5[] = { 1, 2, 1, 2, 1, 2, 2, 0, 1, 2, 1, 2, 1, 2, 2, 0 }; // 64 bits
errors += check(comp5, sizeof(comp5) / sizeof(*comp5), 8);
int comp6[] = { 1, 2, 1, 2, 1, 2, 2, 0, 1, 2, 1, 2, 1, 2, 2, 0,
1, 2, 1, 2, 1, 2, 2, 0, 1, 2, 1, 2, 1, 2, 2, 0 }; // 128 bits
errors += check(comp6, sizeof(comp6) / sizeof(*comp6), 16);
int comp7[] = { 4, 8, 10, 3, 49, 50, 0, 20, 13 };
errors += check(comp7, sizeof(comp7) / sizeof(*comp7));
int comp8[] = { 4959, 6754, 8133, 10985, 11121, 14413, 17335, 20754,
21317, 30008, 30381, 33494, 34935, 41210, 41417 };
errors += check(comp8, sizeof(comp8) / sizeof(*comp8));
int comp9[] = { 0, 0, 0, 0, 0, 0, 0, 0, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
errors += check(comp9, sizeof(comp9) / sizeof(*comp9));
int comp10[] = { 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0,
0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0,
9, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 10,
0, 0, 0, 0, 0, 0, 0, 0, 9 };
errors += check(comp10, sizeof(comp10) / sizeof(*comp10));
return errors;
}
......@@ -25,3 +25,4 @@
set -e
run 0 ../intvcomp
run 0 ../intvcmp2
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment