/usr/share/doc/liblinbox-dev/examples/iliopoulos2.C is in liblinbox-dev 1.4.2-5build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | /* linbox/algorithms/coppersmith-invariant-factors.h
* Copyright (C) 2015 Gavin Harrison
*
* Written by Gavin Harrison <gavin.har@gmail.com>
*
* ========LICENCE========
* This file is part of the library LinBox.
*
* LinBox is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* ========LICENCE========
*/
#include "linbox/linbox-config.h"
#include <iostream>
#include <vector>
#include "linbox/ring/modular.h"
#include "linbox/matrix/dense-matrix.h"
#include "linbox/matrix/matrix-domain.h"
#include "linbox/matrix/random-matrix.h"
#include "linbox/algorithms/smith-form-iliopoulos2.h"
#include <givaro/zring.h>
using namespace LinBox;
using namespace Givaro;
typedef ZRing<Integer> Field;
typedef typename ZRing<Integer>::Element Element;
typedef IliopoulosDomain<Field> IliopoulosDom;
typedef MatrixDomain<Field> Domain;
typedef typename Domain::OwnMatrix Matrix;
typedef typename Field::RandIter RandIter;
typedef RandomDenseMatrix<RandIter, Field> RandomMatrix;
Field Z;
Domain MD(Z);
RandIter RI(Z);
RandomMatrix RDM(Z, RI);
IliopoulosDom ID(Z);
void printMatrix(Matrix &A) {
size_t m = A.rowdim();
size_t n = A.coldim();
std::cout << "matrix(ZZ, " << m << "," << n << ", [" << std::endl;
for (size_t i = 0; i < m; i++) {
Element tmp;
Z.write(std::cout << "[", A.getEntry(tmp, i, 0));
for (size_t j = 1; j < n; j++) {
Z.write(std::cout << ", ", A.getEntry(tmp, i, j));
}
std::cout << "]," << std::endl;
}
std::cout << "])" << std::endl;
}
void randomL(Matrix &L) {
size_t n = L.rowdim();
RDM.random(L);
for (size_t i = 0; i < n; i++) {
L.setEntry(i, i, Z.one);
for (size_t j = i+1; j < n; j++) {
L.setEntry(i, j, Z.zero);
}
}
}
void randomU(Matrix &U) {
size_t n = U.rowdim();
RDM.random(U);
for (size_t i = 0; i < n; i++) {
U.setEntry(i, i, Z.one);
for (size_t j = 0; j < i; j++) {
U.setEntry(i, j, Z.zero);
}
}
}
int main(int argc, char** argv)
{
Matrix A(Z, 4, 4);
//RDM.random(A);
A.setEntry(0,0,Integer(2));
A.setEntry(1,1,Integer(6));
A.setEntry(2,2,Integer(12));
printMatrix(A);
Matrix L1(Z, 4, 4);
randomL(L1);
Matrix U1(Z, 4, 4);
randomU(U1);
Matrix L2(Z, 4, 4);
randomL(L2);
Matrix U2(Z, 4, 4);
randomU(U2);
Matrix B(Z, 4, 4);
MD.mul(B, U1, A);
MD.leftMulin(B, L1);
MD.rightMulin(B, U2);
MD.rightMulin(B, L2);
printMatrix(B);
ID.smithFormIn(B, Integer(2 * 6 * 12));
printMatrix(B);
return 0;
}
|