Merge branch 'master' of bitbucket.org:glavaux/cosmotool

This commit is contained in:
Guilhem Lavaux 2017-08-17 10:07:29 +02:00
commit c2059ea118
16 changed files with 162 additions and 138 deletions

View File

@ -1,6 +1,5 @@
cmake_minimum_required(VERSION 3.6) cmake_minimum_required(VERSION 3.6)
set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD 11)
cmake_policy(SET CMP0012 OLD)
list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_SOURCE_DIR}") list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_SOURCE_DIR}")
project(CosmoToolbox) project(CosmoToolbox)
@ -54,7 +53,7 @@ IF(YORICK_SUPPORT)
ENDIF((EXISTS ${NETCDFCPP_INCLUDE_PATH}/netcdf AND ${NETCDFCPP_LIBRARY} MATCHES "netcdf_c\\+\\+4") OR (INTERNAL_NETCDF)) ENDIF((EXISTS ${NETCDFCPP_INCLUDE_PATH}/netcdf AND ${NETCDFCPP_LIBRARY} MATCHES "netcdf_c\\+\\+4") OR (INTERNAL_NETCDF))
ENDIF(YORICK_SUPPORT) ENDIF(YORICK_SUPPORT)
find_program(CYTHON cython) find_program(CYTHON cython3 cython)
find_library(ZLIB z) find_library(ZLIB z)
find_library(DL_LIBRARY dl) find_library(DL_LIBRARY dl)
find_library(MATH_LIBRARY m) find_library(MATH_LIBRARY m)

View File

@ -1,10 +1,12 @@
execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-c" execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-c"
"import distutils.sysconfig as cs; import os; v=cs.get_config_vars(); print(os.path.join(v['LIBDIR'],v['LDLIBRARY']));" "import distutils.sysconfig as cs; import os; import sys; v=cs.get_config_vars(); print(os.path.join(v['LIBDIR'],v['LDLIBRARY'])); sys.exit(0)"
RESULT_VARIABLE _PYLIB_SEARCH_SUCCESS RESULT_VARIABLE _PYLIB_SEARCH_SUCCESS
OUTPUT_VARIABLE _PYLIB_VALUES_OUTPUT OUTPUT_VARIABLE _PYLIB_VALUES_OUTPUT
ERROR_VARIABLE _PYLIB_ERROR_VALUE ERROR_VARIABLE _PYLIB_ERROR_VALUE
OUTPUT_STRIP_TRAILING_WHITESPACE) OUTPUT_STRIP_TRAILING_WHITESPACE)
message(${_PYLIB_SEARCH_SUCCESS})
execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-c" execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-c"
"import distutils.sysconfig as cs; import os; v=cs.get_config_vars(); print(v['INCLUDEPY']);" "import distutils.sysconfig as cs; import os; v=cs.get_config_vars(); print(v['INCLUDEPY']);"
RESULT_VARIABLE _PYINC_SEARCH_SUCCESS RESULT_VARIABLE _PYINC_SEARCH_SUCCESS

View File

