void forward_propagation(Eigen::MatrixBase<Derived1> const &input, Eigen::MatrixBase<Derived2> const &weight, Eigen::MatrixBase<Derived3> const &bias, Eigen::MatrixBase<Derived4> &output, bool no_overlap = true, UnaryFunc func = UnaryFunc()) { static_assert(std::is_same<Derived1::Scalar, Derived2::Scalar>::value && std::is_same<Derived2::Scalar, Derived3::Scalar>::value && std::is_same<Derived4::Scalar, Derived4::Scalar>::value, "Data type of matrix input, weight, bias and output should be the same"); if(input.rows() != 0 && weight.rows() != 0 && bias.rows() != 0){ if(no_overlap){ output.noalias() = weight * input; }else{ output = weight * input; } using Scalar = typename Derived3::Scalar; using MatType = Eigen::Matrix<Scalar, Eigen::Dynamic, 1>; using Mapper = Eigen::Map<const MatType, Eigen::Aligned>; Mapper Map(&bias(0, 0), bias.size()); output.colwise() += Map; func(output); } }