Fortran Does Fortran have a built-in function to calculate the determinant?

Click For Summary
Fortran does not include built-in functions for calculating the determinant of a matrix, relying instead on external libraries for such functionality. The only intrinsic matrix operations in Fortran 90 are MATMUL, TRANSPOSE, and DOT_PRODUCT. Historically, Fortran programmers have utilized libraries like the IMSL numerical math library, which includes a det() function, to handle complex numerical calculations efficiently. This approach allows developers to focus on broader programming challenges rather than debugging custom functions. Notable libraries such as LINPACK and EISPACK, which were later merged into LAPACK, provide advanced numerical techniques for various matrix types. The separation of libraries from the core language enhances flexibility and allows for cross-language compatibility, as many modern programming languages, including Python, leverage these external libraries.
Eclair_de_XII
Messages
1,082
Reaction score
91
TL;DR
Some Google-searching has led me to believe that Fortran does not have a built-in function for calculating the determinant of a given matrix. I've found only source codes and external libraries that have been written for this purpose. Does Fortran just not have any functions that calculate determinants directly? If it does not, then why not?
Fortran:
program main
! use ! some library that defines the function to calculate the determinant of a given matrix
implicit none
real,dimension(2,2)::A
real::det_val
A(1,1)=1
A(2,2)=1
A(2,1)=0
A(1,2)=0
! det_val=det(A)
print *,det_val ! Should print 1.
end program main
 
Technology news on Phys.org
Eclair_de_XII said:
Does Fortran just not have any functions that calculate determinants directly? If it does not, then why not?
The only Fortran 90 matrix intrinsics are; MATMUL, TRANSPOSE, and DOT_PRODUCT.
Other intrinsic functions are not usually needed, and so are better loaded from an external library.
 
In general, no FORTRAN does not have that as a built-in. Instead the functionality is provided by a math library like the IMSL numerical math library and its det() function.

https://help.imsl.com/fortran/6.0/math/default.htm?turl=imslfortrannumericalmathlibrary.htm

https://help.imsl.com/fortran/6.0/math/default.htm?turl=imslfortrannumericalmathlibrary.htm

Experienced programmers will tend to use library functions over developing their own as it saves time in debugging and allows one to look at the bigger programming issues of a project.
 
Long ago (1960s and 1970s), the FORTRAN programmers used libraries to assist in their numerical calculations. The IBM Scientific Subroutine Package (SSP) was a very well-programmed and documented set of subroutines that was bundled in with their sales packages.
The IMSL (International Mathematics and Statistics Library) for FORTRAN was published in 1970.
Then LINPACK and EISPACK became available for use on supercomputers (of that era).
There are a large variety of specialized needs (huge matrices, sparce matrices, complex matrices, etc) that were addressed by different well-documented libraries using advanced (for that era) numerical techniques.
It is conceivable that modern compilers for a language would have the ability to use the correct technique for a special situation, but I would verify that before I counted on it.
 
  • Informative
  • Like
Likes jedishrfu and berkeman
Let me add that LINPACK and EISPACK were merged into LAPACK (Linear Algebra PACKage). The source code (Fortran 90) is available at http://www.netlib.org/lapack/
 
  • Like
Likes jedishrfu and FactChecker
DrClaude said:
Let me add that LINPACK and EISPACK were merged into LAPACK (Linear Algebra PACKage). The source code (Fortran 90) is available at http://www.netlib.org/lapack/
DrClaude's example illustrates the kind of flexibility that you want in libraries. If you make the functions intrinsic to the language, you have less future flexibility. That is one reason to keep libraries separate from the programming language.

Another reason is that external libraries can be shared by programs written in many languages.
Python is very popular today, but if you dig into the details of Python packages, you may find external libraries written in C or FORTRAN.
 
  • Like
Likes FactChecker and jedishrfu
Learn If you want to write code for Python Machine learning, AI Statistics/data analysis Scientific research Web application servers Some microcontrollers JavaScript/Node JS/TypeScript Web sites Web application servers C# Games (Unity) Consumer applications (Windows) Business applications C++ Games (Unreal Engine) Operating systems, device drivers Microcontrollers/embedded systems Consumer applications (Linux) Some more tips: Do not learn C++ (or any other dialect of C) as a...

Similar threads

  • · Replies 20 ·
Replies
20
Views
3K
  • · Replies 25 ·
Replies
25
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 4 ·
Replies
4
Views
8K
  • · Replies 5 ·
Replies
5
Views
1K
  • · Replies 8 ·
Replies
8
Views
2K