@ -5,8 +5,9 @@ OPTION(ENABLE_OPENMP "Set to Yes if Healpix and/or you need openMP" OFF)
SET(FFTW_URL "http://www.fftw.org/fftw-3.3.3.tar.gz" CACHE URL "URL to download FFTW from") SET(FFTW_URL "http://www.fftw.org/fftw-3.3.3.tar.gz" CACHE URL "URL to download FFTW from")
SET(EIGEN_URL "http://bitbucket.org/eigen/eigen/get/3.2.10.tar.gz" CACHE URL "URL to download Eigen from") SET(EIGEN_URL "http://bitbucket.org/eigen/eigen/get/3.2.10.tar.gz" CACHE URL "URL to download Eigen from")
SET(GENGETOPT_URL "ftp://ftp.gnu.org/gnu/gengetopt/gengetopt-2.22.5.tar.gz" CACHE STRING "URL to download gengetopt from") SET(GENGETOPT_URL "ftp://ftp.gnu.org/gnu/gengetopt/gengetopt-2.22.5.tar.gz" CACHE STRING "URL to download gengetopt from")
SET(HDF5_URL "https://support.hdfgroup.org/ftp/HDF5/current18/src/hdf5-1.8.18.tar.bz2" CACHE STRING "URL to download HDF5 from") SET(HDF5_URL "https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.8/hdf5-1.8.18/src/hdf5-1.8.18.tar.gz" CACHE STRING "URL to download HDF5 from")
SET(NETCDF_URL "http://www.unidata.ucar.edu/downloads/netcdf/ftp/netcdf-4.1.3.tar.gz" CACHE STRING "URL to download NetCDF from") SET(NETCDF_URL "ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-4.4.1.1.tar.gz" CACHE STRING "URL to download NetCDF from")
SET(NETCDFCXX_URL "https://github.com/Unidata/netcdf-cxx4/archive/v4.3.0.tar.gz" CACHE STRING "URL to download NetCDF-C++ from")
SET(BOOST_URL "http://sourceforge.net/projects/boost/files/boost/1.61.0/boost_1_61_0.tar.gz/download" CACHE STRING "URL to download Boost from") SET(BOOST_URL "http://sourceforge.net/projects/boost/files/boost/1.61.0/boost_1_61_0.tar.gz/download" CACHE STRING "URL to download Boost from")
SET(GSL_URL "ftp://ftp.gnu.org/gnu/gsl/gsl-1.15.tar.gz" CACHE STRING "URL to download GSL from ") SET(GSL_URL "ftp://ftp.gnu.org/gnu/gsl/gsl-1.15.tar.gz" CACHE STRING "URL to download GSL from ")
mark_as_advanced(FFTW_URL EIGEN_URL HDF5_URL NETCDF_URL BOOST_URL GSL_URL) mark_as_advanced(FFTW_URL EIGEN_URL HDF5_URL NETCDF_URL BOOST_URL GSL_URL)
@ -77,13 +78,14 @@ if (INTERNAL_HDF5)
ExternalProject_Add(hdf5 ExternalProject_Add(hdf5
PREFIX ${BUILD_PREFIX}/hdf5-prefix PREFIX ${BUILD_PREFIX}/hdf5-prefix
URL ${HDF5_URL} URL ${HDF5_URL}
CONFIGURE_COMMAND ${HDF5_SOURCE_DIR}/configure CMAKE_ARGS
--disable-shared --enable-cxx --with-pic -DCMAKE_INSTALL_PREFIX=${EXT_INSTALL}
--prefix=${HDF5_BIN_DIR} --libdir=${HDF5_BIN_DIR}/lib -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
CPPFLAGS=${CONFIGURE_CPP_FLAGS} CC=${CMAKE_C_COMPILER} -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
CXX=${CMAKE_CXX_COMPILER} -DHDF5_BUILD_CPP_LIB=ON
BUILD_IN_SOURCE 1 -DHDF5_BUILD_TOOLS=ON
INSTALL_COMMAND ${CMAKE_MAKE_PROGRAM} install -DHDF5_BUILD_HL_LIB=ON
-DBUILD_SHARED_LIBS=OFF
) )
SET(cosmotool_DEPS ${cosmotool_DEPS} hdf5) SET(cosmotool_DEPS ${cosmotool_DEPS} hdf5)
SET(hdf5_built hdf5) SET(hdf5_built hdf5)
@ -112,7 +114,12 @@ else (INTERNAL_HDF5)
cmessage(STATUS "HDF5 lib: ${HDF5_LIBRARIES}") cmessage(STATUS "HDF5 lib: ${HDF5_LIBRARIES}")
cmessage(STATUS "HDF5 includes: ${HDF5_INCLUDE_DIRS}") cmessage(STATUS "HDF5 includes: ${HDF5_INCLUDE_DIRS}")
cmessage(STATUS "HDF5 C lib: ${HDF5_C_LIBRARY}") cmessage(STATUS "HDF5 C lib: ${HDF5_C_LIBRARY}")
get_filename_component(HDF5_BIN_DIR ${HDF5_C_LIBRARY} DIRECTORY) cmessage(STATUS "HDF5 BIN: ${HDF5_BIN_DIR}")
foreach(hdf5lib IN LISTS HDF5_LIBRARIES)
if (${hdf5lib} MATCHES "(hdf5)|(HDF5)")
get_filename_component(HDF5_BIN_DIR ${hdf5lib} DIRECTORY)
endif()
endforeach()
cmessage(STATUS "HDF5 libpath: ${HDF5_BIN_DIR}") cmessage(STATUS "HDF5 libpath: ${HDF5_BIN_DIR}")
else() else()
cmessage(STATUS "Found HDF5 cmake config.") cmessage(STATUS "Found HDF5 cmake config.")
@ -137,7 +144,7 @@ endforeach(include_dir)
if (INTERNAL_NETCDF) if (INTERNAL_NETCDF)
SET(NETCDF_SOURCE_DIR ${BUILD_PREFIX}/netcdf-prefix/src/netcdf) SET(NETCDF_SOURCE_DIR ${BUILD_PREFIX}/netcdf-prefix/src/netcdf)
SET(NETCDF_BIN_DIR ${EXT_INSTALL}) SET(NETCDF_BIN_DIR ${EXT_INSTALL})
# SET(CONFIGURE_CPP_FLAGS "${CONFIGURE_CPP_FLAGS} -I${NETCDF_BIN_DIR}/include") SET(CONFIGURE_CPP_FLAGS "${CONFIGURE_CPP_FLAGS} -I${NETCDF_BIN_DIR}/include")
SET(CONFIGURE_LDFLAGS "${CONFIGURE_LDFLAGS} -L${NETCDF_BIN_DIR}/lib") SET(CONFIGURE_LDFLAGS "${CONFIGURE_LDFLAGS} -L${NETCDF_BIN_DIR}/lib")
SET(EXTRA_NC_FLAGS CPPFLAGS=${CONFIGURE_CPP_FLAGS} LIBS=${CONFIGURE_LIBS} LDFLAGS=${CONFIGURE_LDFLAGS}) SET(EXTRA_NC_FLAGS CPPFLAGS=${CONFIGURE_CPP_FLAGS} LIBS=${CONFIGURE_LIBS} LDFLAGS=${CONFIGURE_LDFLAGS})
SET(NETCDF_CONFIG_COMMAND ${NETCDF_SOURCE_DIR}/configure SET(NETCDF_CONFIG_COMMAND ${NETCDF_SOURCE_DIR}/configure
@ -150,15 +157,36 @@ if (INTERNAL_NETCDF)
DEPENDS ${hdf5_built} DEPENDS ${hdf5_built}
PREFIX ${BUILD_PREFIX}/netcdf-prefix PREFIX ${BUILD_PREFIX}/netcdf-prefix
URL ${NETCDF_URL} URL ${NETCDF_URL}
CONFIGURE_COMMAND ${NETCDF_CONFIG_COMMAND} CMAKE_ARGS
BUILD_IN_SOURCE 1 -DCMAKE_PREFIX_PATH=${EXT_INSTALL}
INSTALL_COMMAND ${CMAKE_MAKE_PROGRAM} install -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DBUILD_SHARED_LIBS=OFF
-DBUILD_TESTING=OFF
-DCMAKE_BUILD_TYPE=Release
-DENABLE_NETCDF4=ON
-DENABLE_DAP=OFF
-DCMAKE_INSTALL_PREFIX=${NETCDF_BIN_DIR}
)
SET(NETCDFCXX_SOURCE_DIR ${BUILD_PREFIX}/netcdf-c++-prefix/src/netcdf-c++)
ExternalProject_Add(netcdf-c++
DEPENDS ${hdf5_built} netcdf
PREFIX ${BUILD_PREFIX}/netcdf-c++-prefix
URL ${NETCDFCXX_URL}
CMAKE_ARGS
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DBUILD_SHARED_LIBS=OFF
-DBUILD_TESTING=OFF
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_INSTALL_PREFIX=${NETCDF_BIN_DIR}
) )
# SET(CONFIGURE_CPP_LDFLAGS "${CONFIGURE_LDFLAGS}") # SET(CONFIGURE_CPP_LDFLAGS "${CONFIGURE_LDFLAGS}")
# SET(EXTRA_NC_FLAGS CPPFLAGS=${CONFIGURE_CPP_FLAGS} LDFLAGS=${CONFIGURE_CPP_LDFLAGS}) # SET(EXTRA_NC_FLAGS CPPFLAGS=${CONFIGURE_CPP_FLAGS} LDFLAGS=${CONFIGURE_CPP_LDFLAGS})
SET(cosmotool_DEPS ${cosmotool_DEPS} netcdf) SET(cosmotool_DEPS ${cosmotool_DEPS} netcdf netcdf-c++)
SET(NETCDF_LIBRARY ${NETCDF_BIN_DIR}/lib/libnetcdf.a CACHE STRING "NetCDF lib" FORCE) SET(NETCDF_LIBRARY ${NETCDF_BIN_DIR}/lib/libnetcdf.a CACHE STRING "NetCDF lib" FORCE)
SET(NETCDFCPP_LIBRARY ${NETCDF_BIN_DIR}/lib/libnetcdf_c++4.a CACHE STRING "NetCDF-C++ lib" FORCE) SET(NETCDFCPP_LIBRARY ${NETCDF_BIN_DIR}/lib/libnetcdf-cxx4.a CACHE STRING "NetCDF-C++ lib" FORCE)
SET(NETCDF_INCLUDE_PATH ${NETCDF_BIN_DIR}/include CACHE STRING "NetCDF include" FORCE) SET(NETCDF_INCLUDE_PATH ${NETCDF_BIN_DIR}/include CACHE STRING "NetCDF include" FORCE)
SET(NETCDFCPP_INCLUDE_PATH ${NETCDF_INCLUDE_PATH} CACHE STRING "NetCDF C++ include path" FORCE) SET(NETCDFCPP_INCLUDE_PATH ${NETCDF_INCLUDE_PATH} CACHE STRING "NetCDF C++ include path" FORCE)

