Go to the documentation of this file.
77 #include <jasper/jas_config.h>
98 #define JAS_MATRIX_REF 0x0001
105 #ifdef JAS_ENABLE_32BIT
106 typedef int_least32_t jas_seqent_t;
107 #define PRIjas_seqent PRIiLEAST32
109 typedef int_fast32_t jas_seqent_t;
110 #define PRIjas_seqent PRIiFAST32
114 #ifdef JAS_ENABLE_32BIT
115 typedef int_least32_t jas_matent_t;
117 typedef int_fast32_t jas_matent_t;
120 #ifdef JAS_ENABLE_32BIT
121 typedef int_least32_t jas_matind_t;
123 typedef int_fast32_t jas_matind_t;
135 jas_matind_t xstart_;
138 jas_matind_t ystart_;
147 jas_matind_t numrows_;
150 jas_matind_t numcols_;
153 jas_seqent_t **rows_;
156 int_fast32_t maxrows_;
162 int_fast32_t datasize_;
189 return matrix->numrows_;
198 return matrix->numcols_;
228 assert(i >= 0 && i < matrix->numrows_ && j >= 0 && j < matrix->numcols_);
229 return matrix->rows_[i][j];
238 assert(i >= 0 && i < matrix->numrows_ && j >= 0 && j < matrix->numcols_);
239 matrix->rows_[i][j] = v;
249 return matrix->numrows_ == 1
250 ? matrix->rows_[0][i]
251 : matrix->rows_[i][0];
260 if (matrix->numrows_ == 1)
261 matrix->rows_[0][i] = v;
263 matrix->rows_[i][0] = v;
273 return &matrix->rows_[i][j];
283 return matrix->numrows_ > 1
322 jas_matind_t c0, jas_matind_t r1, jas_matind_t c1);
348 jas_seqent_t maxval);
385 return matrix->numrows_ > 1
386 ? (size_t)(matrix->rows_[1] - matrix->rows_[0])
397 return matrix->numrows_ > 1
427 static inline jas_seqent_t jas_seqent_asl(jas_seqent_t x,
unsigned n)
429 #ifdef JAS_ENABLE_32BIT
430 return jas_least32_asl(x, n);
432 return jas_fast32_asl(x, n);
440 static inline jas_seqent_t jas_seqent_asr(jas_seqent_t x,
unsigned n)
442 #ifdef JAS_ENABLE_32BIT
443 return jas_least32_asr(x, n);
445 return jas_fast32_asr(x, n);
466 jas_matind_t xend, jas_matind_t yend);
554 return (
unsigned)(s->xend_ - s->xstart_);
564 return (
unsigned)(s->yend_ - s->ystart_);
575 s->xend_ = s->xstart_ + s->numcols_;
576 s->yend_ = s->ystart_ + s->numrows_;
605 jas_matind_t ystart, jas_matind_t xend, jas_matind_t yend);
635 seq->rows_[0][i - seq->xstart_] = v;
645 return &seq->rows_[0][i - seq->xstart_];
655 return seq->rows_[0][i - seq->xstart_];
static void jas_seq2d_setshift(jas_seq2d_t *s, jas_matind_t x, jas_matind_t y)
Set the shift (i.e., starting x- and y-coordinates) of the sequence.
Definition: jas_seq.h:571
static JAS_ATTRIBUTE_PURE jas_matind_t jas_seq2d_ystart(const jas_seq2d_t *s)
Get the starting y-coordinate of the sequence.
Definition: jas_seq.h:492
JAS_EXPORT int jas_matrix_output(jas_matrix_t *matrix, FILE *out)
Write a matrix to a C standard library stream.
static void jas_matrix_setv(jas_matrix_t *matrix, jas_matind_t i, jas_seqent_t v)
Set an element in a matrix that is known to be a row or column vector.
Definition: jas_seq.h:258
static jas_seq_t * jas_seq_create(jas_matind_t start, jas_matind_t end)
Create a 1-D sequence.
Definition: jas_seq.h:615
static JAS_ATTRIBUTE_PURE jas_matind_t jas_seq2d_yend(const jas_seq2d_t *s)
Get the ending y-coordinate of the sequence.
Definition: jas_seq.h:512
void jas_matrix_divpow2(jas_matrix_t *matrix, unsigned n)
Almost-but-not-quite arithmetic shift right of all elements in a matrix.
Definition: jas_seq.c:276
static JAS_ATTRIBUTE_PURE jas_matind_t jas_seq_end(const jas_seq_t *seq)
Get the ending index of a sequence.
Definition: jas_seq.h:673
static JAS_ATTRIBUTE_PURE jas_matind_t jas_seq2d_size(const jas_seq2d_t *s)
Get the number of elements in the sequence.
Definition: jas_seq.h:584
void jas_matrix_setall(jas_matrix_t *matrix, jas_seqent_t val)
Set all elements of a matrix to the specified value.
Definition: jas_seq.c:396
static JAS_ATTRIBUTE_PURE size_t jas_matrix_step(const jas_matrix_t *matrix)
The spacing between columns of a matrix.
Definition: jas_seq.h:395
int jas_matrix_cmp(jas_matrix_t *mat0, jas_matrix_t *mat1)
Compare two matrices for equality.
Definition: jas_seq.c:257
static void jas_seq_destroy(jas_seq_t *seq)
Destroy a 1-D sequence.
Definition: jas_seq.h:624
static JAS_ATTRIBUTE_PURE jas_matind_t jas_seq_start(const jas_seq_t *seq)
Get the starting index of a sequence.
Definition: jas_seq.h:663
static JAS_ATTRIBUTE_PURE jas_matind_t jas_matrix_size(const jas_matrix_t *matrix)
Get the number of elements in a matrix.
Definition: jas_seq.h:206
int jas_seq2d_bindsub(jas_matrix_t *s, jas_matrix_t *s1, jas_matind_t xstart, jas_matind_t ystart, jas_matind_t xend, jas_matind_t yend)
Initialize a sequence to reference a subsequence of another sequence.
Definition: jas_seq.c:206
void * jas_alloc2(size_t num_elements, size_t element_size)
Allocate array (with overflow checking).
Definition: jas_malloc.c:212
int jas_matrix_bindsub(jas_matrix_t *mat0, jas_matrix_t *mat1, jas_matind_t r0, jas_matind_t c0, jas_matind_t r1, jas_matind_t c1)
Create a matrix that references part of another matrix.
Definition: jas_seq.c:217
static JAS_ATTRIBUTE_PURE jas_matind_t jas_matrix_numcols(const jas_matrix_t *matrix)
Get the number of columns in a matrix.
Definition: jas_seq.h:196
static JAS_ATTRIBUTE_PURE jas_seqent_t jas_seq2d_get(const jas_seq2d_t *s, jas_matind_t x, jas_matind_t y)
Get an element of a 2-D sequence.
Definition: jas_seq.h:532
static void jas_seq2d_destroy(jas_seq2d_t *s)
Destroy a 2-D sequence.
Definition: jas_seq.h:472
JAS_EXPORT jas_matrix_t * jas_matrix_input(FILE *)
Read a matrix from a C standard library stream.
static JAS_ATTRIBUTE_PURE jas_matind_t jas_matrix_numrows(const jas_matrix_t *matrix)
Get the number of rows in a matrix.
Definition: jas_seq.h:187
static JAS_ATTRIBUTE_PURE jas_seqent_t jas_matrix_getv(const jas_matrix_t *matrix, jas_matind_t i)
Get an element from a matrix that is known to be a row or column vector.
Definition: jas_seq.h:247
jas_matrix_t * jas_matrix_create(jas_matind_t numrows, jas_matind_t numcols)
Create a matrix with the specified dimensions.
Definition: jas_seq.c:102
JAS_EXPORT void * jas_malloc(size_t size)
Allocate memory.
Definition: jas_malloc.c:136
static void jas_seq_set(jas_seq_t *seq, jas_matind_t i, jas_seqent_t v)
Set an element of a sequence.
Definition: jas_seq.h:633
static JAS_ATTRIBUTE_PURE jas_matind_t jas_seq2d_xend(const jas_seq2d_t *s)
Get the ending x-coordinate of the sequence.
Definition: jas_seq.h:502
JasPer Debugging-Related Functionality.
static JAS_ATTRIBUTE_PURE unsigned jas_seq2d_height(const jas_seq2d_t *s)
Get the number of rows in the sequence.
Definition: jas_seq.h:562
static JAS_ATTRIBUTE_PURE jas_seqent_t * jas_matrix_getvref(const jas_matrix_t *matrix, jas_matind_t i)
Get a reference to a particular row of a 2-D sequence.
Definition: jas_seq.h:281
jas_matrix_t * jas_matrix_copy(jas_matrix_t *x)
Copy a matrix.
Definition: jas_seq.c:188
JAS_EXPORT void jas_free(void *ptr)
Free memory.
Definition: jas_malloc.c:186
One-dimensional sequence type.
static JAS_ATTRIBUTE_PURE jas_seqent_t * jas_matrix_getref(const jas_matrix_t *matrix, jas_matind_t i, jas_matind_t j)
Get the address of an element in a matrix.
Definition: jas_seq.h:271
static JAS_ATTRIBUTE_PURE jas_seqent_t jas_seq_get(const jas_seq_t *seq, jas_matind_t i)
Get an element of a sequence.
Definition: jas_seq.h:653
static JAS_ATTRIBUTE_PURE jas_seqent_t jas_matrix_get(const jas_matrix_t *matrix, jas_matind_t i, jas_matind_t j)
Get a matrix element.
Definition: jas_seq.h:226
void jas_matrix_clip(jas_matrix_t *matrix, jas_seqent_t minval, jas_seqent_t maxval)
Clip the values of matrix elements to the specified range.
Definition: jas_seq.c:298
void jas_matrix_asr(jas_matrix_t *matrix, unsigned n)
Arithmetic shift right of all elements in a matrix.
Definition: jas_seq.c:327
static JAS_ATTRIBUTE_PURE size_t jas_seq2d_rowstep(const jas_seq2d_t *s)
Get the stride between successive rows in the sequence.
Definition: jas_seq.h:542
static JAS_ATTRIBUTE_PURE unsigned jas_seq2d_width(const jas_seq2d_t *s)
Get the number of columns in the sequence.
Definition: jas_seq.h:552
static JAS_ATTRIBUTE_PURE bool jas_seq2d_empty(const jas_seq2d_t *s)
Test if the sequence is empty (i.e., contains no elements).
Definition: jas_seq.h:594
static JAS_ATTRIBUTE_PURE jas_matind_t jas_seq2d_xstart(const jas_seq2d_t *s)
Get the starting x-coordinate of the sequence.
Definition: jas_seq.h:482
static int jas_matrix_bindrow(jas_matrix_t *mat0, jas_matrix_t *mat1, jas_matind_t r)
Create a matrix that is a reference to a row of another matrix.
Definition: jas_seq.h:328
jas_matrix_t * jas_seq2d_create(jas_matind_t xstart, jas_matind_t ystart, jas_matind_t xend, jas_matind_t yend)
Create a 2-D sequence.
Definition: jas_seq.c:87
static void jas_matrix_set(jas_matrix_t *matrix, jas_matind_t i, jas_matind_t j, jas_seqent_t v)
Set a matrix element.
Definition: jas_seq.h:236
Two-dimensional sequence type.
int jas_matrix_resize(jas_matrix_t *matrix, jas_matind_t numrows, jas_matind_t numcols)
Resize a matrix. The previous contents of the matrix are lost.
Definition: jas_seq.c:375
void jas_matrix_destroy(jas_matrix_t *matrix)
Destroy a matrix.
Definition: jas_seq.c:162
static JAS_ATTRIBUTE_PURE jas_seqent_t * jas_seq2d_getref(const jas_seq2d_t *s, jas_matind_t x, jas_matind_t y)
Get a pointer (i.e., reference) to an element of a 2-D sequence.
Definition: jas_seq.h:522
static JAS_ATTRIBUTE_PURE size_t jas_matrix_rowstep(const jas_matrix_t *matrix)
The spacing between rows of a matrix.
Definition: jas_seq.h:383
static int jas_matrix_bindcol(jas_matrix_t *mat0, jas_matrix_t *mat1, jas_matind_t c)
Create a matrix that is a reference to a column of another matrix.
Definition: jas_seq.h:337
jas_seq2d_t * jas_seq2d_copy(jas_seq2d_t *x)
Copy a 2-D sequence.
Definition: jas_seq.c:172
static JAS_ATTRIBUTE_PURE jas_seqent_t * jas_seq_getref(const jas_seq_t *seq, jas_matind_t i)
Get a pointer (i.e., reference) to an element of a sequence.
Definition: jas_seq.h:643
Matrix type.
Definition: jas_seq.h:129
void jas_matrix_asl(jas_matrix_t *matrix, unsigned n)
Arithmetic shift left of all elements in a matrix.
Definition: jas_seq.c:349
static JAS_ATTRIBUTE_PURE bool jas_matrix_empty(const jas_matrix_t *matrix)
Test if a matrix is empty (i.e., contains no elements).
Definition: jas_seq.h:216