scs.h File Reference

This is the main header file of the SCS library, which defines the SCS data structure, and the functions that implement arithmetic on it. More...


Data Structures

struct  scs
 The SCS data type. More...


SCS data-types

typedef scsscs_ptr
scs scs_t [1]

Conversion and initialization functions

void scs_get_d (double *, scs_ptr)
void scs_get_d_minf (double *, scs_ptr)
void scs_get_d_pinf (double *, scs_ptr)
void scs_get_d_zero (double *, scs_ptr)
void scs_set_d (scs_ptr, double)
void scs_set_si (scs_ptr, signed int)
void scs_get_std (scs_ptr)
void scs_set (scs_ptr, scs_ptr)
void scs_zero (scs_ptr)
void scs_rand (scs_ptr result, int expo_max)

Addition and renormalisation functions

void scs_add (scs_ptr result, scs_ptr x, scs_ptr y)
void scs_sub (scs_ptr result, scs_ptr x, scs_ptr y)
void scs_add_no_renorm (scs_ptr result, scs_ptr x, scs_ptr y)
void scs_renorm (scs_ptr)
void scs_renorm_no_cancel_check (scs_ptr)

Multiplication functions

void scs_mul (scs_ptr result, const scs_ptr x, const scs_ptr y)
void scs_mul_ui (scs_ptr, const unsigned int)
void scs_square (scs_ptr result, scs_ptr x)
void scs_fma (scs_ptr result, scs_ptr a, scs_ptr b, scs_ptr c)

Divisions

void scs_inv (scs_ptr result, scs_ptr x)
void scs_div (scs_ptr result, scs_ptr x, scs_ptr y)


Detailed Description

This is the main header file of the SCS library, which defines the SCS data structure, and the functions that implement arithmetic on it.

Author:
David Defour David.Defour@ens-lyon.fr , Florent de Dinechin Florent.de.Dinechin@ens-lyon.fr
This file is part of the SCS library.

Copyright (C) 2002 David Defour and Florent de Dinechin

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA


Typedef Documentation

typedef struct scs* scs_ptr
 

scs_ptr is a pointer on a SCS structure.


Function Documentation

void scs_get_d double *   ,
scs_ptr   
 

Convert a SCS number to a double, rounding to the nearest.

void scs_get_d_minf double *   ,
scs_ptr   
 

Convert a SCS number to a double, rounding towards minus infinity.

void scs_get_d_pinf double *   ,
scs_ptr   
 

Convert a SCS number to a double, rounding towards plus infinity.

void scs_get_d_zero double *   ,
scs_ptr   
 

Convert a SCS number to a double, rounding towards zero.

void scs_set_d scs_ptr   ,
double   
 

Convert a double into a SCS number (this is an exact operation).

void scs_set_si scs_ptr   ,
signed    int
 

Convert an unsigned int into a SCS number (this is an exact operation).

void scs_get_std scs_ptr   
 

Print out a SCS number.

Sorry for the strange name, we are mimicking GMP

void scs_set scs_ptr   ,
scs_ptr   
 

Copy a SCS number into another.

void scs_zero scs_ptr   
 

Set a SCS number to zero.

void scs_rand scs_ptr    result,
int    expo_max
 

Generate a random SCS number.

The index field of result will be between -expo_max and +expo_max. Example: to get a number in the double-precision floating-point range, expo_max should be smaller than 39.

Warning:
No guarantee is made about the quality of the random algorithm used...

void scs_add scs_ptr    result,
scs_ptr    x,
scs_ptr    y
 

Addition of two SCS numbers.

The arguments x, y and result may point to the same memory location. The result is a normalised SCS number.

void scs_sub scs_ptr    result,
scs_ptr    x,
scs_ptr    y
 

Subtraction of two SCS numbers.

The arguments x, y and result may point to the same memory location. The result is a normalised SCS number.

void scs_add_no_renorm scs_ptr    result,
scs_ptr    x,
scs_ptr    y
 

Addition without renormalisation, to be used for adding many numbers.

Warning:
In case of a cancellation, severe loss of precision could happen. Safe if the numbers are of the same sign.

void scs_renorm scs_ptr   
 

Renormalisation (to be used after several scs_add_no_renorm).

This function removes the carry from each digit, and also shifts the digits in case of a cancellation (so that if result != 0 then its first digit is non-zero)

Warning:
THIS FUNCTION HAS NEVER BEEN PROPERLY TESTED and is currently unused in the library: instead, specific renormalisation steps are fused within the code of the operations which require it.

void scs_renorm_no_cancel_check scs_ptr   
 

Renormalisation assuming no cancellation.

This function is useful for example when adding many numbers of the same sign

void scs_mul scs_ptr    result,
const scs_ptr    x,
const scs_ptr    y
 

Multiplication of two SCS numbers.

The arguments x, y and result may point to the same memory location. The result is a normalised SCS number.

void scs_mul_ui scs_ptr   ,
const unsigned    int
 

Multiplication of a SCS with an unsigned integer; result is returned in x.

void scs_square scs_ptr    result,
scs_ptr    x
 

Square.

Result is normalised

void scs_fma scs_ptr    result,
scs_ptr    a,
scs_ptr    b,
scs_ptr    c
 

Fused multiply-and-add (ab+c); Result is normalised.

Warning:
This function has not been tested thoroughly

void scs_inv scs_ptr    result,
scs_ptr    x
 

SCS inverse.

Stores 1/x in result. Result is normalised

Warning:
This function is known not to work for most precisions: it performs a fixed number of Newton-Raphson iterations (two), starting with a FP number (53 bits), so provides roughly 210 bits of precision. It should be modified to perform more iterations if more precision is needed.

void scs_div scs_ptr    result,
scs_ptr    x,
scs_ptr    y
 

SCS division.

Computes x/y. Result is normalised

Warning:
This function is known not to work for most precisions: it performs a fixed number of Newton-Raphson iterations (two), starting with a FP number (53 bits), so provides roughly 210 bits of precision. It should be modified to perform more iterations if more precision is needed.


Variable Documentation

struct scs scs_t[1]
 

scs_t is an array of one SCS struct to lighten syntax : you may declare a scs_t object, and pass it to the scs functions (which expect pointers) without using ampersands.


Generated on Tue Jun 17 10:15:45 2003 for SCSLib by doxygen1.2.15