ParaMonte Fortran 2.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
pm_polynomial::getPolyVal Interface Reference

Generate and return the value of the polynomial of arbitrary degree whose coefficients are specified by the user in the order of increasing power.
More...

Detailed Description

Generate and return the value of the polynomial of arbitrary degree whose coefficients are specified by the user in the order of increasing power.

See the documentation of pm_polynomial for details of the implementation.

Parameters
[in]coef: The input array of,
  • type complex of the same kind as the kind of the input x of type complex, or
  • type real of the same kind as the kind of the input x of type complex, or
  • type real of the same kind as the kind of the input x of type real,
containing the coefficients of the polynomial in the order of increasing power.
By definition, the degree of the polynomial is size(coef) - 1.
[in]x: The input scalar of,
  • type complex of kind any supported by the processor (e.g., CK, CK32, CK64, or CK128),
  • type real of kind any supported by the processor (e.g., RK, RK32, RK64, or RK128),
representing the point at which the polynomial must be computed.
Returns
poly : The output scalar of the same type and kind as the input x containing the polynomial value at the specified point.


Possible calling interfaces

poly = getPolyVal(coef(:), x)
poly(1:size(x)) = getPolyVal(coef(:), x(:))
Generate and return the value of the polynomial of arbitrary degree whose coefficients are specified ...
This module contains procedures and generic interfaces for performing various mathematical operations...
Warning
The condition 0 < size(coef) must hold for the corresponding input arguments.
This condition is verified only if the library is built with the preprocessor macro CHECK_ENABLED=1.
The pure procedure(s) documented herein become impure when the ParaMonte library is compiled with preprocessor macro CHECK_ENABLED=1.
By default, these procedures are pure in release build and impure in debug and testing builds.
Note
The current interface requirements of either,
  1. (complex :: coef, complex :: x), or
  2. (real :: coef, complex :: x), or
  3. (real :: coef, real :: x)
are in line with the fact that polynomial coefficients of type real frequently have complex roots.
In particular, the interface (real :: coef, complex :: x) allows seamless integration of the polynomial evaluations of this module with various polynomial root-finding algorithm of the ParaMonte library.
See also
getPolyRoot
setPolyRoot


Example usage

