netlist: minor code maintenance. (nw)

This commit is contained in:
couriersud 2020-04-11 14:43:26 +02:00
parent 447ac5bccd
commit 2453c5b077
3 changed files with 19 additions and 21 deletions

View File

@ -311,7 +311,7 @@ namespace plib {
m_stat_cur_alloc() -= size; m_stat_cur_alloc() -= size;
#if (PUSE_ALIGNED_ALLOCATION) #if (PUSE_ALIGNED_ALLOCATION)
// NOLINTNEXTLINE(cppcoreguidelines-no-malloc) // NOLINTNEXTLINE(cppcoreguidelines-no-malloc)
free(ptr); ::free(ptr);
#else #else
::operator delete(ptr); ::operator delete(ptr);
#endif #endif

View File

@ -17,29 +17,29 @@
namespace plib namespace plib
{ {
template<typename T, typename A = aligned_allocator<T>> template<typename T, typename A = aligned_allocator<T>>
class pmatrix2d class pmatrix2d
{ {
public: public:
using size_type = std::size_t;
using value_type = T; using value_type = T;
using allocator_type = A; using allocator_type = A;
static constexpr const std::size_t align_size = align_traits<A>::align_size; static constexpr const size_type align_size = align_traits<A>::align_size;
static constexpr const std::size_t stride_size = align_traits<A>::stride_size; static constexpr const size_type stride_size = align_traits<A>::stride_size;
pmatrix2d() pmatrix2d() noexcept
: m_N(0), m_M(0), m_stride(8), m_v() : m_N(0), m_M(0), m_stride(8), m_v()
{ {
} }
pmatrix2d(std::size_t N, std::size_t M) pmatrix2d(size_type N, size_type M)
: m_N(N), m_M(M), m_v() : m_N(N), m_M(M), m_v()
{ {
m_stride = ((M + stride_size-1) / stride_size) * stride_size; m_stride = ((M + stride_size-1) / stride_size) * stride_size;
m_v.resize(N * m_stride); m_v.resize(N * m_stride);
} }
void resize(std::size_t N, std::size_t M) void resize(size_type N, size_type M)
{ {
m_N = N; m_N = N;
m_M = M; m_M = M;
@ -47,31 +47,31 @@ namespace plib
m_v.resize(N * m_stride); m_v.resize(N * m_stride);
} }
C14CONSTEXPR T * operator[] (std::size_t row) noexcept C14CONSTEXPR T * operator[] (size_type row) noexcept
{ {
return assume_aligned_ptr<T, align_size>(&m_v[m_stride * row]); return assume_aligned_ptr<T, align_size>(&m_v[m_stride * row]);
} }
constexpr const T * operator[] (std::size_t row) const noexcept constexpr const T * operator[] (size_type row) const noexcept
{ {
return assume_aligned_ptr<T, align_size>(&m_v[m_stride * row]); return assume_aligned_ptr<T, align_size>(&m_v[m_stride * row]);
} }
T & operator()(std::size_t r, std::size_t c) noexcept T & operator()(size_type r, size_type c) noexcept
{ {
return (*this)[r][c]; return (*this)[r][c];
} }
const T & operator()(std::size_t r, std::size_t c) const noexcept const T & operator()(size_type r, size_type c) const noexcept
{ {
return (*this)[r][c]; return (*this)[r][c];
} }
private: private:
std::size_t m_N; size_type m_N;
std::size_t m_M; size_type m_M;
std::size_t m_stride; size_type m_stride;
std::vector<T, A> m_v; std::vector<T, A> m_v;
}; };

View File

@ -508,20 +508,18 @@ namespace solver
// FIXME: gonn, gtn and Idr - which float types should they have? // FIXME: gonn, gtn and Idr - which float types should they have?
for (std::size_t i = 0; i < railstart; i++)
*tcr_r[i] += static_cast<FT>(go[i]);
auto gtot_t = std::accumulate(gt, gt + term_count, plib::constants<FT>::zero()); auto gtot_t = std::accumulate(gt, gt + term_count, plib::constants<FT>::zero());
// update diagonal element ... // update diagonal element ...
*tcr_r[railstart] += static_cast<FT>(gtot_t); //mat.A[mat.diag[k]] += gtot_t; *tcr_r[railstart] = static_cast<FT>(gtot_t); //mat.A[mat.diag[k]] += gtot_t;
auto RHS_t = std::accumulate(Idr, Idr + term_count, plib::constants<FT>::zero()); for (std::size_t i = 0; i < railstart; i++)
*tcr_r[i] += static_cast<FT>(go[i]);
auto RHS_t(std::accumulate(Idr, Idr + term_count, plib::constants<FT>::zero()));
for (std::size_t i = railstart; i < term_count; i++) for (std::size_t i = railstart; i < term_count; i++)
{
RHS_t += (- go[i]) * *cnV[i]; RHS_t += (- go[i]) * *cnV[i];
}
m_RHS[k] = static_cast<FT>(RHS_t); m_RHS[k] = static_cast<FT>(RHS_t);
} }