Go to the documentation of this file.
77 #include <jasper/jas_config.h>
99 #define JAS_MATRIX_REF 0x0001
107 #define PRIjas_seqent PRIjas_fix
123 jas_matind_t xstart_;
126 jas_matind_t ystart_;
135 jas_matind_t numrows_;
138 jas_matind_t numcols_;
141 jas_seqent_t **rows_;
144 int_fast32_t maxrows_;
150 int_fast32_t datasize_;
177 return matrix->numrows_;
186 return matrix->numcols_;
216 assert(i >= 0 && i < matrix->numrows_ && j >= 0 && j < matrix->numcols_);
217 return matrix->rows_[i][j];
226 assert(i >= 0 && i < matrix->numrows_ && j >= 0 && j < matrix->numcols_);
227 matrix->rows_[i][j] = v;
237 return matrix->numrows_ == 1
238 ? matrix->rows_[0][i]
239 : matrix->rows_[i][0];
248 if (matrix->numrows_ == 1)
249 matrix->rows_[0][i] = v;
251 matrix->rows_[i][0] = v;
261 return &matrix->rows_[i][j];
271 return matrix->numrows_ > 1
310 jas_matind_t c0, jas_matind_t r1, jas_matind_t c1);
336 jas_seqent_t maxval);
373 return matrix->numrows_ > 1
374 ? (size_t)(matrix->rows_[1] - matrix->rows_[0])
385 return matrix->numrows_ > 1
415 static inline jas_seqent_t jas_seqent_asl(jas_seqent_t x,
unsigned n)
418 #ifdef JAS_ENABLE_32BIT
419 return jas_least32_asl(x, n);
421 return jas_fast32_asl(x, n);
424 return jas_fix_asl(x, n);
431 static inline jas_seqent_t jas_seqent_asr(jas_seqent_t x,
unsigned n)
434 #ifdef JAS_ENABLE_32BIT
435 return jas_least32_asr(x, n);
437 return jas_fast32_asr(x, n);
440 return jas_fix_asr(x, n);
460 jas_matind_t xend, jas_matind_t yend);
548 return (
unsigned)(s->xend_ - s->xstart_);
558 return (
unsigned)(s->yend_ - s->ystart_);
569 s->xend_ = s->xstart_ + s->numcols_;
570 s->yend_ = s->ystart_ + s->numrows_;
599 jas_matind_t ystart, jas_matind_t xend, jas_matind_t yend);
629 seq->rows_[0][i - seq->xstart_] = v;
639 return &seq->rows_[0][i - seq->xstart_];
649 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:565
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:486
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:246
static jas_seq_t * jas_seq_create(jas_matind_t start, jas_matind_t end)
Create a 1-D sequence.
Definition: jas_seq.h:609
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:506
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:667
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:578
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:383
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:618
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:657
JasPer Fixed-Point Number Class.
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:194
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:184
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:526
static void jas_seq2d_destroy(jas_seq2d_t *s)
Destroy a 2-D sequence.
Definition: jas_seq.h:466
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:175
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:235
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:627
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:496
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:556
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:269
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:259
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:647
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:214
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:536
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:546
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:588
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:476
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:316
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:224
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:516
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:371
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:325
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:637
Matrix type.
Definition: jas_seq.h:117
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:204
int_least64_t jas_fix_t
Definition: jas_fix.h:101