ajmath.c


Function ajRound

Rounds an integer to be a multiple of a given number.

Synopsis

Prototype
ajint ajRound (
      ajint i,
      ajint round
);

TypeNameRead/WriteDescription
ajintiInputInteger to round.
ajintroundInputRounding multiple.
ajint RETURNResult.

Input
i:(Input)Integer to round.
round:(Input)Rounding multiple.
Returns
ajint:Result.

Description

Rounds an integer to be a multiple of a given number.

Usage

See source code

Example

In preparation

Errors

See source code

Dependencies

See source code

See Also

See other functions in this section

Availability

In release 5.0.0

Function ajRoundF

Rounds a floating point number to have bits free for cumulative addition

Synopsis

Prototype
float ajRoundF (
      float a,
      ajint nbits
);

TypeNameRead/WriteDescription
floataInputFloat to round.
ajintnbitsInputNumber of bits to free.
float RETURNResult.

Input
a:(Input)Float to round.
nbits:(Input)Number of bits to free.
Returns
float:Result.

Description

Rounds a floating point number to have bits free for cumulative addition

Usage

See source code

Example

In preparation

Errors

See source code

Dependencies

See source code

See Also

See other functions in this section

Availability

In release 5.0.0

Function ajRecToPol

Converts cartesian co-ordinates to polar

Synopsis

Prototype
void ajRecToPol (
      float x,
      float y,
      float* radius,
      float* angle
);

TypeNameRead/WriteDescription
floatxInputX co-ordinate
floatyInputY co-ordinate
float*radiusOutputRadius
float*angleOutputAngle
void RETURN

Input
x:(Input)X co-ordinate
y:(Input)Y co-ordinate
Output
radius:(Output)Radius
angle:(Output)Angle
Returns
void:No return value

Description

Converts cartesian co-ordinates to polar

Usage

See source code

Example

In preparation

Errors

See source code

Dependencies

See source code

See Also

See other functions in this section

Availability

In release 5.0.0

Function ajPolToRec

Converts polar co-ordinates to cartesian

Synopsis

Prototype
void ajPolToRec (
      float radius,
      float angle,
      float* x,
      float* y
);

TypeNameRead/WriteDescription
floatradiusInputRadius
floatangleInputAngle
float*xOutputX co-ordinate
float*yOutputY co-ordinate
void RETURN

Input
radius:(Input)Radius
angle:(Input)Angle
Output
x:(Output)X co-ordinate
y:(Output)Y co-ordinate
Returns
void:No return value

Description

Converts polar co-ordinates to cartesian

Usage

See source code

Example

In preparation

Errors

See source code

Dependencies

See source code

See Also

See other functions in this section

Availability

In release 5.0.0

Function ajDegToRad

Converts degrees to radians

Synopsis

Prototype
float ajDegToRad (
      float degrees
);

TypeNameRead/WriteDescription
floatdegreesInputDegrees
float RETURNRadians

Input
degrees:(Input)Degrees
Returns
float:Radians

Description

Converts degrees to radians

Usage

See source code

Example

In preparation

Errors

See source code

Dependencies

See source code

See Also

See other functions in this section

Availability

In release 5.0.0

Function ajRadToDeg

Converts radians to degrees

Synopsis

Prototype
float ajRadToDeg (
      float radians
);

TypeNameRead/WriteDescription
floatradiansInputRadians
float RETURNDegrees

Input
radians:(Input)Radians
Returns
float:Degrees

Description

Converts radians to degrees

Usage

See source code

Example

In preparation

Errors

See source code

Dependencies

See source code

See Also

See other functions in this section

Availability

In release 5.0.0

Function ajGaussProb

Returns a probability given a Gaussian distribution

Synopsis

Prototype
double ajGaussProb (
      float mean,
      float sd,
      float score
);

TypeNameRead/WriteDescription
floatmeanInputmean
floatsdInputsd
floatscoreInputscore
double RETURNprobability

Input
mean:(Input)mean
sd:(Input)sd
score:(Input)score
Returns
double:probability

Description

Returns a probability given a Gaussian distribution

Usage

See source code

Example

In preparation

Errors

See source code

Dependencies

See source code

See Also

See other functions in this section

Availability

In release 5.0.0

Function ajGeoMean

Calculate a geometric mean

Synopsis

Prototype
float ajGeoMean (
      const float* s,
      ajint n
);

TypeNameRead/WriteDescription
const float*sInputarray of values
ajintnInputnumber of values
float RETURNgeometric mean

