Skip to content
This repository has been archived by the owner on Sep 29, 2024. It is now read-only.

Commit

Permalink
merge latest lieonn.
Browse files Browse the repository at this point in the history
  • Loading branch information
bitsofcotton committed Jun 23, 2024
1 parent d1efb21 commit aec93c2
Show file tree
Hide file tree
Showing 4 changed files with 210 additions and 131 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,6 @@ gokibin32mp:
${CXX} ${CXXFLAGS} ${MPFLAGS} -D_FLOAT_BITS_=32 -o gokibin32mp tools.cc
gokibin64mp:
${CXX} ${CXXFLAGS} ${MPFLAGS} -D_FLOAT_BITS_=64 -o gokibin64mp tools.cc
gokibin128mp:
${CXX} ${CXXFLAGS} ${MPFLAGS} -D_FLOAT_BITS_=128 -o gokibin128mp tools.cc

46 changes: 0 additions & 46 deletions goki.hh
Original file line number Diff line number Diff line change
Expand Up @@ -326,52 +326,6 @@ template <typename T> SimpleMatrix<T> sharpen(const int& size) {
return s;
}



template <typename T> SimpleMatrix<T> rotate(const SimpleMatrix<T>& d, const T& theta) {
assert(abs(theta) < atan(T(1)));
const auto c(cos(theta));
const auto s(sin(theta));
const auto h0(abs(int(c * T(d.rows()) - s * T(d.cols()))));
const auto h1(h0 + abs(int(s * T(d.cols()))) * 2);
const auto w0(abs(int(s * T(d.rows()) + c * T(d.cols()))));
const auto w1(w0 + abs(int(s * T(d.rows()))) * 2);
SimpleMatrix<T> res(h0 < d.rows() ? h1 : h0,
w0 < d.cols() ? w1 : w0);
const T offy(h0 < d.rows() ? abs(int(s * T(d.cols()))) : 0);
const T offx(w0 < d.cols() ? abs(int(s * T(d.rows()))) : 0);
res.O();
const auto diag(int(sqrt(res.rows() * res.rows() +
res.cols() * res.cols())) + 1);
for(int j = - diag; j < diag; j ++)
for(int k = - diag; k < diag; k ++) {
const int yy(c * T(j) - s * T(k) + offy);
const int xx(s * T(j) + c * T(k) + offx);
if(0 <= yy && yy < res.rows() &&
0 <= xx && xx < res.cols()) {
const auto dyy(getImgPt<int>(j, d.rows()));
const auto dxx(getImgPt<int>(k, d.cols()));
{
res(yy, xx) = res(min(yy + 1, int(res.rows()) - 1), xx) =
res(yy, min(xx + 1, int(res.cols()) - 1)) =
res(min(yy + 1, int(res.rows()) - 1),
min(xx + 1, int(res.cols()) - 1)) =
d(dyy, dxx);
}
}
}
return res;
}

template <typename T> static inline SimpleMatrix<T> center(const SimpleMatrix<T>& dr, const SimpleMatrix<T>& d) {
SimpleMatrix<T> res(d.rows(), d.cols());
for(int i = 0; i < res.rows(); i ++)
for(int j = 0; j < res.cols(); j ++)
res(i, j) = dr(max(0, min(i + (dr.rows() - d.rows()) / 2, dr.rows() - 1)),
max(0, min(j + (dr.cols() - d.cols()) / 2, dr.cols() - 1)));
return res;
}

template <typename T> static inline SimpleMatrix<T> flip(const SimpleMatrix<T>& d) {
auto res(d);
#if defined(_OPENMP)
Expand Down
Loading

0 comments on commit aec93c2

Please sign in to comment.