CWB
Functions
barlib.c File Reference

This file contains the methods for the BARdesc class. More...

#include "barlib.h"
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>

Functions

BARdesc BAR_new (int N, int M, int W)
 Creates a BAR whose matrix size is N-by-M, with beam width W. More...
 
void BAR_reinit (BARdesc BAR, int N, int M, int W)
 Changes the size of a BAR (erasing the contents of the BAR). More...
 
void BAR_delete (BARdesc BAR)
 Destroys a BARdesc object. More...
 
void BAR_write (BARdesc BAR, int x, int y, int i)
 Sets an element of a BAR. More...
 
int BAR_read (BARdesc BAR, int x, int y)
 Reads a single integer value from the specified cell of the matrix in a BAR. More...
 

Detailed Description

This file contains the methods for the BARdesc class.

See also
BARdesc

Function Documentation

void BAR_delete ( BARdesc  BAR)

Destroys a BARdesc object.

Parameters
BARDescriptor of the BAR to destroy.

References _BARdesc::d_block_data, _BARdesc::d_block_start_x, and _BARdesc::data.

Referenced by best_path().

BARdesc BAR_new ( int  N,
int  M,
int  W 
)

Creates a BAR whose matrix size is N-by-M, with beam width W.

Parameters
NFirst dimension size for the new matrix (see BARdesc).
MSecond dimension size for the new matrix (see BARdesc).
WBeam width size for the new matrix (see BARdesc).
Returns
The new BARdesc object.

References _BARdesc::beam_width, _BARdesc::d_block_data, _BARdesc::d_block_start_x, _BARdesc::d_size, _BARdesc::data, _BARdesc::data_size, _BARdesc::vector_size, _BARdesc::x_size, and _BARdesc::y_size.

Referenced by best_path().

int BAR_read ( BARdesc  BAR,
int  x,
int  y 
)

Reads a single integer value from the specified cell of the matrix in a BAR.

Usage:

i = A(x,y)

is expressed as

i = BAR_read(BAR, x, y);

Parameters
BARBAR descriptor: the matrix we want to read from.
xmatrix x coordinate of the value we want.
ymatrix y coordinate of the value we want.
Returns
the value of A(x,y); if (x,y) is outside the matrix or beam range, the function returns 0.

References _BARdesc::beam_width, _BARdesc::d_block_data, and _BARdesc::d_block_start_x.

Referenced by best_path().

void BAR_reinit ( BARdesc  BAR,
int  N,
int  M,
int  W 
)

Changes the size of a BAR (erasing the contents of the BAR).

This function must never be passed a NULL object.

See also
BARdesc
Parameters
BARThe BAR to resize.
NFirst dimension of the new size of matrix (see BARdesc).
MSecond dimension of the new size of matrix (see BARdesc).
WBeam width of the new size of matrix (see BARdesc).

References _BARdesc::beam_width, _BARdesc::d_block_data, _BARdesc::d_block_start_x, _BARdesc::d_size, _BARdesc::data, _BARdesc::data_size, _BARdesc::vector_size, _BARdesc::x_size, and _BARdesc::y_size.

void BAR_write ( BARdesc  BAR,
int  x,
int  y,
int  i 
)

Sets an element of a BAR.

Usage:

BAR_write(BAR, x, y, i);

sets A(x,y) = i.

  • if (x,y) is outside matrix or beam range, the function call is ignored.
  • if d_(x+y) hasn't been accessed before, the block_start_x value is set to x.
Parameters
BARBAR descriptor: the matrix we want to write to.
xmatrix x coordinate of the cell we want to write in.
ymatrix y coordinate of the cell we want to write in.
ivalue to set it to

References _BARdesc::beam_width, beam_width, _BARdesc::d_block_data, and _BARdesc::d_block_start_x.

Referenced by best_path().