Input
s:(Input)array of values
n:(Input)number of values
Returns
float:geometric mean

Description

Calculate a geometric mean

Usage

See source code

Example

In preparation

Errors

See source code

Dependencies

See source code

See Also

See other functions in this section

Availability

In release 5.0.0

Function ajPosMod

Modulo always returning positive number

Synopsis

Prototype
ajint ajPosMod (
      ajint a,
      ajint b
);

TypeNameRead/WriteDescription
ajintaInputvalue1
ajintbInputvalue2
ajint RETURNvalue1 modulo value2

Input
a:(Input)value1
b:(Input)value2
Returns
ajint:value1 modulo value2

Description

Modulo always returning positive number

Usage

See source code

Example

In preparation

Errors

See source code

Dependencies

See source code

See Also

See other functions in this section

Availability

In release 5.0.0

Function ajRandomSeed

Seed for the ajRandomNumberD routine

Based on dprand and sdprand and used with the permission of the author.... Copyright (C) 1992 N.M. Maclaren Copyright (C) 1992 The University of Cambridge

This software may be reproduced and used freely, provided that all users of it agree that the copyright holders are not liable for any damage or injury caused by use of this software and that this condition is passed onto all subsequent recipients of the software, whether modified or not.

Synopsis

Prototype
void ajRandomSeed (
      void
);

TypeNameRead/WriteDescription
void RETURN

Returns
void:No return value

Description

Seed for the ajRandomNumberD routine

Based on dprand and sdprand and used with the permission of the author.... Copyright (C) 1992 N.M. Maclaren Copyright (C) 1992 The University of Cambridge

This software may be reproduced and used freely, provided that all users of it agree that the copyright holders are not liable for any damage or injury caused by use of this software and that this condition is passed onto all subsequent recipients of the software, whether modified or not.

Usage

See source code

Example

In preparation

Errors

See source code

Dependencies

See source code

See Also

See other functions in this section

Availability

In release 5.0.0

Function ajRandomNumber

Generate a pseudo-random number between 0-32767

Synopsis

Prototype
ajint ajRandomNumber (
      void
);

TypeNameRead/WriteDescription
ajint RETURNRandom number

Returns
ajint:Random number

Description

Generate a pseudo-random number between 0-32767

Usage

See source code

Example

In preparation

Errors

See source code

Dependencies

See source code

See Also

See other functions in this section

Availability

In release 5.0.0

Function ajRandomNumberD

Generate a random number between 0-1.0

Based on dprand and sdprand and used with the permission of the author.... Copyright (C) 1992 N.M. Maclaren Copyright (C) 1992 The University of Cambridge

This software may be reproduced and used freely, provided that all users of it agree that the copyright holders are not liable for any damage or injury caused by use of this software and that this condition is passed onto all subsequent recipients of the software, whether modified or not.

Synopsis

Prototype
double ajRandomNumberD (
      void
);

TypeNameRead/WriteDescription
double RETURNRandom number

Returns
double:Random number

Description

Generate a random number between 0-1.0

Based on dprand and sdprand and used with the permission of the author.... Copyright (C) 1992 N.M. Maclaren Copyright (C) 1992 The University of Cambridge

This software may be reproduced and used freely, provided that all users of it agree that the copyright holders are not liable for any damage or injury caused by use of this software and that this condition is passed onto all subsequent recipients of the software, whether modified or not.

Usage

See source code

Example

In preparation

Errors

See source code

Dependencies

See source code

See Also

See other functions in this section

Availability

In release 5.0.0

Function ajSp32Crc

Calculates the SwissProt style CRC32 checksum for a protein sequence. This seems to be a bit reversal of a standard CRC32 checksum.

Synopsis

Prototype
ajuint ajSp32Crc (
      const AjPStr seq
);

TypeNameRead/WriteDescription
const AjPStrseqInputSequence as a string
ajuint RETURNCRC32 checksum.

Input
seq:(Input)Sequence as a string
Returns
ajuint:CRC32 checksum.

Description

Calculates the SwissProt style CRC32 checksum for a protein sequence. This seems to be a bit reversal of a standard CRC32 checksum.

Usage

See source code

Example

In preparation

Errors

See source code

Dependencies

See source code

See Also

See other functions in this section

Availability

In release 5.0.0

Function ajSp64Crc

Calculate 64-bit crc

Synopsis

Prototype
unsigned long long ajSp64Crc (
      const AjPStr thys
);

