GALAHAD CONVERT package#

purpose#

The convert package takes a sparse matrix \(A\) stored in one format and converts it into another.

Currently only the options and inform dictionaries are exposed; these are provided and used by other GALAHAD packages with Python interfaces. Please contact us if you would like full functionality!

See Section 4 of $GALAHAD/doc/convert.pdf for a brief description of the method employed and other details.

callable functions#

overview of functions provided#

// namespaces

namespace conf;

// typedefs

typedef float spc_;
typedef double rpc_;
typedef int ipc_;

// structs

struct convert_control_type;
struct convert_inform_type;
struct convert_time_type;

// global functions

void convert_initialize(
    void **data,
    struct convert_control_type* control,
    ipc_ *status
);

void convert_information(
    void **data,
    struct convert_inform_type* inform,
    ipc_ *status
);

void convert_terminate(
    void **data,
    struct convert_control_type* control,
    struct convert_inform_type* inform
);

typedefs#

typedef float spc_

spc_ is real single precision

typedef double rpc_

rpc_ is the real working precision used, but may be changed to float by defining the preprocessor variable REAL_32 or (if supported) to __real128 using the variable REAL_128.

typedef int ipc_

ipc_ is the default integer word length used, but may be changed to int64_t by defining the preprocessor variable INTEGER_64.

function and structure names#

The function and structure names described below are appropriate for the default real working precision (double) and integer word length (int32_t). To use the functions and structures with different precisions and integer word lengths, an additional suffix must be added to their names (and the arguments set accordingly). The appropriate suffices are:

_s for single precision (float) reals and standard 32-bit (int32_t) integers;

_q for quadruple precision (__real128) reals (if supported) and standard 32-bit (int32_t) integers;

_64 for standard precision (double) reals and 64-bit (int64_t) integers;

_s_64 for single precision (float) reals and 64-bit (int64_t) integers; and

_q_64 for quadruple precision (__real128) reals (if supported) and 64-bit (int64_t) integers.

Thus a call to convert_initialize below will instead be

void convert_initialize_s_64(void **data, struct convert_control_type_s_64* control,
                                 int64_t *status)

if single precision (float) reals and 64-bit (int64_t) integers are required. Thus it is possible to call functions for this package with more that one precision and/or integer word length at same time. An example is provided for the package expo, and the obvious modifications apply equally here.

function calls#

void convert_initialize(
    void **data,
    struct convert_control_type* control,
    ipc_ *status
)

Set default control values and initialize private data

Parameters:

data

holds private internal data

control

is a struct containing control information (see convert_control_type)

status

is a scalar variable of type ipc_, that gives the exit status from the package. Possible values are (currently):

  • 0

    The initialization was successful.

void convert_information(
    void **data,
    struct convert_inform_type* inform,
    ipc_ *status
)

Provides output information

Parameters:

data

holds private internal data

inform

is a struct containing output information (see convert_inform_type)

status

is a scalar variable of type ipc_, that gives the exit status from the package. Possible values are (currently):

  • 0

    The values were recorded successfully

void convert_terminate(
    void **data,
    struct convert_control_type* control,
    struct convert_inform_type* inform
)

Deallocate all internal private storage

Parameters:

data

holds private internal data

control

is a struct containing control information (see convert_control_type)

inform

is a struct containing output information (see convert_inform_type)

available structures#

convert_control_type structure#

#include <galahad_convert.h>

struct convert_control_type {
    // fields

    bool f_indexing;
    ipc_ error;
    ipc_ out;
    ipc_ print_level;
    bool transpose;
    bool sum_duplicates;
    bool order;
    bool space_critical;
    bool deallocate_error_fatal;
    char prefix[31];
};

detailed documentation#

control derived type as a C struct

components#

bool f_indexing

use C or Fortran sparse matrix indexing

ipc_ error

unit for error messages

ipc_ out

unit for monitor output

ipc_ print_level

controls level of diagnostic output

bool transpose

obtain the transpose of the input matrix?

bool sum_duplicates

add the values of entries in duplicate positions?

bool order

order row or column data by increasing index?

bool space_critical

if space is critical, ensure allocated arrays are no bigger than needed

bool deallocate_error_fatal

exit if any deallocation fails

char prefix[31]

all output lines will be prefixed by prefix(2:LEN(TRIM(.prefix))-1) where prefix contains the required string enclosed in quotes, e.g. “string” or ‘string’

convert_time_type structure#

#include <galahad_convert.h>

struct convert_time_type {
    // fields

    rpc_ total;
    rpc_ clock_total;
};

detailed documentation#

time derived type as a C struct

components#

rpc_ total

total cpu time spent in the package

rpc_ clock_total

total clock time spent in the package

convert_inform_type structure#

#include <galahad_convert.h>

struct convert_inform_type {
    // fields

    ipc_ status;
    ipc_ alloc_status;
    ipc_ duplicates;
    char bad_alloc[81];
    struct convert_time_type time;
};

detailed documentation#

inform derived type as a C struct

components#

ipc_ status

the return status. Possible values are:

  • 0

    a successful conversion.

  • -1

    An allocation error occurred. A message indicating the offending array is written on unit control.error, and the returned allocation status and a string containing the name of the offending array are held in inform.alloc_status and inform.bad_alloc respectively.

  • -2

    A deallocation error occurred. A message indicating the offending array is written on unit control.error and the returned allocation status and a string containing the name of the offending array are held in inform.alloc_status and inform.bad_alloc respectively.

  • -3

    The restriction n > 0 or m > 0 or requirement that a type contains its relevant string ‘coordinate’, ‘sparse_by_rows’, ‘sparse_by_columns’, ‘dense_by_rows’ or ‘dense_by_columns’ has been violated.

  • -32

    provided integer workspace is not large enough.

  • -33

    provided real workspace is not large enough.

  • -73

    an input matrix entry has been repeated.

  • -79

    there are missing optional arguments.

  • -90

    a requested output format is not recognised.

ipc_ alloc_status

the status of the last attempted allocation/deallocation.

ipc_ duplicates

the number of duplicates found (-ve = not checked).

char bad_alloc[81]

the name of the array for which an allocation/deallocation error occurred.

struct convert_time_type time

timings (see above).