View File

@ -1,5 +1,6 @@
set(CMAKE_SHARED_MODULE_PREFIX) set(CMAKE_SHARED_MODULE_PREFIX)
include_directories(${NUMPY_INCLUDE_DIRS} ${PYTHON_INCLUDE_PATH} ${CMAKE_SOURCE_DIR}/src ${CMAKE_BINARY_DIR}/src ${CMAKE_SOURCE_DIR}/python) include_directories(${NUMPY_INCLUDE_DIRS} ${PYTHON_INCLUDE_PATH} ${CMAKE_SOURCE_DIR}/src ${CMAKE_BINARY_DIR}/src ${CMAKE_SOURCE_DIR}/python)
IF(CYTHON) IF(CYTHON)
@ -39,7 +40,10 @@ add_library(_project MODULE ${CMAKE_CURRENT_BINARY_DIR}/_project.cpp)
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Bsymbolic-functions") SET(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Bsymbolic-functions")
if(APPLE)
set(CMAKE_MODULE_LINKER_FLAGS "-undefined dynamic_lookup")
endif()
target_link_libraries(_cosmotool ${CosmoTool_local} ${PYTHON_LIBRARIES} ${GSL_LIBRARIES}) target_link_libraries(_cosmotool ${CosmoTool_local} ${PYTHON_LIBRARIES} ${GSL_LIBRARIES})
target_link_libraries(_cosmo_power ${CosmoTool_local} ${PYTHON_LIBRARIES} ${GSL_LIBRARIES}) target_link_libraries(_cosmo_power ${CosmoTool_local} ${PYTHON_LIBRARIES} ${GSL_LIBRARIES})
@ -74,6 +78,9 @@ if (NOT PYTHON_SITE_PACKAGES)
mark_as_advanced(USER_PYTHON_SITE_PACKAGES SYSTEM_PYTHON_SITE_PACKAGES) mark_as_advanced(USER_PYTHON_SITE_PACKAGES SYSTEM_PYTHON_SITE_PACKAGES)
endif (NOT PYTHON_SITE_PACKAGES) endif (NOT PYTHON_SITE_PACKAGES)
message(STATUS "System python site: ${SYSTEM_PYTHON_SITE_PACKAGES}")
message(STATUS "User python site: ${USER_PYTHON_SITE_PACKAGES}")
OPTION(INSTALL_PYTHON_LOCAL OFF) OPTION(INSTALL_PYTHON_LOCAL OFF)
IF (NOT INSTALL_PYTHON_LOCAL) IF (NOT INSTALL_PYTHON_LOCAL)
@ -81,6 +88,7 @@ IF (NOT INSTALL_PYTHON_LOCAL)
ELSE (NOT INSTALL_PYTHON_LOCAL) ELSE (NOT INSTALL_PYTHON_LOCAL)
SET(PYTHON_SITE_PACKAGES ${USER_PYTHON_SITE_PACKAGES}) SET(PYTHON_SITE_PACKAGES ${USER_PYTHON_SITE_PACKAGES})
ENDIF(NOT INSTALL_PYTHON_LOCAL) ENDIF(NOT INSTALL_PYTHON_LOCAL)
cmessage(STATUS "Python install location: ${PYTHON_SITE_PACKAGES}")
if (WIN32 AND NOT CYGWIN) if (WIN32 AND NOT CYGWIN)

View File

@ -1,4 +1,6 @@
#ifdef _OPENMP
#include <omp.h> #include <omp.h>
#endif
#include <iostream> #include <iostream>
#include <boost/format.hpp> #include <boost/format.hpp>
#include <boost/multi_array.hpp> #include <boost/multi_array.hpp>
@ -171,7 +173,11 @@ void CosmoTool_compute_bispectrum(
{ {
// First remap to multi_array for easy access // First remap to multi_array for easy access
size_t kNz = Nz/2+1; size_t kNz = Nz/2+1;
#ifdef _OPENMP
int Ntasks = omp_get_max_threads(); int Ntasks = omp_get_max_threads();
#else
int Ntasks = 1;
#endif
boost::multi_array_ref<std::complex<double>, 3> a_delta(reinterpret_cast<std::complex<double>*>(delta_hat), boost::extents[Nx][Ny][kNz]); boost::multi_array_ref<std::complex<double>, 3> a_delta(reinterpret_cast<std::complex<double>*>(delta_hat), boost::extents[Nx][Ny][kNz]);
boost::multi_array_ref<size_t, 3> a_Nt(Ntriangles, boost::extents[Nk][Nk][Nk]); boost::multi_array_ref<size_t, 3> a_Nt(Ntriangles, boost::extents[Nk][Nk][Nk]);
boost::multi_array_ref<std::complex<double>, 3> a_B(reinterpret_cast<std::complex<double>*>(B), boost::extents[Nk][Nk][Nk]); boost::multi_array_ref<std::complex<double>, 3> a_B(reinterpret_cast<std::complex<double>*>(B), boost::extents[Nk][Nk][Nk]);
@ -190,6 +196,7 @@ void CosmoTool_compute_bispectrum(
delta_mirror[n1.i1][n1.i2][n1.i3] = std::conj(delta_mirror[n2.i1][n2.i2][n2.i3]); delta_mirror[n1.i1][n1.i2][n1.i3] = std::conj(delta_mirror[n2.i1][n2.i2][n2.i3]);
} }
#ifdef _OPENMP
// First loop over m1 // First loop over m1
#pragma omp parallel #pragma omp parallel
{ {
@ -236,6 +243,9 @@ void CosmoTool_compute_bispectrum(
a_B_p[q] += b_B_p[q]; a_B_p[q] += b_B_p[q];
} }
} }
#else
#warning Serial version not implemented
#endif
} }

