//! atomic mass constant (in kg) static eT m_u() { return eT(1.660538782e-27); }
//! von Klitzing constant (in ohms) static eT R_k() { return eT(25812.807557); }
arma_hot inline void spglue_plus::apply_noalias(SpMat<eT>& out, const SpProxy<T1>& pa, const SpProxy<T2>& pb) { arma_extra_debug_sigprint(); arma_debug_assert_same_size(pa.get_n_rows(), pa.get_n_cols(), pb.get_n_rows(), pb.get_n_cols(), "addition"); if( (pa.get_n_nonzero() != 0) && (pb.get_n_nonzero() != 0) ) { out.set_size(pa.get_n_rows(), pa.get_n_cols()); // Resize memory to correct size. out.mem_resize(n_unique(pa, pb, op_n_unique_add())); // Now iterate across both matrices. typename SpProxy<T1>::const_iterator_type x_it = pa.begin(); typename SpProxy<T2>::const_iterator_type y_it = pb.begin(); typename SpProxy<T1>::const_iterator_type x_end = pa.end(); typename SpProxy<T2>::const_iterator_type y_end = pb.end(); uword cur_val = 0; while( (x_it != x_end) || (y_it != y_end) ) { if(x_it == y_it) { const eT val = (*x_it) + (*y_it); if (val != eT(0)) { access::rw(out.values[cur_val]) = val; access::rw(out.row_indices[cur_val]) = x_it.row(); ++access::rw(out.col_ptrs[x_it.col() + 1]); ++cur_val; } ++x_it; ++y_it; } else { const uword x_it_row = x_it.row(); const uword x_it_col = x_it.col(); const uword y_it_row = y_it.row(); const uword y_it_col = y_it.col(); if((x_it_col < y_it_col) || ((x_it_col == y_it_col) && (x_it_row < y_it_row))) // if y is closer to the end { access::rw(out.values[cur_val]) = (*x_it); access::rw(out.row_indices[cur_val]) = x_it_row; ++access::rw(out.col_ptrs[x_it_col + 1]); ++cur_val; ++x_it; } else { access::rw(out.values[cur_val]) = (*y_it); access::rw(out.row_indices[cur_val]) = y_it_row; ++access::rw(out.col_ptrs[y_it_col + 1]); ++cur_val; ++y_it; } } } const uword out_n_cols = out.n_cols; uword* col_ptrs = access::rwp(out.col_ptrs); // Fix column pointers to be cumulative. for(uword c = 1; c <= out_n_cols; ++c) { col_ptrs[c] += col_ptrs[c - 1]; } } else { if(pa.get_n_nonzero() == 0) { out = pb.Q; return; } if(pb.get_n_nonzero() == 0) { out = pa.Q; return; } } }
//! proton mass (in kg) static eT m_p() { return eT(1.672621637e-27); }
//! speed of light in vacuum (in meters per second) static eT c_0() { return eT(299792458.0); }
//! molar gas constant (in joules per mole kelvin) static eT R() { return eT(8.314472); }
//! Planck constant (in joule seconds) static eT h() { return eT(6.62606896e-34); }
//! conductance quantum (in siemens) static eT G_0() { return eT(7.7480917004e-5); }
//! Coulomb's constant (in meters per farad) static eT k_e() { return eT(8.9875517873681764e9); }
//! Bohr radius (in meters) static eT a_0() { return eT(0.52917720859e-10); }
//! characteristic impedance of vacuum (in ohms) static eT Z_0() { return eT(3.76730313461771e-2); }
//! Boltzmann constant (in eV/K) static eT k_evk() { return eT(8.617343e-5); }
//! Boltzmann constant (in joules per kelvin) static eT k() { return eT(1.3806504e-23); }
//! Avogadro constant static eT N_A() { return eT(6.02214179e23); }
//! magnetic constant (in henries per meter) static eT mu_0() { return eT(1.25663706143592e-06); }
//! electric constant (in farads per meter) static eT eps_0() { return eT(8.85418781762039e-12); }
//! magnetic flux quantum (in webers) static eT phi_0() { return eT(2.067833667e-15); }
//! electron mass (in kg) static eT m_e() { return eT(9.10938215e-31); }
//! Newtonian constant of gravitation (in newton square meters per kilogram squared) static eT G() { return eT(6.67428e-11); }
//! elementary charge (in coulombs) static eT e() { return eT(1.602176487e-19); }
//! Planck constant over 2 pi, aka reduced Planck constant (in joule seconds) static eT h_bar() { return eT(1.054571628e-34); }
//! Faraday constant (in coulombs) static eT F() { return eT(96485.3399); }
//! Rydberg constant (in reciprocal meters) static eT R_inf() { return eT(10973731.568527); }
//! fine-structure constant static eT alpha() { return eT(7.2973525376e-3); }
//! Stefan-Boltzmann constant static eT sigma() { return eT(5.670400e-8); }
//! inverse fine-structure constant static eT alpha_inv() { return eT(137.035999679); }
//! Wien wavelength displacement law constant static eT b() { return eT(2.8977685e-3); }
//! Josephson constant static eT K_J() { return eT(483597.891e9); }
arma_inline operator eT () { return eT(std::rand()) / eT(RAND_MAX); }
//! square root of 2 static eT sqrt2() { return eT(1.4142135623730950488016887242096980785696718753769480731766797379907324784621070388503875343276415727); }