Skip to content

Commit

Permalink
Merge pull request #48 from devernay/cmakelongdouble
Browse files Browse the repository at this point in the history
also build for long double if available
  • Loading branch information
devernay authored Dec 22, 2020
2 parents 11a0ef4 + dc2e4de commit 9ff8150
Show file tree
Hide file tree
Showing 27 changed files with 6,464 additions and 11 deletions.
36 changes: 29 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,32 @@ set (cminpack_srcs
set (cminpack_hdrs
cminpack.h minpack.h)

include (CheckTypeSize)
check_type_size ("double" SIZEOF_DOUBLE)
check_type_size ("long double" SIZEOF_LONG_DOUBLE)

if (${CMINPACK_PRECISION} STREQUAL s)
message (STATUS "Building for single precision (float).")
set (cminpack_libs cminpacks)
elseif (${CMINPACK_PRECISION} STREQUAL d)
message (STATUS "Building for double precision (double).")
set (cminpack_libs cminpack)
elseif (${CMINPACK_PRECISION} STREQUAL ld)
set (cminpack_libs cminpackld)
if (${SIZEOF_LONG_DOUBLE} GREATER ${SIZEOF_DOUBLE})
message (STATUS "Building for extended precision (long double).")
set (cminpack_libs cminpackld)
else ()
# Microsoft Visual C++ for x86 makes long double a synonym for double
message (FATAL_ERROR "Compiler does not support long double, or long double is a synonym of double")
endif ()
elseif (${CMINPACK_PRECISION} STREQUAL all)
set (cminpack_libs cminpacks;cminpack)
if (${SIZEOF_LONG_DOUBLE} GREATER ${SIZEOF_DOUBLE})
message (STATUS "Building for single precision (float), double precision (double) and extended precision (long double).")
set (cminpack_libs cminpacks;cminpack;cminpackld)
else ()
message (STATUS "Building for single precision (float) and double precision (double).")
set (cminpack_libs cminpacks;cminpack)
endif ()
endif ()

if (BUILD_SHARED_LIBS)
Expand Down Expand Up @@ -114,11 +132,15 @@ foreach (cminpack_lib ${cminpack_libs})

# Link with CBLAS library if requested
if (USE_BLAS)
find_package (CBLAS)
if (CBLAS_FOUND)
target_link_libraries (${cminpack_lib} PUBLIC ${CBLAS_LIBRARIES})
set_target_properties (${cminpack_lib} PROPERTIES LINK_FLAGS "${CBLAS_LINKER_FLAGS}")
target_compile_definitions (${cminpack_lib} PUBLIC USE_CBLAS)
if (${cminpack_lib} STREQUAL cminpackld)
message (WARNING "BLAS cannot be used for the extended precision version")
else ()
find_package (CBLAS)
if (CBLAS_FOUND)
target_link_libraries (${cminpack_lib} PUBLIC ${CBLAS_LIBRARIES})
set_target_properties (${cminpack_lib} PROPERTIES LINK_FLAGS "${CBLAS_LINKER_FLAGS}")
target_compile_definitions (${cminpack_lib} PUBLIC USE_CBLAS)
endif ()
endif ()
endif ()

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ History
------

* version 1.3.8 (//2021):
- cmake now builds by default the single-, double-, and extended-precision versions #45 #48
- Avoid promoting to doubles in all operations for the single-precision version #47

* version 1.3.7 (09/12/2020):
- Makefile cleanups #11
Expand Down
311 changes: 311 additions & 0 deletions examples/ref/ldchkdrvc.ref
Original file line number Diff line number Diff line change
@@ -0,0 +1,311 @@



problem 1 with dimension 2 is F


first function vector

2.0770000e+00 -2.8292900e+00


function difference vector

-3.5462622e-10 1.0526366e-08


error vector

3.0078824e-02 9.2433674e-01



problem 2 with dimension 4 is F


first function vector

-8.1070000e+00 -1.6859953e+00 1.8741610e+00 1.5952160e+01


function difference vector

4.7260447e-09 -5.5515146e-10 -7.9065710e-10 1.0505208e-08


error vector

1.0000000e+00 1.0000000e+00 4.6869594e-02 9.9092222e-01



problem 3 with dimension 2 is F


first function vector

1.0777100e+03 3.0019279e-01


function difference vector

7.1037855e-07 -1.5595059e-10


error vector

0.0000000e+00 0.0000000e+00



problem 4 with dimension 4 is T


first function vector

-5.4127112e+03 -1.9649458e+03 -4.8718278e+03 -1.7769432e+03


function difference vector

5.1311172e-06 1.1789170e-06 4.6181002e-06 1.0625044e-06


error vector

9.6545728e-01 1.0000000e+00 9.7164712e-01 1.0000000e+00



problem 5 with dimension 3 is F


first function vector

-5.0987696e+01 -1.1441658e+00 1.2300000e-01


function difference vector

4.0500487e-10 -2.9159797e-09 4.0500487e-11


error vector

1.0000000e+00 0.0000000e+00 1.0000000e+00



problem 6 with dimension 9 is F


first function vector

-5.7930631e+00 -3.3390751e+01 -3.4683179e+01 -3.6368725e+01 -3.7947668e+01
-3.9431326e+01 -4.0834243e+01 -4.2170791e+01 -4.3453299e+01


function difference vector

9.9768537e-09 1.8235860e-08 2.3137328e-08 2.6977852e-08 3.0131870e-08
3.2820793e-08 3.5178894e-08 3.7293188e-08 3.9222860e-08


error vector

0.0000000e+00 3.6958717e-02 4.8655594e-02 5.8177865e-02 6.5994814e-02
7.2648566e-02 7.8448546e-02 8.3592559e-02 8.8215713e-02



problem 7 with dimension 7 is F


first function vector

3.5142857e-02 -4.5634667e-02 2.1936396e-01 2.1302816e-01 2.5865828e-01
2.3088814e-01 5.9195986e-02


function difference vector

3.4084382e-10 4.5526348e-10 5.2523568e-10 1.1820072e-09 2.1443179e-09
3.4838991e-09 4.6673111e-09


error vector

0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00
0.0000000e+00 0.0000000e+00



problem 8 with dimension 10 is T


first function vector

-5.6230000e+00 -5.3770000e+00 -5.6230000e+00 -5.3770000e+00 -5.6230000e+00
-5.3770000e+00 -5.6230000e+00 -5.3770000e+00 -5.6230000e+00 -9.9928526e-01


function difference vector

1.7704969e-09 1.8514979e-09 1.7704969e-09 1.8514979e-09 1.7704969e-09
1.8514979e-09 1.7704969e-09 1.8514979e-09 1.7704969e-09 2.3534345e-12


error vector

9.9846705e-01 9.9261857e-01 9.9846705e-01 9.9261857e-01 9.9846705e-01
9.9261857e-01 9.9846705e-01 9.9261857e-01 9.9846705e-01 1.0000000e+00



problem 9 with dimension 10 is F


first function vector

-3.8266208e-01 4.8185552e-01 -5.0497059e-01 4.8364359e-01 -5.0327111e-01
4.8731586e-01 -4.9982317e-01 4.9409864e-01 -4.9324735e-01 3.8308496e-01


function difference vector

1.2760182e-10 -1.5641890e-10 1.6863172e-10 -1.5586223e-10 1.6922236e-10
-1.5553038e-10 1.6982190e-10 -1.5572015e-10 1.4352145e-10 -6.2281313e-11


error vector

2.8219889e-02 1.3376113e-01 2.0444304e-02 6.8047375e-02 1.3641636e-02
6.1770151e-02 1.5282455e-02 8.5364343e-02 2.6626937e-02 1.0200768e-01



problem 10 with dimension 10 is F


first function vector

-1.6796677e-01 4.6728538e-02 -2.2043167e-01 1.7378706e-02 -2.2845451e-01
2.8983382e-02 -2.0089459e-01 6.9050605e-02 -1.5510284e-01 1.1399106e-01


function difference vector

7.2803384e-11 1.8004944e-11 1.1962540e-10 5.2614146e-11 1.4146512e-10
6.1093737e-11 1.3625274e-10 4.1589837e-11 1.0264708e-10 2.0182886e-11


error vector

0.0000000e+00 6.8687797e-03 0.0000000e+00 0.0000000e+00 0.0000000e+00
0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 3.6993619e-02



problem 11 with dimension 10 is F


first function vector

1.4839305e-01 -4.6502477e-02 1.4892203e-01 3.0207835e-03 1.4945101e-01
5.2544044e-02 1.4997998e-01 1.0206730e-01 1.5050896e-01 1.5159056e-01


function difference vector

7.2579293e-11 4.1193132e-11 7.2231127e-11 7.3671153e-11 7.1882961e-11
1.0614917e-10 7.1534795e-11 1.3862719e-10 7.1186630e-11 1.7110521e-10


error vector

0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00
0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00



problem 12 with dimension 10 is F


first function vector

-1.0878876e+05 -2.1757715e+05 -3.2636603e+05 -4.3515443e+05 -5.4394331e+05
-6.5273170e+05 -7.6152058e+05 -8.7030898e+05 -9.7909786e+05 -1.0878862e+06


function difference vector

4.9710803e-05 9.9421397e-05 1.4913183e-04 1.9884242e-04 2.4855286e-04
2.9826345e-04 3.4797389e-04 3.9768448e-04 4.4739493e-04 4.9710551e-04


error vector

1.6738365e-02 1.6738288e-02 1.6738331e-02 1.6738301e-02 1.6738324e-02
1.6738305e-02 1.6738321e-02 1.6738307e-02 1.6738319e-02 1.6738308e-02



problem 13 with dimension 10 is T


first function vector

-3.1372580e+00 1.9974200e-01 -2.2602580e+00 1.9974200e-01 -2.2602580e+00
1.9974200e-01 -2.2602580e+00 1.9974200e-01 -2.2602580e+00 -2.0462580e+00


function difference vector

2.1927938e-09 7.7000843e-10 1.9040221e-09 7.7000843e-10 1.9040221e-09
7.7000843e-10 1.9040221e-09 7.7000843e-10 1.9040221e-09 1.5095539e-09


error vector

1.0000000e+00 9.6830903e-01 9.7919715e-01 9.6830903e-01 9.7919715e-01
9.6830903e-01 9.7919715e-01 9.6830903e-01 9.7919715e-01 1.0000000e+00



problem 14 with dimension 10 is F


first function vector

-8.2193683e+00 -4.4028887e+00 -8.2496263e+00 -4.4331467e+00 -8.2798843e+00
-4.4634047e+00 -8.1720133e+00 -4.4634047e+00 -8.1720133e+00 -4.3252757e+00


function difference vector

7.9522463e-09 4.8305583e-09 8.6307170e-09 5.5090291e-09 9.3091878e-09
6.1874998e-09 9.5269217e-09 6.1874998e-09 9.5269217e-09 5.7267630e-09


error vector

0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00
0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00
summary of 14 tests of chkder

nprob n status errmin errmax

1 2 F 3.0078824e-02 9.2433674e-01
2 4 F 4.6869594e-02 1.0000000e+00
3 2 F 0.0000000e+00 0.0000000e+00
4 4 T 9.6545728e-01 1.0000000e+00
5 3 F 0.0000000e+00 1.0000000e+00
6 9 F 0.0000000e+00 8.8215713e-02
7 7 F 0.0000000e+00 0.0000000e+00
8 10 T 9.9261857e-01 1.0000000e+00
9 10 F 1.3641636e-02 1.3376113e-01
10 10 F 0.0000000e+00 3.6993619e-02
11 10 F 0.0000000e+00 0.0000000e+00
12 10 F 1.6738288e-02 1.6738365e-02
13 10 T 9.6830903e-01 1.0000000e+00
14 10 F 0.0000000e+00 0.0000000e+00
Loading

0 comments on commit 9ff8150

Please sign in to comment.