Lattice Builder Manual Software Package for Constructing Rank-1 Lattices

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Examples

All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Modules Pages
Storage.cc

This examples shows how to use the LatBuilder::Storage template class.The output is as follows:

1 ==> storage / compression: flat storage / none
2 virtual / actual sizes: 12 / 12
3 original: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
4 unpermuted: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
5 strided(3): [0, 3, 6, 9, 0, 3, 6, 9, 0, 3, 6, 9]
6 ==> storage / compression: flat storage / symmetric
7 virtual / actual sizes: 12 / 7
8 original: [0, 1, 2, 3, 4, 5, 6]
9 unpermuted: [0, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1]
10 strided(3): [0, 3, 6, 3, 0, 3, 6]
11 ==> storage / compression: multilevel storage / none
12 virtual / actual sizes: 16 / 16
13 original: [0, 8, 4, 12, 2, 10, 14, 6, 1, 13, 9, 5, 15, 3, 7, 11]
14 unpermuted: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
15 strided(3): [0, 8, 12, 4, 6, 14, 10, 2, 3, 7, 11, 15, 13, 9, 5, 1]
16 ==> storage / compression: multilevel storage / symmetric
17 virtual / actual sizes: 16 / 9
18 original: [0, 8, 4, 2, 6, 1, 3, 7, 5]
19 unpermuted: [0, 1, 2, 3, 4, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1]
20 strided(3): [0, 8, 4, 6, 2, 3, 7, 5, 1]
// Copyright (c) 2012 David Munger, Pierre L'Ecuyer, Université de Montréal.
//
// This file is part of Lattice Builder.
//
// Lattice Builder 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 3 of the License, or
// (at your option) any later version.
//
// Lattice Builder 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 Lattice Builder. If not, see <http://www.gnu.org/licenses/>.
#include "latbuilder/Storage.h"
#include "latbuilder/TextStream.h"
using namespace LatBuilder;
using TextStream::operator<<;
template <LatType L, Compress C>
void test(const Storage<L, C>& storage)
{
std::cout << "==> storage / compression: " << Storage<L, C>::name() << std::endl;
std::cout << " virtual / actual sizes: " << storage.virtualSize() << " / " << storage.size() << std::endl;
RealVector original(storage.size());
auto unpermuted = storage.unpermuted(original);
for (RealVector::size_type j = unpermuted.size(); j > 0; j--)
unpermuted[j - 1] = j - 1;
auto strided = storage.strided(original, 3);
std::cout << " original: " << original << std::endl;
std::cout << " unpermuted: " << unpermuted << std::endl;
std::cout << " strided(3): " << strided << std::endl;
}
int main(int argc, const char *argv[])
{
test(Storage<LatType::ORDINARY, Compress::NONE >(12));
test(Storage<LatType::ORDINARY, Compress::SYMMETRIC>(12));
test(Storage<LatType::EMBEDDED, Compress::NONE >(16));
test(Storage<LatType::EMBEDDED, Compress::SYMMETRIC>(16));
return 0;
}