TypeNameRead/WriteDescription
const AjPStrthysInputsequence
unsigned long long RETURN64-bit CRC

Input
thys:(Input)sequence
Returns
unsigned long long:64-bit CRC

Description

Calculate 64-bit crc

Usage

See source code

Example

In preparation

Errors

See source code

Dependencies

See source code

See Also

See other functions in this section

Availability

In release 5.0.0

Function ajMathPos

Converts a string position into a true position. If ipos is negative, it is counted from the end of the string rather than the beginning.

Synopsis

Prototype
ajuint ajMathPos (
      ajuint len,
      ajint ipos
);

TypeNameRead/WriteDescription
ajuintlenInputString length.
ajintiposInputPosition (0 start, negative from the end).
ajuint RETURNstring position between 0 and (length minus 1).

Input
len:(Input)String length.
ipos:(Input)Position (0 start, negative from the end).
Returns
ajuint:string position between 0 and (length minus 1).

Description

Converts a string position into a true position. If ipos is negative, it is counted from the end of the string rather than the beginning.

Usage

See source code

Example

In preparation

Errors

See source code

Dependencies

See source code

See Also

See other functions in this section

Availability

In release 5.0.0

Function ajMathPosI

Converts a position into a true position. If ipos is negative, it is counted from the end of the string rather than the beginning.

imin is a minimum relative position. Usually this is the start position when the end of a range is being tested.

Synopsis

Prototype
ajuint ajMathPosI (
      ajuint len,
      ajuint imin,
      ajint ipos
);

TypeNameRead/WriteDescription
ajuintlenInputmaximum length.
ajuintiminInputStart position (0 start, no negative values).
ajintiposInputPosition (0 start, negative from the end).
ajuint RETURNstring position between 0 and (length minus 1).

Input
len:(Input)maximum length.
imin:(Input)Start position (0 start, no negative values).
ipos:(Input)Position (0 start, negative from the end).
Returns
ajuint:string position between 0 and (length minus 1).

Description

Converts a position into a true position. If ipos is negative, it is counted from the end of the string rather than the beginning.

imin is a minimum relative position. Usually this is the start position when the end of a range is being tested.

Usage

See source code

Example

In preparation

Errors

See source code

Dependencies

See source code

See Also

See other functions in this section

Availability

In release 5.0.0

Function ajNumLengthDouble

Returns the length of a number written as an integer

Synopsis

Prototype
ajuint ajNumLengthDouble (
      double dnumber
);

TypeNameRead/WriteDescription
doublednumberInputDouble precision value
ajuint RETURNNumber of digits

Input
dnumber:(Input)Double precision value
Returns
ajuint:Number of digits

Description

Returns the length of a number written as an integer

Usage

See source code

Example

In preparation

Errors

See source code

Dependencies

See source code

See Also

See other functions in this section

Availability

In release 5.0.0

Function ajNumLengthFloat

Returns the length of a number written as an integer

Synopsis

Prototype
ajuint ajNumLengthFloat (
      float fnumber
);

TypeNameRead/WriteDescription
floatfnumberInputSingle precision value
ajuint RETURNNumber of digits

Input
fnumber:(Input)Single precision value
Returns
ajuint:Number of digits

Description

Returns the length of a number written as an integer

Usage

See source code

Example

In preparation

Errors

See source code

Dependencies

See source code

See Also

See other functions in this section

Availability

In release 5.0.0

Function ajNumLengthInt

Returns the length of a number written as an integer

Synopsis

Prototype
ajuint ajNumLengthInt (
      ajlong inumber
);

TypeNameRead/WriteDescription
ajlonginumberInputInteger
ajuint RETURNNumber of digits

Input
inumber:(Input)Integer
Returns
ajuint:Number of digits

Description

Returns the length of a number written as an integer

Usage

See source code

Example

In preparation

Errors

See source code

Dependencies

See source code

See Also

See other functions in this section

Availability

In release 5.0.0

Function ajNumLengthUint

Returns the length of a number written as an integer

Synopsis

Prototype
ajuint ajNumLengthUint (
      ajulong inumber
);

TypeNameRead/WriteDescription
ajulonginumberInputUnsigned integer
ajuint RETURNNumber of digits

Input
inumber:(Input)Unsigned integer
Returns
ajuint:Number of digits

Description

Returns the length of a number written as an integer

Usage

See source code

Example

In preparation

Errors

See source code

Dependencies

See source code

See Also

See other functions in this section

Availability

In release 5.0.0