Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
Is there any way to call a fast implementation of expm1 from GNU Fortran?
Ideally, it would be great to have a function to calculate (exp(x)-1)/x directly to avoid extra check for zero argument.
Elemental version of expm1 would be especially helpful.
This is how it's called from libm:
use, intrinsic :: iso_c_binding, only: c_double
implicit none
interface
real(c_double) function expm1(x) bind(c, name='expm1')
import c_double
real(c_double), intent(in), value :: x
end function expm1
end interface
print*, expm1(3.4d0)
end program
If the glibc source code for the function does not look too discouraging then you might wish to translate it into Fortran in order to make it elemental (if by elemental you meant the Fortran keyword).
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 3 years ago.
Improve this question
Is there a source code for a fast implementation of natural logarithm, for __m256 type, for AVX?
There is fmath, but it only works for __m128
Glibc has AVX[-512] SIMD log and logf implementations in the github repository: sysdeps/x86_64/fpu/multiarch. It relies on a lot of support code, like polynomial coefficient data, macros, support functions, etc. Much of this is in the parent fpu directory.
GNU libc's license is LGPLv2, so you can dynamically link it from any software, but only copy the source into GPL-compatible projects.
Agner Fog's Vector Class Library (VCL) is now Apache-licensed, and also has some SIMD math functions. It can be used with __m256, implicitly converting to/from its internal Vec8f type.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
Is there a tool that converts C++ code into fortran? Please state any possible deficiency of the tool you use.
I know it sounds silly but I do have a C++ code that calls a big Fortran code inside and I need to to use OpenMP. I am trying to keep the parallel region only inside Fortran (because there are many COMMON blocks and EQUIVALENCEs used) so I have to translate a few hundreds of lines of C++ functions to Fortran.
Depending on the compiler (such as the GNU compilers), you're actually able to compile C, C++, Fortran, etc. code together. This is so you don't actually have to translate or rewrite that code. C++ Forum Answer
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
Is there an implementation callable from C or C++ that allows the evaluation of the generalized hypergeometric function pFq(a1,...,ap; b1,...,bp; x)?
I tried GSL and Boost, but I don't think the generalized function is available in either of those libraries.
I believe the Arb library, a C library for arbitrary-precision floating-point ball arithmetic developed by the creator of mpmath, now provides an implementation.
I would suggest using this python library for the functions you need. It seems like it has it.
The trick however is you need to be able to call a python script from C++. For that you can use a boost component.
This seems like the easiest solution, even if it is possibly inefficient.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed last year.
Improve this question
I need to port a piece of code from matlab into C or C++. Matlab implementation of the code extensively use reshape and permute functions to manipulate the layout of multidimensional arrays. Is there any library in c or c++ to get effect of these two matlab routines. Any suggestion would be helpful.
You can use OpenCV library, which contains similar Mat::reshape() routines to do transforms and permutations.
If someone has found the answer for the Matlab permute function I am interrested.
I think the reshape can be done with boost::multi_array::reshape.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
How do I get the contents of a directory in Fortran 95?
shure if we have all the files in the 'inFiles' folder, we first find out how many are there and then we read their names into an array, check this out:
real :: r
integer :: i,reason,NstationFiles,iStation
character(LEN=100), dimension(:), allocatable :: stationFileNames
! get the files
call system('ls ./inFiles > fileContents.txt')
open(31,FILE='fileContents.txt',action="read")
!how many
i = 0
do
read(31,FMT='(a)',iostat=reason) r
if (reason/=0) EXIT
i = i+1
end do
NstationFiles = i
write(verb,'(a,I0)') "Number of station files: " , NstationFiles
allocate(stationFileNames(NstationFiles))
rewind(31)
do i = 1,NstationFiles
read(31,'(a)') stationFileNames(i)
! write(verb,'(a)') trim(stationFileNames(i))
end do
close(31)
To be pedantic, you don't. There's no intrinsic or such in Fortran 95 that helps you.
On a POSIX system and a recent Fortran compiler, you can use ISO_C_BINDING to create interfaces to the POSIX opendir() and readdir() functions (or readdir_r() if you need thread safety), which allow you to iterate over the directory entries.
There is no concept of a directory in Fortran, as such. It reads files. (There are some processors that don't even have a concept of directory).
With that being said, the easiest way would be with SYSTEM. Depends on what you want with that after ...