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 136 137 138 139 140 141
|
////////////////////////////////////////////////////////////////////////////////
//
// PointConfiguration.cc
//
// produced: 13/03/98 jr
// last change: 13/03/98 jr
//
////////////////////////////////////////////////////////////////////////////////
#include <iostream>
#include <ctype.h>
#include <string.h>
#include "PointConfiguration.hh"
#include "Chirotope.hh"
#include "PlacingTriang.hh"
#include "StairCaseMatrix.hh"
const int PointConfiguration::zeroes_in_row(const size_type index) const {
int result = 0;
for (size_type i = 0; i < coldim(); ++i) {
if ((*this)(index,i) == ZERO) {
++result;
}
}
return result;
}
const int PointConfiguration::zeroes_in_col(const size_type index) const {
int result = 0;
for (size_type i = 0; i < rowdim(); ++i) {
if ((*this)(i,index) == ZERO) {
++result;
}
}
return result;
}
const Field PointConfiguration::volume() const {
Field result(0);
const PlacingTriang pt(Chirotope(*this, false));
for (SimplicialComplex::const_iterator iter = pt.begin();
iter != pt.end();
++iter) {
const basis_type& basis(*iter);
StairCaseMatrix basis_matrix;
for (basis_type::const_iterator iter = basis.begin();
iter != basis.end();
++iter) {
basis_matrix.augment((*this)[*iter]);
}
result += abs(det(basis_matrix));
}
return result;
}
PointConfiguration& PointConfiguration::prism() {
PointConfiguration new_cols(*this);
for (size_type i = 0; i < no(); ++i) {
(*this)[i].append(ZERO);
new_cols[i].append(ONE);
}
append(new_cols);
return *this;
}
PointConfiguration& PointConfiguration::pyramid() {
Vector new_col(rank(), ZERO);
for (size_type i = 0; i < no(); ++i) {
(*this)[i].append(ZERO);
}
new_col.append(ONE);
append(new_col);
return *this;
}
PointConfiguration& PointConfiguration::direct_sum(const PointConfiguration& p) {
PointConfiguration new_cols = Matrix(rank(), p.no(), ZERO);
for (size_type i = 0; i < no(); ++i) {
(*this)[i].append(Vector(p.rank(), ZERO));
}
for (size_type i = 0; i < p.no(); ++i) {
new_cols[i].append(p[i]);
}
append(new_cols);
return *this;
}
PointConfiguration& PointConfiguration::homogenize() {
stack(Matrix(1, no(), ONE));
return *this;
}
PointConfiguration& PointConfiguration::transform_to_full_rank() {
Matrix::row_normal_form();
return *this;
}
PointConfiguration PointConfiguration::product(const PointConfiguration& p) const {
PointConfiguration result = Matrix(0, no() * p.no());
const ProductIndex product_index(no(), p.no());
if ((no() == 0) || (p.no() == 0)) {
return result;
}
for (size_type i = 0; i < no(); ++i) {
for (size_type j = 0; j < p.no(); ++j) {
result[product_index(i,j)] = (*this)[i];
result[product_index(i,j)].append(p[j]);
}
}
return result;
}
PointConfiguration& PointConfiguration::sort_rows() {
for (size_type i = 0; i < rowdim(); ++i) {
for (size_type j = i + 1; j < rowdim(); ++j) {
if (zeroes_in_row(j) > zeroes_in_row(i)) {
swap_rows(i, j);
}
}
}
return *this;
}
PointConfiguration& PointConfiguration::lex_abs_sort_cols() {
for (size_type i = 0; i < coldim(); ++i) {
for (size_type j = i + 1; j < coldim(); ++j) {
if (lex_abs_compare((*this)[i],(*this)[j])) {
swap_cols(i, j);
}
}
}
return *this;
}
PointConfiguration& PointConfiguration::preprocess() {
sort_rows();
lex_abs_sort_cols();
return *this;
}
// eof PointConfiguration.cc
|