msl.examples.loadlib.fortran64 module

Communicates with fortran_lib32 via the Fortran32 class.

Example of a module that can be executed within a 64-bit Python interpreter which can communicate with a 32-bit library, fortran_lib32, that is hosted by a 32-bit Python server, fortran32. A 64-bit process cannot load a 32-bit library and therefore inter-process communication is used to interact with a 32-bit library from a 64-bit process.

Fortran64 is the 64-bit client and Fortran32 is the 32-bit server for inter-process communication.

class msl.examples.loadlib.fortran64.Fortran64

Bases: Client64

Communicates with the 32-bit FORTRAN fortran_lib32 library.

This class demonstrates how to communicate with a 32-bit FORTRAN library if an instance of this class is created within a 64-bit Python interpreter.

sum_8bit(a, b)

Send a request to add two 8-bit signed integers.

See the corresponding 32-bit sum_8bit() method.

Parameters:
  • a (int) – First 8-bit signed integer.

  • b (int) – Second 8-bit signed integer.

Returns:

The sum of a and b.

Return type:

int

sum_16bit(a, b)

Send a request to add two 16-bit signed integers.

See the corresponding 32-bit sum_16bit() method.

Parameters:
  • a (int) – First 16-bit signed integer.

  • b (int) – Second 16-bit signed integer.

Returns:

The sum of a and b.

Return type:

int

sum_32bit(a, b)

Send a request to add two 32-bit signed integers.

See the corresponding 32-bit sum_32bit() method.

Parameters:
  • a (int) – First 32-bit signed integer.

  • b (int) – Second 32-bit signed integer.

Returns:

The sum of a and b.

Return type:

int

sum_64bit(a, b)

Send a request to add two 64-bit signed integers.

See the corresponding 32-bit sum_64bit() method.

Parameters:
  • a (int) – First 64-bit signed integer.

  • b (int) – Second 64-bit signed integer.

Returns:

The sum of a and b.

Return type:

int

multiply_float32(a, b)

Send a request to multiply two FORTRAN floating-point numbers.

See the corresponding 32-bit multiply_float32() method.

Parameters:
  • a (float) – First floating-point number.

  • b (float) – Second floating-point number.

Returns:

The product of a and b.

Return type:

float

multiply_float64(a, b)

Send a request to multiply two FORTRAN double-precision numbers.

See the corresponding 32-bit multiply_float64() method.

Parameters:
  • a (float) – First double-precision number.

  • b (float) – Second double-precision number.

Returns:

The product of a and b.

Return type:

float

is_positive(a)

Returns whether the value of the input argument is > 0.

See the corresponding 32-bit is_positive() method.

Parameters:

a (float) – Double-precision number.

Returns:

Whether the value of a is > 0.

Return type:

bool

add_or_subtract(a, b, do_addition)

Add or subtract two integers.

See the corresponding 32-bit add_or_subtract() method.

Parameters:
  • a (int) – First integer.

  • b (int) – Second integer.

  • do_addition (bool) – Whether to add or subtract the numbers.

Returns:

a+b if do_addition is True else a-b.

Return type:

int

factorial(n)

Compute the n’th factorial.

See the corresponding 32-bit factorial() method.

Parameters:

n (int) – The integer to computer the factorial of. The maximum allowed value is 127.

Returns:

The factorial of n.

Return type:

float

standard_deviation(data)

Compute the standard deviation.

See the corresponding 32-bit standard_deviation() method.

Parameters:

data (Sequence[float]) – The values to compute the standard deviation of.

Returns:

The standard deviation of data.

Return type:

float

besselJ0(x)

Compute the Bessel function of the first kind of order 0 of x.

See the corresponding 32-bit besselJ0() method.

Parameters:

x (float) – The value to compute BESSEL_J0 of.

Returns:

The value of BESSEL_J0(x).

Return type:

float

reverse_string(original)

Reverse a string.

See the corresponding 32-bit reverse_string() method.

Parameters:

original (str) – The original string.

Returns:

The string reversed.

Return type:

str

add_1d_arrays(a1, a2)

Perform an element-wise addition of two 1D double-precision arrays.

See the corresponding 32-bit add_1d_arrays() method.

Parameters:
Returns:

The element-wise addition of a1 + a2.

Return type:

list[float]

matrix_multiply(a1, a2)

Multiply two matrices.

See the corresponding 32-bit matrix_multiply() method.

Parameters:
Returns:

The product of a1 * a2.

Return type:

list[list[float]]