Skip to content

Commit

Permalink
Update basis normalization
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin D. Weinberg committed Oct 27, 2024
2 parents cdd2897 + 9e0e023 commit edfd924
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ endif()
# Required compiler features
add_compile_options(-D_REENTRANT)

# Bake in library paths (esp. useful for HPC sites with modules)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)

# Check and enforce that we are a git repository. Necessary for
# submodules to work correctly.
if(EXISTS "${PROJECT_SOURCE_DIR}/.git")
Expand Down
2 changes: 1 addition & 1 deletion expui/BiorthBess.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <EXPException.H>
#include <interp.H>
#include <gaussQ.H>

#include <cassert>

BiorthBess::BiorthBess(double rmax, int lmax, int nmax, int RNUM) :
rmax(rmax), lmax(lmax), nmax(nmax), RNUM(RNUM)
Expand Down
27 changes: 27 additions & 0 deletions exputil/EmpCyl2d.cc
Original file line number Diff line number Diff line change
Expand Up @@ -873,9 +873,15 @@ void EmpCyl2d::create_tables()
if (m==0) xgrid[i] = r;

for (int n=0; n<nmaxfid; n++) {
<<<<<<< Updated upstream
pot(n) = basis->potl(m, n, r) / sqrt(basis->norm(n, m)*0.5);
den(n) = basis->dens(m, n, r) / sqrt(basis->norm(n, m)*2.0);
dph(n) = basis->dpot(m, n, r) / sqrt(basis->norm(n, m)*0.5);
=======
pot(n) = basis->potl(m, n, r) / sqrt(basis->norm(n, m)*0.5/M_PI);
den(n) = basis->dens(m, n, r) / sqrt(basis->norm(n, m)*2.0*M_PI);
dph(n) = basis->dpot(m, n, r) / sqrt(basis->norm(n, m)*0.5/M_PI);
>>>>>>> Stashed changes
}

pot = U.transpose() * pot;
Expand Down Expand Up @@ -1203,7 +1209,11 @@ double EmpCyl2d::get_potl(double r, int M, int N)
checkMN(M, N, "get_potl");

if (basis_test) {
<<<<<<< Updated upstream
return basis->potl(M, N, r)/sqrt(basis->norm(N, M)*0.5);
=======
return basis->potl(M, N, r)/sqrt(basis->norm(N, M)*0.5/M_PI);
>>>>>>> Stashed changes
}

int lo, hi;
Expand All @@ -1218,7 +1228,11 @@ double EmpCyl2d::get_dens(double r, int M, int N)
checkMN(M, N, "get_dens");

if (basis_test) {
<<<<<<< Updated upstream
return basis->dens(M, N, r)/sqrt(basis->norm(N, M)*2.0);
=======
return basis->dens(M, N, r)/sqrt(basis->norm(N, M)*2.0*M_PI);
>>>>>>> Stashed changes
}

int lo, hi;
Expand All @@ -1233,7 +1247,11 @@ double EmpCyl2d::get_dpot(double r, int M, int N)
checkMN(M, N, "get_dpot");

if (basis_test) {
<<<<<<< Updated upstream
return basis->dpot(M, N, r)/sqrt(basis->norm(N, M)*0.5);
=======
return basis->dpot(M, N, r)/sqrt(basis->norm(N, M)*2.0*M_PI);
>>>>>>> Stashed changes
}

int lo, hi;
Expand Down Expand Up @@ -1307,7 +1325,11 @@ void EmpCyl2d::checkCoefs()

for (int j=0; j<nmax; j++) {
coefs(j) += fac * disk->dens(rr) * get_potl(rr, 0, j);
<<<<<<< Updated upstream
coef0(j) += fac * disk->dens(rr) * basis->potl(0, j, rr) / sqrt(basis->norm(j, 0)*0.5);
=======
coef0(j) += fac * disk->dens(rr) * basis->potl(0, j, rr) / sqrt(basis->norm(j, 0)*2.0*M_PI);
>>>>>>> Stashed changes
}
}

Expand All @@ -1331,8 +1353,13 @@ void EmpCyl2d::checkCoefs()
for (int j=0; j<nmax; j++) {
uu += coefs(j) * get_potl(rr, 0, j);
vv += coefs(j) * get_dens(rr, 0, j);
<<<<<<< Updated upstream
yy += coef0(j) * basis->potl(0, j, rr) / sqrt(basis->norm(j, 0)*0.5);
zz += coef0(j) * basis->dens(0, j, rr) / sqrt(basis->norm(j, 0)*2.0);
=======
yy += coef0(j) * basis->potl(0, j, rr) / sqrt(basis->norm(j, 0)*2.0*M_PI);
zz += coef0(j) * basis->dens(0, j, rr) / sqrt(basis->norm(j, 0)*0.5/M_PI);
>>>>>>> Stashed changes
}

std::cout << std::setw(16) << rr
Expand Down
2 changes: 1 addition & 1 deletion extern/HighFive
Submodule HighFive updated 65 files
+7 −18 .github/workflows/ci.yml
+0 −138 .travis.yml
+25 −0 CHANGELOG.md
+6 −4 CMakeLists.txt
+22 −1 README.md
+23 −21 cmake/HighFiveWarnings.cmake
+1 −1 deps/catch2
+6 −3 doc/developer_guide.md
+17 −11 doc/doxygen-awesome-css/doxygen-awesome.css
+95 −1 doc/migration_guide.md
+1 −1 include/highfive/H5Attribute.hpp
+17 −0 include/highfive/H5DataSpace.hpp
+3 −3 include/highfive/H5Easy.hpp
+61 −9 include/highfive/H5File.hpp
+3 −23 include/highfive/H5Object.hpp
+0 −6 include/highfive/H5PropertyList.hpp
+4 −1 include/highfive/H5Version.hpp
+4 −1 include/highfive/H5Version.hpp.in
+12 −17 include/highfive/bits/H5Attribute_misc.hpp
+2 −4 include/highfive/bits/H5Converter_misc.hpp
+3 −3 include/highfive/bits/H5DataType_misc.hpp
+10 −3 include/highfive/bits/H5Dataspace_misc.hpp
+9 −9 include/highfive/bits/H5File_misc.hpp
+66 −100 include/highfive/bits/H5Inspector_misc.hpp
+0 −3 include/highfive/bits/H5Node_traits.hpp
+6 −10 include/highfive/bits/H5Node_traits_misc.hpp
+0 −6 include/highfive/bits/H5Object_misc.hpp
+0 −9 include/highfive/bits/H5PropertyList_misc.hpp
+23 −4 include/highfive/bits/H5ReadWrite_misc.hpp
+215 −33 include/highfive/bits/H5Slice_traits.hpp
+161 −14 include/highfive/bits/H5Slice_traits_misc.hpp
+29 −0 include/highfive/bits/assert_compatible_spaces.hpp
+31 −0 include/highfive/bits/convert_size_vector.hpp
+9 −0 include/highfive/bits/h5o_wrapper.hpp
+21 −0 include/highfive/bits/h5s_wrapper.hpp
+24 −6 include/highfive/boost.hpp
+8 −1 include/highfive/eigen.hpp
+149 −0 include/highfive/experimental/opencv.hpp
+34 −62 include/highfive/h5easy_bits/H5Easy_Eigen.hpp
+0 −100 include/highfive/h5easy_bits/H5Easy_opencv.hpp
+6 −50 include/highfive/h5easy_bits/H5Easy_scalar.hpp
+0 −94 include/highfive/h5easy_bits/H5Easy_xtensor.hpp
+9 −22 include/highfive/h5easy_bits/default_io_impl.hpp
+14 −3 include/highfive/span.hpp
+212 −0 include/highfive/xtensor.hpp
+1 −2 src/examples/CMakeLists.txt
+3 −4 src/examples/broadcasting_arrays.cpp
+131 −0 src/examples/select_slices.cpp
+37 −30 tests/unit/CMakeLists.txt
+80 −0 tests/unit/compary_arrays.hpp
+166 −29 tests/unit/data_generator.hpp
+24 −0 tests/unit/supported_types.hpp
+4 −225 tests/unit/test_all_types.cpp
+27 −0 tests/unit/test_boost.cpp
+248 −0 tests/unit/test_empty_arrays.cpp
+152 −15 tests/unit/test_high_five_selection.cpp
+36 −0 tests/unit/test_legacy.cpp
+59 −0 tests/unit/test_opencv.cpp
+58 −0 tests/unit/test_stl.cpp
+351 −0 tests/unit/test_string.cpp
+142 −0 tests/unit/test_xtensor.cpp
+2 −1 tests/unit/tests_high_five.hpp
+301 −686 tests/unit/tests_high_five_base.cpp
+12 −8 tests/unit/tests_high_five_easy.cpp
+0 −223 tests/unit/tests_high_five_multi_dims.cpp
2 changes: 1 addition & 1 deletion extern/pybind11
Submodule pybind11 updated 239 files
32 changes: 32 additions & 0 deletions pyEXP/TensorToArray.H
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,38 @@ py::array_t<T> make_ndarray3(Eigen::Tensor<T, 3>& mat)
);
}

template <typename T>
Eigen::Tensor<T, 3> make_tensor3(py::array_t<T> array)
{
// Request a buffer descriptor from Python
py::buffer_info buffer_info = array.request();

// Get the array dimenions
T *data = static_cast<T *>(buffer_info.ptr);
std::vector<ssize_t> shape = buffer_info.shape;

// Check rank
if (shape.size() != 3) {
std::ostringstream sout;
sout << "make_tensor3: tensor rank must be 3, found "
<< shape.size();
throw std::runtime_error(sout.str());
}

// Build result tensor with col-major ordering
Eigen::Tensor<T, 3> tensor(shape[0], shape[1], shape[2]);
for (int i=0, l=0; i < shape[0]; i++) {
for (int j=0; j < shape[1]; j++) {
for (int k=0; k < shape[2]; k++) {
tensor(i, j, k) = data[l++];
}
}
}

return tensor;
}


//! Helper function that maps the Eigen::Tensor<T, 4> into an numpy.ndarray
template <typename T>
py::array_t<T> make_ndarray4(Eigen::Tensor<T, 4>& mat)
Expand Down

0 comments on commit edfd924

Please sign in to comment.