1program example
2
3 use pm_kind, only: SK, IK, LK, RKH
5 use pm_io, only: display_type
6
7 implicit none
8
9 type(display_type) :: disp
10 disp = display_type(file = "main.out.F90")
11
12 block
13 use pm_kind, only: TKG => RKH ! all processor kinds are supported.
14 call disp%skip()
15 call disp%show("getPolyVal([real(TKG) :: 1, 3, 0, 2], x = 2._TKG) ! 23.")
16 call disp%show( getPolyVal([real(TKG) :: 1, 3, 0, 2], x = 2._TKG) )
17 call disp%skip()
18 call disp%show("getPolyVal([real(TKG) :: -19.0, 7.0, -4.0, 6.0], x = 3._TKG) ! 128.")
19 call disp%show( getPolyVal([real(TKG) :: -19.0, 7.0, -4.0, 6.0], x = 3._TKG) )
20 call disp%skip()
21 call disp%show("getPolyVal([real(TKG) :: -19.0, 7.0, -4.0, 6.0], x = (3._TKG, 0._TKG)) ! (128., 0.)")
22 call disp%show( getPolyVal([real(TKG) :: -19.0, 7.0, -4.0, 6.0], x = (3._TKG, 0._TKG)) )
23 call disp%skip()
24 end block
25
26 block
27 use pm_kind, only: TKG => RKS ! all processor kinds are supported.
28 call disp%skip()
29 call disp%show("getPolyVal([complex(TKG) :: (+2., +4.), (+24., +12.), (-28., +36.), (-15., +0.), (+24., -42.), (-7., +0.)], x = (2._TKG, -2._TKG))")
30 call disp%show( getPolyVal([complex(TKG) :: (+2., +4.), (+24., +12.), (-28., +36.), (-15., +0.), (+24., -42.), (-7., +0.)], x = (2._TKG, -2._TKG)) )
31 call disp%skip()
32 end block
33
34end program example
This is a generic method of the derived type display_type with pass attribute.
Definition: pm_io.F90:11726
This is a generic method of the derived type display_type with pass attribute.
Definition: pm_io.F90:11508
This module contains classes and procedures for input/output (IO) or generic display operations on st...
Definition: pm_io.F90:252
type(display_type) disp
This is a scalar module variable an object of type display_type for general display.
Definition: pm_io.F90:11393
This module defines the relevant Fortran kind type-parameters frequently used in the ParaMonte librar...
Definition: pm_kind.F90:268
integer, parameter LK
The default logical kind in the ParaMonte library: kind(.true.) in Fortran, kind(....
Definition: pm_kind.F90:541
integer, parameter IK
The default integer kind in the ParaMonte library: int32 in Fortran, c_int32_t in C-Fortran Interoper...
Definition: pm_kind.F90:540
integer, parameter SK
The default character kind in the ParaMonte library: kind("a") in Fortran, c_char in C-Fortran Intero...
Definition: pm_kind.F90:539
integer, parameter RKH
The scalar integer constant of intrinsic default kind, representing the highest-precision real kind t...
Definition: pm_kind.F90:858
integer, parameter RKS
The single-precision real kind in Fortran mode. On most platforms, this is an 32-bit real kind.
Definition: pm_kind.F90:567
Generate and return an object of type display_type.
Definition: pm_io.F90:10282

Example Unix compile command via Intel ifort compiler
1#!/usr/bin/env sh
2rm main.exe
3ifort -fpp -standard-semantics -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
4./main.exe

Example Windows Batch compile command via Intel ifort compiler
1del main.exe
2set PATH=..\..\..\lib;%PATH%
3ifort /fpp /standard-semantics /O3 /I:..\..\..\include main.F90 ..\..\..\lib\libparamonte*.lib /exe:main.exe
4main.exe

Example Unix / MinGW compile command via GNU gfortran compiler
1#!/usr/bin/env sh
2rm main.exe
3gfortran -cpp -ffree-line-length-none -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
4./main.exe

Example output
1
2getPolyVal([real(TKG) :: 1, 3, 0, 2], x = 2._TKG) ! 23.
3+23.0000000000000000000000000000000000
4
5getPolyVal([real(TKG) :: -19.0, 7.0, -4.0, 6.0], x = 3._TKG) ! 128.
6+128.000000000000000000000000000000000
7
8getPolyVal([real(TKG) :: -19.0, 7.0, -4.0, 6.0], x = (3._TKG, 0._TKG)) ! (128., 0.)
9(+128.000000000000000000000000000000000, +0.00000000000000000000000000000000000)
10
11
12getPolyVal([complex(TKG) :: (+2., +4.), (+24., +12.), (-28., +36.), (-15., +0.), (+24., -42.), (-7., +0.)], x = (2._TKG, -2._TKG))
13(-38.0000000, +2236.00000)
14
15
Test:
test_pm_polynomial


Final Remarks


If you believe this algorithm or its documentation can be improved, we appreciate your contribution and help to edit this page's documentation and source file on GitHub.
For details on the naming abbreviations, see this page.
For details on the naming conventions, see this page.
This software is distributed under the MIT license with additional terms outlined below.

  1. If you use any parts or concepts from this library to any extent, please acknowledge the usage by citing the relevant publications of the ParaMonte library.
  2. If you regenerate any parts/ideas from this library in a programming environment other than those currently supported by this ParaMonte library (i.e., other than C, C++, Fortran, MATLAB, Python, R), please also ask the end users to cite this original ParaMonte library.

This software is available to the public under a highly permissive license.
Help us justify its continued development and maintenance by acknowledging its benefit to society, distributing it, and contributing to it.

Author:
Fatemeh Bagheri, Tuesday 11:34 PM, August 10, 2021, Dallas, TX

Definition at line 517 of file pm_polynomial.F90.


The documentation for this interface was generated from the following file: