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 SINGLE.

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 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).