View File

@ -9,6 +9,9 @@ cimport cython
np.import_array() np.import_array()
cdef extern from "sys/types.h":
ctypedef np.int64_t int64_t
cdef extern from "loadSimu.hpp" namespace "CosmoTool": cdef extern from "loadSimu.hpp" namespace "CosmoTool":
cdef cppclass SimuData: cdef cppclass SimuData:
@ -20,7 +23,7 @@ cdef extern from "loadSimu.hpp" namespace "CosmoTool":
np.float_t Omega_Lambda np.float_t Omega_Lambda
np.int64_t TotalNumPart np.int64_t TotalNumPart
np.int64_t NumPart np.int64_t NumPart
np.int64_t *Id int64_t *Id
float *Pos[3] float *Pos[3]
float *Vel[3] float *Vel[3]
int *type int *type
@ -323,7 +326,7 @@ cdef object wrap_array(void *p, np.uint64_t s, int typ):
cdef object wrap_float_array(float *p, np.uint64_t s): cdef object wrap_float_array(float *p, np.uint64_t s):
return wrap_array(<void *>p, s, np.NPY_FLOAT32) return wrap_array(<void *>p, s, np.NPY_FLOAT32)
cdef object wrap_int64_array(np.int64_t* p, np.uint64_t s): cdef object wrap_int64_array(int64_t* p, np.uint64_t s):
return wrap_array(<void *>p, s, np.NPY_INT64) return wrap_array(<void *>p, s, np.NPY_INT64)
cdef object wrap_int_array(int* p, np.uint64_t s): cdef object wrap_int_array(int* p, np.uint64_t s):
@ -388,6 +391,7 @@ def loadGadget(str filename, int snapshot_id, int gadgetFormat = 1, bool loadPos
cdef int flags cdef int flags
cdef SimuData *data cdef SimuData *data
cdef Simulation simu cdef Simulation simu
cdef const char *filename_bs
flags = 0 flags = 0
if loadPosition: if loadPosition:
@ -401,7 +405,10 @@ def loadGadget(str filename, int snapshot_id, int gadgetFormat = 1, bool loadPos
if loadMass: if loadMass:
flags |= NEED_MASS flags |= NEED_MASS
data = loadGadgetMulti(filename, snapshot_id, flags, gadgetFormat) filename_b = bytes(filename, 'utf-8')
filename_bs = filename_b
with nogil:
data = loadGadgetMulti(filename_bs, snapshot_id, flags, gadgetFormat)
if data == <SimuData*>0: if data == <SimuData*>0:
return None return None
@ -497,7 +504,7 @@ def writeGadget(str filename, object simulation):
simdata.Vel[j] = <float *>vel.data simdata.Vel[j] = <float *>vel.data
ids = simulation.getIdentifiers() ids = simulation.getIdentifiers()
simdata.Id = <np.int64_t *>ids.data simdata.Id = <int64_t *>ids.data
simdata.BoxSize = simulation.getBoxsize() simdata.BoxSize = simulation.getBoxsize()
simdata.time = simulation.getTime() simdata.time = simulation.getTime()
simdata.Hubble = simulation.getHubble() simdata.Hubble = simulation.getHubble()

View File

@ -389,7 +389,8 @@ cdef void INTERNAL_project_cic_no_mass(npx.ndarray[DTYPE_t, ndim=3] g,
npx.ndarray[DTYPE_t, ndim=2] x, int Ngrid, double Lbox, double shifter): npx.ndarray[DTYPE_t, ndim=2] x, int Ngrid, double Lbox, double shifter):
cdef double delta_Box = Ngrid/Lbox cdef double delta_Box = Ngrid/Lbox
cdef int i cdef int i
cdef double a[3], c[3] cdef double a[3]
cdef double c[3]
cdef int b[3] cdef int b[3]
cdef int do_not_put cdef int do_not_put
@ -404,9 +405,6 @@ cdef void INTERNAL_project_cic_no_mass(npx.ndarray[DTYPE_t, ndim=3] g,
if b[j] < 0 or b[j]+1 >= Ngrid: if b[j] < 0 or b[j]+1 >= Ngrid:
do_not_put = True do_not_put = True
print("b = %g %g %g" % (b[0], b[1], b[2]))
print("a = %g %g %g" % (a[0], a[1], a[2]))
if not do_not_put: if not do_not_put:
g[b[0],b[1],b[2]] += c[0]*c[1]*c[2] g[b[0],b[1],b[2]] += c[0]*c[1]*c[2]
g[b[0]+1,b[1],b[2]] += a[0]*c[1]*c[2] g[b[0]+1,b[1],b[2]] += a[0]*c[1]*c[2]
@ -424,8 +422,10 @@ cdef void INTERNAL_project_cic_no_mass_periodic(npx.ndarray[DTYPE_t, ndim=3] g,
npx.ndarray[DTYPE_t, ndim=2] x, int Ngrid, double Lbox, double shifter): npx.ndarray[DTYPE_t, ndim=2] x, int Ngrid, double Lbox, double shifter):
cdef double delta_Box = Ngrid/Lbox cdef double delta_Box = Ngrid/Lbox
cdef int i cdef int i
cdef double a[3], c[3] cdef double a[3]
cdef int b[3], b1[3] cdef double c[3]
cdef int b[3]
cdef int b1[3]
cdef int do_not_put cdef int do_not_put
cdef DTYPE_t[:,:] ax cdef DTYPE_t[:,:] ax
cdef DTYPE_t[:,:,:] ag cdef DTYPE_t[:,:,:] ag
@ -465,7 +465,8 @@ cdef void INTERNAL_project_cic_with_mass(npx.ndarray[DTYPE_t, ndim=3] g,
int Ngrid, double Lbox, double shifter): int Ngrid, double Lbox, double shifter):
cdef double delta_Box = Ngrid/Lbox cdef double delta_Box = Ngrid/Lbox
cdef int i cdef int i
cdef double a[3], c[3] cdef double a[3]
cdef double c[3]
cdef DTYPE_t m0 cdef DTYPE_t m0
cdef int b[3] cdef int b[3]
@ -502,8 +503,10 @@ cdef void INTERNAL_project_cic_with_mass_periodic(npx.ndarray[DTYPE_t, ndim=3] g
cdef double half_Box = 0.5*Lbox, m0 cdef double half_Box = 0.5*Lbox, m0
cdef double delta_Box = Ngrid/Lbox cdef double delta_Box = Ngrid/Lbox
cdef int i cdef int i
cdef double a[3], c[3] cdef double a[3]
cdef int b[3], b1[3] cdef double c[3]
cdef int b[3]
cdef int b1[3]
for i in range(x.shape[0]): for i in range(x.shape[0]):
@ -550,18 +553,18 @@ def project_cic(npx.ndarray[DTYPE_t, ndim=2] x not None, npx.ndarray[DTYPE_t, nd
if x.shape[1] != 3: if x.shape[1] != 3:
raise ValueError("Invalid shape for x array") raise ValueError("Invalid shape for x array")
if mass != None and mass.shape[0] != x.shape[0]: if mass is not None and mass.shape[0] != x.shape[0]:
raise ValueError("Mass array and coordinate array must have the same number of elements") raise ValueError("Mass array and coordinate array must have the same number of elements")
g = np.zeros((Ngrid,Ngrid,Ngrid),dtype=DTYPE) g = np.zeros((Ngrid,Ngrid,Ngrid),dtype=DTYPE)
if not periodic: if not periodic:
if mass == None: if mass is None:
INTERNAL_project_cic_no_mass(g, x, Ngrid, Lbox, shifter) INTERNAL_project_cic_no_mass(g, x, Ngrid, Lbox, shifter)
else: else:
INTERNAL_project_cic_with_mass(g, x, mass, Ngrid, Lbox, shifter) INTERNAL_project_cic_with_mass(g, x, mass, Ngrid, Lbox, shifter)
else: else:
if mass == None: if mass is None:
INTERNAL_project_cic_no_mass_periodic(g, x, Ngrid, Lbox, shifter) INTERNAL_project_cic_no_mass_periodic(g, x, Ngrid, Lbox, shifter)
else: else:
INTERNAL_project_cic_with_mass_periodic(g, x, mass, Ngrid, Lbox, shifter) INTERNAL_project_cic_with_mass_periodic(g, x, mass, Ngrid, Lbox, shifter)
@ -629,7 +632,8 @@ cdef DTYPE_t cube_integral(DTYPE_t u[3], DTYPE_t u0[3], int r[1], DTYPE_t alpha_
@cython.cdivision(True) @cython.cdivision(True)
cdef DTYPE_t cube_integral_trilin(DTYPE_t u[3], DTYPE_t u0[3], int r[1], DTYPE_t vertex_value[8], DTYPE_t alpha_max) nogil: cdef DTYPE_t cube_integral_trilin(DTYPE_t u[3], DTYPE_t u0[3], int r[1], DTYPE_t vertex_value[8], DTYPE_t alpha_max) nogil:
cdef DTYPE_t I, tmp_a cdef DTYPE_t I, tmp_a
cdef DTYPE_t v[3], term[4] cdef DTYPE_t v[3]
cdef DTYPE_t term[4]
cdef int i, j, q cdef int i, j, q
j = 0 j = 0
@ -671,7 +675,8 @@ cdef DTYPE_t integrator1(DTYPE_t[:,:,:] density,
DTYPE_t u[3], DTYPE_t u0[3], int u_delta[3], int iu0[3], int jumper[1], DTYPE_t alpha_max) nogil: DTYPE_t u[3], DTYPE_t u0[3], int u_delta[3], int iu0[3], int jumper[1], DTYPE_t alpha_max) nogil:
cdef DTYPE_t vertex_value[8] cdef DTYPE_t vertex_value[8]
cdef DTYPE_t d cdef DTYPE_t d
cdef int a[3][2], i cdef int a[3][2]
cdef int i
for i in xrange(3): for i in xrange(3):
a[i][0] = iu0[i] a[i][0] = iu0[i]
@ -697,7 +702,10 @@ cdef DTYPE_t C_line_of_sight_projection(DTYPE_t[:,:,:] density,
DTYPE_t min_distance, DTYPE_t min_distance,
DTYPE_t max_distance, DTYPE_t[:] shifter, int integrator_id) nogil except? 0: DTYPE_t max_distance, DTYPE_t[:] shifter, int integrator_id) nogil except? 0:
cdef DTYPE_t u[3], ifu0[3], u0[3], utot[3] cdef DTYPE_t u[3]
cdef DTYPE_t ifu0[3]
cdef DTYPE_t u0[3]
cdef DTYPE_t utot[3]
cdef int u_delta[3] cdef int u_delta[3]
cdef int iu0[3] cdef int iu0[3]
cdef int i cdef int i

View File

@ -4,14 +4,23 @@ import numpy as np
import numexpr as ne import numexpr as ne
class CubeFT(object): class CubeFT(object):
def __init__(self, L, N, max_cpu=-1): def __init__(self, L, N, max_cpu=-1, width=32):
if width==32:
fourier_type='complex64'
real_type='float32'
elif width==64:
fourier_type='complex128'
real_type='float64'
else:
raise ValueError("Invalid bitwidth (must be 32 or 64)")
self.N = N self.N = N
self.align = pyfftw.simd_alignment self.align = pyfftw.simd_alignment
self.L = float(L) self.L = float(L)
self.max_cpu = multiprocessing.cpu_count() if max_cpu < 0 else max_cpu self.max_cpu = multiprocessing.cpu_count() if max_cpu < 0 else max_cpu
self._dhat = pyfftw.n_byte_align_empty((self.N,self.N,self.N//2+1), self.align, dtype='complex64') self._dhat = pyfftw.n_byte_align_empty((self.N,self.N,self.N//2+1), self.align, dtype=fourier_type)
self._density = pyfftw.n_byte_align_empty((self.N,self.N,self.N), self.align, dtype='float32') self._density = pyfftw.n_byte_align_empty((self.N,self.N,self.N), self.align, dtype=real_type)
self._irfft = pyfftw.FFTW(self._dhat, self._density, axes=(0,1,2), direction='FFTW_BACKWARD', threads=self.max_cpu)#, normalize_idft=False) self._irfft = pyfftw.FFTW(self._dhat, self._density, axes=(0,1,2), direction='FFTW_BACKWARD', threads=self.max_cpu)#, normalize_idft=False)
self._rfft = pyfftw.FFTW(self._density, self._dhat, axes=(0,1,2), threads=self.max_cpu) #, normalize_idft=False) self._rfft = pyfftw.FFTW(self._density, self._dhat, axes=(0,1,2), threads=self.max_cpu) #, normalize_idft=False)

View File

@ -14,6 +14,7 @@ class SimulationBare(PySimulationBase):
self.positions = [q.copy() for q in s.getPositions()] if s.getPositions() is not None else None self.positions = [q.copy() for q in s.getPositions()] if s.getPositions() is not None else None
self.velocities = [q.copy() for q in s.getVelocities()] if s.getVelocities() is not None else None self.velocities = [q.copy() for q in s.getVelocities()] if s.getVelocities() is not None else None
self.identifiers = s.getIdentifiers().copy() if s.getIdentifiers() is not None else None self.identifiers = s.getIdentifiers().copy() if s.getIdentifiers() is not None else None
self.types = s.getTypes().copy() if s.getTypes() is not None else None
self.boxsize = s.getBoxsize() self.boxsize = s.getBoxsize()
self.time = s.getTime() self.time = s.getTime()
self.Hubble = s.getHubble() self.Hubble = s.getHubble()
@ -53,12 +54,16 @@ class SimulationBare(PySimulationBase):
self.positions = _safe_merge(self.positions, other.getPositions()) self.positions = _safe_merge(self.positions, other.getPositions())
self.velocities = _safe_merge(self.velocities, other.getVelocities()) self.velocities = _safe_merge(self.velocities, other.getVelocities())
self.identifiers = _safe_merge0(self.identifiers, other.getIdentifiers()) self.identifiers = _safe_merge0(self.identifiers, other.getIdentifiers())
self.types = _safe_merge0(self.types, other.getTypes())
try: try:
self.masses = _safe_merge0(self.masses, other.getMasses()) self.masses = _safe_merge0(self.masses, other.getMasses())
except Exception as e: except Exception as e:
warnings.warn("Unexpected exception: " + repr(e)); warnings.warn("Unexpected exception: " + repr(e));
self.masses = None self.masses = None
def getTypes(self):
return self.types
def getPositions(self): def getPositions(self):
return self.positions return self.positions

View File

@ -62,7 +62,7 @@ void computeInterpolatedField(MyTree *tree1, double boxsize, int Nres, double cx
{ {
double px = (rx)*boxsize/Nres-cx; double px = (rx)*boxsize/Nres-cx;
MyTree::coords c = { px, py, pz }; MyTree::coords c = { float(px), float(py), float(pz) };
double r2 = c[0]*c[0]+c[1]*c[1]+c[2]*c[2]; double r2 = c[0]*c[0]+c[1]*c[1]+c[2]*c[2];
if (r2 > rLimit2) if (r2 > rLimit2)
@ -179,7 +179,7 @@ int main(int argc, char **argv)
{ {
double px = (rx)*boxsize/Nres-cx; double px = (rx)*boxsize/Nres-cx;
MyTree::coords c = { px, py, pz }; MyTree::coords c = { float(px), float(py), float(pz) };
double r2 = c[0]*c[0]+c[1]*c[1]+c[2]*c[2]; double r2 = c[0]*c[0]+c[1]*c[1]+c[2]*c[2];
if (r2 > rLimit2) if (r2 > rLimit2)

View File

@ -75,7 +75,7 @@ int main()
cout << "iy=" << iy << endl; cout << "iy=" << iy << endl;
for (uint32_t ix = 0; ix < NX; ix++) for (uint32_t ix = 0; ix < NX; ix++)
{ {
MyTree::coords c = { 1.0*ix/NX, 1.0*iy/NX }; MyTree::coords c = { 1.0f*ix/NX, 1.0f*iy/NX };
smooth.fetchNeighbours(c); smooth.fetchNeighbours(c);
smooth.addGridSite(c); smooth.addGridSite(c);
} }
@ -92,7 +92,7 @@ int main()
cout << "iy=" << iy << endl; cout << "iy=" << iy << endl;
for (uint32_t ix = 0; ix < NX; ix++) for (uint32_t ix = 0; ix < NX; ix++)
{ {
MyTree::coords c = { 1.0*ix/NX, 1.0*iy/NX }; MyTree::coords c = { 1.0f*ix/NX, 1.0f*iy/NX };
smooth.fetchNeighbours(c, &state); smooth.fetchNeighbours(c, &state);
out.put(smooth.computeSmoothedValue(c, unit_fun, &state)); out.put(smooth.computeSmoothedValue(c, unit_fun, &state));

View File

@ -78,7 +78,7 @@ endif(YORICK_SUPPORT)
if (HDF5_FOUND) if (HDF5_FOUND)
set(CosmoTool_LIBS ${CosmoTool_LIBS} ${HDF5_LIBRARIES} ${HDF5_HL_LIBRARIES} ${HDF5_CXX_LIBRARIES} ${ZLIB}) set(CosmoTool_LIBS ${CosmoTool_LIBS} ${HDF5_LIBRARIES} ${HDF5_HL_LIBRARIES} ${HDF5_CXX_LIBRARIES} ${ZLIB})
include_directories(${HDF5_INCLUDE_DIRS}) include_directories(${HDF5_INCLUDE_DIR})
message(STATUS "CosmoTool_LIBS: ${CosmoTool_LIBS}") message(STATUS "CosmoTool_LIBS: ${CosmoTool_LIBS}")
endif (HDF5_FOUND) endif (HDF5_FOUND)

View File

@ -43,7 +43,6 @@ using namespace std;
using namespace CosmoTool; using namespace CosmoTool;
UnformattedRead::UnformattedRead(const string& fname) UnformattedRead::UnformattedRead(const string& fname)
throw(NoSuchFileException)
{ {
f = new ifstream(fname.c_str()); f = new ifstream(fname.c_str());
if (!*f) if (!*f)
@ -55,7 +54,6 @@ UnformattedRead::UnformattedRead(const string& fname)
} }
UnformattedRead::UnformattedRead(const char *fname) UnformattedRead::UnformattedRead(const char *fname)
throw(NoSuchFileException)
{ {
f = new ifstream(fname); f = new ifstream(fname);
if (!*f) if (!*f)
@ -100,7 +98,6 @@ void UnformattedRead::setCheckpointSize(CheckpointSize cs)
} }
void UnformattedRead::skip(int64_t off) void UnformattedRead::skip(int64_t off)
throw (InvalidUnformattedAccess)
{ {
if (checkPointAccum == 0 && checkPointRef == 0) if (checkPointAccum == 0 && checkPointRef == 0)
{ {
@ -119,7 +116,6 @@ void UnformattedRead::skip(int64_t off)
} }
void UnformattedRead::beginCheckpoint(bool bufferRecord) void UnformattedRead::beginCheckpoint(bool bufferRecord)
throw (InvalidUnformattedAccess,EndOfFileException)
{ {
if (checkPointAccum != 0) if (checkPointAccum != 0)
throw InvalidUnformattedAccess(); throw InvalidUnformattedAccess();
@ -140,7 +136,6 @@ void UnformattedRead::beginCheckpoint(bool bufferRecord)
} }
void UnformattedRead::endCheckpoint(bool autodrop) void UnformattedRead::endCheckpoint(bool autodrop)
throw (InvalidUnformattedAccess)
{ {
if (recordBuffer != 0) { if (recordBuffer != 0) {
delete[] recordBuffer; delete[] recordBuffer;
@ -169,7 +164,6 @@ void UnformattedRead::endCheckpoint(bool autodrop)
} }
void UnformattedRead::readOrderedBuffer(void *buffer, int size) void UnformattedRead::readOrderedBuffer(void *buffer, int size)
throw (InvalidUnformattedAccess)
{ {
if ((checkPointAccum+(uint64_t)size) > checkPointRef) if ((checkPointAccum+(uint64_t)size) > checkPointRef)
throw InvalidUnformattedAccess(); throw InvalidUnformattedAccess();
@ -190,7 +184,6 @@ void UnformattedRead::readOrderedBuffer(void *buffer, int size)
} }
double UnformattedRead::readReal64() double UnformattedRead::readReal64()
throw (InvalidUnformattedAccess)
{ {
union union
{ {
@ -204,7 +197,6 @@ double UnformattedRead::readReal64()
} }
float UnformattedRead::readReal32() float UnformattedRead::readReal32()
throw (InvalidUnformattedAccess)
{ {
union union
{ {
@ -218,7 +210,6 @@ float UnformattedRead::readReal32()
} }
uint32_t UnformattedRead::readUint32() uint32_t UnformattedRead::readUint32()
throw (InvalidUnformattedAccess)
{ {
union union
{ {
@ -232,7 +223,6 @@ uint32_t UnformattedRead::readUint32()
} }
int32_t UnformattedRead::readInt32() int32_t UnformattedRead::readInt32()
throw (InvalidUnformattedAccess)
{ {
union union
{ {
@ -246,7 +236,6 @@ int32_t UnformattedRead::readInt32()
} }
int64_t UnformattedRead::readInt64() int64_t UnformattedRead::readInt64()
throw (InvalidUnformattedAccess)
{ {
union union
{ {
@ -262,7 +251,6 @@ int64_t UnformattedRead::readInt64()
//// UnformattedWrite //// UnformattedWrite
UnformattedWrite::UnformattedWrite(const string& fname) UnformattedWrite::UnformattedWrite(const string& fname)
throw(NoSuchFileException)
{ {
f = new ofstream(fname.c_str()); f = new ofstream(fname.c_str());
if (!*f) if (!*f)
@ -274,7 +262,6 @@ UnformattedWrite::UnformattedWrite(const string& fname)
} }
UnformattedWrite::UnformattedWrite(const char *fname) UnformattedWrite::UnformattedWrite(const char *fname)
throw(NoSuchFileException)
{ {
f = new ofstream(fname); f = new ofstream(fname);
if (!*f) if (!*f)
@ -304,7 +291,6 @@ void UnformattedWrite::setCheckpointSize(CheckpointSize cs)
} }
void UnformattedWrite::beginCheckpoint() void UnformattedWrite::beginCheckpoint()
throw (InvalidUnformattedAccess,FilesystemFullException)
{ {
if (checkPointAccum != 0) if (checkPointAccum != 0)
throw InvalidUnformattedAccess(); throw InvalidUnformattedAccess();
@ -322,7 +308,6 @@ void UnformattedWrite::beginCheckpoint()
} }
void UnformattedWrite::endCheckpoint() void UnformattedWrite::endCheckpoint()
throw (InvalidUnformattedAccess,FilesystemFullException)
{ {
if (checkPointAccum == 0) if (checkPointAccum == 0)
throw InvalidUnformattedAccess(); throw InvalidUnformattedAccess();
@ -354,7 +339,6 @@ void UnformattedWrite::endCheckpoint()
} }
void UnformattedWrite::writeOrderedBuffer(void *buffer, int size) void UnformattedWrite::writeOrderedBuffer(void *buffer, int size)
throw (FilesystemFullException)
{ {
f->write((char *)buffer, size); f->write((char *)buffer, size);
@ -371,7 +355,6 @@ void UnformattedWrite::writeOrderedBuffer(void *buffer, int size)
} }
void UnformattedWrite::writeReal64(double d) void UnformattedWrite::writeReal64(double d)
throw (FilesystemFullException)
{ {
union union
{ {
@ -385,7 +368,6 @@ void UnformattedWrite::writeReal64(double d)
} }
void UnformattedWrite::writeReal32(float f) void UnformattedWrite::writeReal32(float f)
throw (FilesystemFullException)
{ {
union union
{ {
@ -399,7 +381,6 @@ void UnformattedWrite::writeReal32(float f)
} }
void UnformattedWrite::writeInt32(int32_t i) void UnformattedWrite::writeInt32(int32_t i)
throw (FilesystemFullException)
{ {
union union
{ {
@ -412,7 +393,6 @@ void UnformattedWrite::writeInt32(int32_t i)
} }
void UnformattedWrite::writeInt64(int64_t i) void UnformattedWrite::writeInt64(int64_t i)
throw (FilesystemFullException)
{ {
union union
{ {
@ -425,7 +405,6 @@ void UnformattedWrite::writeInt64(int64_t i)
} }
void UnformattedWrite::writeInt8(int8_t i) void UnformattedWrite::writeInt8(int8_t i)
throw (FilesystemFullException)
{ {
union { char b; int8_t i; } a; union { char b; int8_t i; } a;

View File

@ -67,10 +67,8 @@ namespace CosmoTool
{ {
public: public:
UnformattedRead(const std::string& fname) UnformattedRead(const std::string& fname);
throw (NoSuchFileException); UnformattedRead(const char *fname);
UnformattedRead(const char *fname)
throw (NoSuchFileException);
~UnformattedRead(); ~UnformattedRead();
// Todo implement primitive description // Todo implement primitive description
@ -79,30 +77,21 @@ namespace CosmoTool
uint64_t getBlockSize() const { return checkPointRef; } uint64_t getBlockSize() const { return checkPointRef; }
void beginCheckpoint(bool bufferRecord = false) void beginCheckpoint(bool bufferRecord = false);
throw (InvalidUnformattedAccess,EndOfFileException); void endCheckpoint(bool autodrop = false);
void endCheckpoint(bool autodrop = false)
throw (InvalidUnformattedAccess);
double readReal64() double readReal64();
throw (InvalidUnformattedAccess); float readReal32();
float readReal32() uint32_t readUint32();
throw (InvalidUnformattedAccess); int32_t readInt32();
uint32_t readUint32() int64_t readInt64();
throw (InvalidUnformattedAccess);
int32_t readInt32()
throw (InvalidUnformattedAccess);
int64_t readInt64()
throw (InvalidUnformattedAccess);
void skip(int64_t off) void skip(int64_t off);
throw (InvalidUnformattedAccess);
int64_t position() const; int64_t position() const;
void seek(int64_t pos); void seek(int64_t pos);
void readOrderedBuffer(void *buffer, int size) void readOrderedBuffer(void *buffer, int size);
throw (InvalidUnformattedAccess);
protected: protected:
bool swapOrdering; bool swapOrdering;
CheckpointSize cSize; CheckpointSize cSize;
@ -117,34 +106,24 @@ namespace CosmoTool
{ {
public: public:
UnformattedWrite(const std::string& fname) UnformattedWrite(const std::string& fname);
throw (NoSuchFileException); UnformattedWrite(const char *fname);
UnformattedWrite(const char *fname)
throw (NoSuchFileException);
~UnformattedWrite(); ~UnformattedWrite();
// Todo implement primitive description // Todo implement primitive description
void setOrdering(Ordering o); void setOrdering(Ordering o);
void setCheckpointSize(CheckpointSize cs); void setCheckpointSize(CheckpointSize cs);
void beginCheckpoint() void beginCheckpoint();
throw (FilesystemFullException,InvalidUnformattedAccess); void endCheckpoint();
void endCheckpoint()
throw (FilesystemFullException,InvalidUnformattedAccess);
void writeReal64(double d) void writeReal64(double d);
throw (FilesystemFullException); void writeReal32(float f);
void writeReal32(float f) void writeInt32(int32_t i);
throw (FilesystemFullException); void writeInt64(int64_t i);
void writeInt32(int32_t i) void writeInt8(int8_t c);
throw (FilesystemFullException);
void writeInt64(int64_t i)
throw (FilesystemFullException);
void writeInt8(int8_t c)
throw (FilesystemFullException);
void writeOrderedBuffer(void *buffer, int size) void writeOrderedBuffer(void *buffer, int size);
throw(FilesystemFullException);
protected: protected:
bool swapOrdering; bool swapOrdering;
CheckpointSize cSize; CheckpointSize cSize;

View File

@ -66,7 +66,6 @@ Interpolate::~Interpolate()
} }
double Interpolate::compute(double x) double Interpolate::compute(double x)
throw (InvalidRangeException)
{ {
double y; double y;
@ -85,7 +84,6 @@ double Interpolate::compute(double x)
} }
double Interpolate::compute(double x) const double Interpolate::compute(double x) const
throw (InvalidRangeException)
{ {
double y; double y;
@ -107,7 +105,6 @@ double Interpolate::compute(double x) const
double Interpolate::derivative(double x) double Interpolate::derivative(double x)
throw (InvalidRangeException)
{ {
double y, dy, x0 = x; double y, dy, x0 = x;
@ -199,7 +196,6 @@ Interpolate CosmoTool::buildFromVector(const InterpolatePairs& v)
} }
Interpolate CosmoTool::buildInterpolateFromFile(const char *fname) Interpolate CosmoTool::buildInterpolateFromFile(const char *fname)
throw (NoSuchFileException)
{ {
vector<MyPair> allData; vector<MyPair> allData;
ifstream f(fname); ifstream f(fname);
@ -239,7 +235,6 @@ Interpolate CosmoTool::buildInterpolateFromFile(const char *fname)
Interpolate CosmoTool::buildInterpolateFromColumns(const char *fname, uint32_t col1, uint32_t col2, bool logx, Interpolate CosmoTool::buildInterpolateFromColumns(const char *fname, uint32_t col1, uint32_t col2, bool logx,
bool logy) bool logy)
throw (NoSuchFileException,InvalidRangeException)
{ {
vector<MyPair> allData; vector<MyPair> allData;
ifstream f(fname); ifstream f(fname);

View File

@ -54,12 +54,9 @@ namespace CosmoTool
bool logx = false, bool logy = false); bool logx = false, bool logy = false);
~Interpolate(); ~Interpolate();
double compute(double x) double compute(double x);
throw (InvalidRangeException); double compute(double x) const;
double compute(double x) const double derivative(double x);
throw (InvalidRangeException);
double derivative(double x)
throw (InvalidRangeException);
const Interpolate& operator=(const Interpolate& a); const Interpolate& operator=(const Interpolate& a);
@ -77,10 +74,8 @@ namespace CosmoTool
typedef std::vector< std::pair<double,double> > InterpolatePairs; typedef std::vector< std::pair<double,double> > InterpolatePairs;
Interpolate buildInterpolateFromFile(const char *fname) Interpolate buildInterpolateFromFile(const char *fname);
throw (NoSuchFileException); Interpolate buildInterpolateFromColumns(const char *fname, uint32_t col1, uint32_t col2, bool logx = false, bool logy = false);
Interpolate buildInterpolateFromColumns(const char *fname, uint32_t col1, uint32_t col2, bool logx = false, bool logy = false)
throw (NoSuchFileException,InvalidRangeException);
Interpolate buildFromVector(const InterpolatePairs& v); Interpolate buildFromVector(const InterpolatePairs& v);