Skip to content

Commit

Permalink
fix clang-15 compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
foolnotion committed Aug 16, 2023
1 parent 13f978e commit 25e22e6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
12 changes: 6 additions & 6 deletions include/operon/optimizer/likelihood/gaussian_likelihood.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,13 @@ struct GaussianLikelihood : public LikelihoodBase<T> {
, jac_{bs_, np_}
{ }

using Scalar = LikelihoodBase<T>::Scalar;
using Scalar = typename LikelihoodBase<T>::Scalar;
using scalar_t = Scalar; // needed by lbfgs library NOLINT

using Vector = LikelihoodBase<T>::Vector;
using Ref = LikelihoodBase<T>::Ref;
using Cref = LikelihoodBase<T>::Cref;
using Vector = typename LikelihoodBase<T>::Vector;
using Ref = typename LikelihoodBase<T>::Ref;
using Cref = typename LikelihoodBase<T>::Cref;
using Matrix = typename LikelihoodBase<T>::Matrix;

// this loss can be used by the SGD or LBFGS optimizers
auto operator()(Cref x, Ref g) const noexcept -> Operon::Scalar final {
Expand Down Expand Up @@ -99,12 +100,11 @@ struct GaussianLikelihood : public LikelihoodBase<T> {
return std::numeric_limits<Operon::Scalar>::quiet_NaN();
}

static auto ComputeFisherMatrix(Span<Scalar const> pred, Span<Scalar const> jac, Span<Scalar const> sigma) -> LikelihoodBase<T>::Matrix
static auto ComputeFisherMatrix(Span<Scalar const> pred, Span<Scalar const> jac, Span<Scalar const> sigma) -> Matrix
{
EXPECT(!sigma.empty());
auto const rows = pred.size();
auto const cols = jac.size() / pred.size();
using Matrix = LikelihoodBase<T>::Matrix;
Eigen::Map<Matrix const> m(jac.data(), rows, cols);
typename LikelihoodBase<T>::Matrix f = m.transpose() * m;
if (sigma.size() == 1) {
Expand Down
17 changes: 9 additions & 8 deletions include/operon/optimizer/likelihood/poisson_likelihood.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,6 @@ namespace detail {

template<typename T = Operon::Scalar, bool LogInput = true>
struct PoissonLikelihood : public LikelihoodBase<T> {
using Scalar = T;
using Vector = Eigen::Matrix<Scalar, -1, 1>;
using Ref = Eigen::Ref<Vector>;
using Cref = Eigen::Ref<Vector const> const&;

using scalar_t = T; // for lbfgs solver NOLINT

PoissonLikelihood(Operon::RandomGenerator& rng, InterpreterBase<T> const& interpreter, Operon::Span<Operon::Scalar const> target, Operon::Range const range, std::size_t const batchSize = 0)
: LikelihoodBase<T>(interpreter)
Expand All @@ -62,6 +56,14 @@ struct PoissonLikelihood : public LikelihoodBase<T> {
, jac_{bs_, np_}
{ }

using Scalar = typename LikelihoodBase<T>::Scalar;
using scalar_t = Scalar; // needed by lbfgs library NOLINT

using Vector = typename LikelihoodBase<T>::Vector;
using Ref = typename LikelihoodBase<T>::Ref;
using Cref = typename LikelihoodBase<T>::Cref;
using Matrix = typename LikelihoodBase<T>::Matrix;

// this loss can be used by the SGD or LBFGS optimizers
auto operator()(Cref x, Ref g) const noexcept -> Operon::Scalar final {
++feval_;
Expand Down Expand Up @@ -95,11 +97,10 @@ struct PoissonLikelihood : public LikelihoodBase<T> {
return vstat::univariate::accumulate<Operon::Scalar>(x.begin(), x.end(), y.begin(), F{}).sum;
}

static auto ComputeFisherMatrix(Span<Scalar const> pred, Span<Scalar const> jac, Span<Scalar const> /*not used*/) -> LikelihoodBase<T>::Matrix
static auto ComputeFisherMatrix(Span<Scalar const> pred, Span<Scalar const> jac, Span<Scalar const> /*not used*/) -> Matrix
{
auto const rows = pred.size();
auto const cols = jac.size() / pred.size();
using Matrix = LikelihoodBase<T>::Matrix;
Eigen::Map<Matrix const> m(jac.data(), rows, cols);
Eigen::Map<Vector const> s{pred.data(), std::ssize(pred)};

Expand Down

0 comments on commit 25e22e6

Please sign in to comment.