JasPer  3.0.1
jas_seq.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 1999-2000 Image Power, Inc. and the University of
3  * British Columbia.
4  * Copyright (c) 2001-2002 Michael David Adams.
5  * All rights reserved.
6  */
7 
8 /* __START_OF_JASPER_LICENSE__
9  *
10  * JasPer License Version 2.0
11  *
12  * Copyright (c) 2001-2006 Michael David Adams
13  * Copyright (c) 1999-2000 Image Power, Inc.
14  * Copyright (c) 1999-2000 The University of British Columbia
15  *
16  * All rights reserved.
17  *
18  * Permission is hereby granted, free of charge, to any person (the
19  * "User") obtaining a copy of this software and associated documentation
20  * files (the "Software"), to deal in the Software without restriction,
21  * including without limitation the rights to use, copy, modify, merge,
22  * publish, distribute, and/or sell copies of the Software, and to permit
23  * persons to whom the Software is furnished to do so, subject to the
24  * following conditions:
25  *
26  * 1. The above copyright notices and this permission notice (which
27  * includes the disclaimer below) shall be included in all copies or
28  * substantial portions of the Software.
29  *
30  * 2. The name of a copyright holder shall not be used to endorse or
31  * promote products derived from the Software without specific prior
32  * written permission.
33  *
34  * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS
35  * LICENSE. NO USE OF THE SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
36  * THIS DISCLAIMER. THE SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS
37  * "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
38  * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
39  * PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO
40  * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
41  * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
42  * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
43  * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
44  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. NO ASSURANCES ARE
45  * PROVIDED BY THE COPYRIGHT HOLDERS THAT THE SOFTWARE DOES NOT INFRINGE
46  * THE PATENT OR OTHER INTELLECTUAL PROPERTY RIGHTS OF ANY OTHER ENTITY.
47  * EACH COPYRIGHT HOLDER DISCLAIMS ANY LIABILITY TO THE USER FOR CLAIMS
48  * BROUGHT BY ANY OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL
49  * PROPERTY RIGHTS OR OTHERWISE. AS A CONDITION TO EXERCISING THE RIGHTS
50  * GRANTED HEREUNDER, EACH USER HEREBY ASSUMES SOLE RESPONSIBILITY TO SECURE
51  * ANY OTHER INTELLECTUAL PROPERTY RIGHTS NEEDED, IF ANY. THE SOFTWARE
52  * IS NOT FAULT-TOLERANT AND IS NOT INTENDED FOR USE IN MISSION-CRITICAL
53  * SYSTEMS, SUCH AS THOSE USED IN THE OPERATION OF NUCLEAR FACILITIES,
54  * AIRCRAFT NAVIGATION OR COMMUNICATION SYSTEMS, AIR TRAFFIC CONTROL
55  * SYSTEMS, DIRECT LIFE SUPPORT MACHINES, OR WEAPONS SYSTEMS, IN WHICH
56  * THE FAILURE OF THE SOFTWARE OR SYSTEM COULD LEAD DIRECTLY TO DEATH,
57  * PERSONAL INJURY, OR SEVERE PHYSICAL OR ENVIRONMENTAL DAMAGE ("HIGH
58  * RISK ACTIVITIES"). THE COPYRIGHT HOLDERS SPECIFICALLY DISCLAIM ANY
59  * EXPRESS OR IMPLIED WARRANTY OF FITNESS FOR HIGH RISK ACTIVITIES.
60  *
61  * __END_OF_JASPER_LICENSE__
62  */
63 
69 #ifndef JAS_SEQ_H
70 #define JAS_SEQ_H
71 
72 /******************************************************************************\
73 * Includes.
74 \******************************************************************************/
75 
76 /* The configuration header file should be included first. */
77 #include <jasper/jas_config.h> /* IWYU pragma: keep */
78 
79 #include <jasper/jas_types.h>
80 #include <jasper/jas_math.h>
81 
82 #include <stdio.h>
83 
84 #ifdef __cplusplus
85 extern "C" {
86 #endif
87 
93 /******************************************************************************\
94 * Constants.
95 \******************************************************************************/
96 
97 /* This matrix is a reference to another matrix. */
98 #define JAS_MATRIX_REF 0x0001
99 
100 /******************************************************************************\
101 * Types.
102 \******************************************************************************/
103 
104 /* An element in a sequence. */
105 #ifdef JAS_ENABLE_32BIT
106 typedef int_least32_t jas_seqent_t;
107 #define PRIjas_seqent PRIiLEAST32
108 #else
109 typedef int_fast32_t jas_seqent_t;
110 #define PRIjas_seqent PRIiFAST32
111 #endif
112 
113 /* An element in a matrix. */
114 #ifdef JAS_ENABLE_32BIT
115 typedef int_least32_t jas_matent_t;
116 #else
117 typedef int_fast32_t jas_matent_t;
118 #endif
119 
120 #ifdef JAS_ENABLE_32BIT
121 typedef int_least32_t jas_matind_t;
122 #else
123 typedef int_fast32_t jas_matind_t;
124 #endif
125 
129 typedef struct {
130 
131  /* Additional state information. */
132  int flags_;
133 
134  /* The starting horizontal index. */
135  jas_matind_t xstart_;
136 
137  /* The starting vertical index. */
138  jas_matind_t ystart_;
139 
140  /* The ending horizontal index. */
141  jas_matind_t xend_;
142 
143  /* The ending vertical index. */
144  jas_matind_t yend_;
145 
146  /* The number of rows in the matrix. */
147  jas_matind_t numrows_;
148 
149  /* The number of columns in the matrix. */
150  jas_matind_t numcols_;
151 
152  /* Pointers to the start of each row. */
153  jas_seqent_t **rows_;
154 
155  /* The allocated size of the rows array. */
156  int_fast32_t maxrows_;
157 
158  /* The matrix data buffer. */
159  jas_seqent_t *data_;
160 
161  /* The allocated size of the data array. */
162  int_fast32_t datasize_;
163 
164 } jas_matrix_t;
165 
170 typedef jas_matrix_t jas_seq2d_t;
171 
176 typedef jas_matrix_t jas_seq_t;
177 
178 /******************************************************************************\
179 * Functions/macros for matrix class.
180 \******************************************************************************/
181 
186 JAS_ATTRIBUTE_PURE
187 static inline jas_matind_t jas_matrix_numrows(const jas_matrix_t *matrix)
188 {
189  return matrix->numrows_;
190 }
191 
195 JAS_ATTRIBUTE_PURE
196 static inline jas_matind_t jas_matrix_numcols(const jas_matrix_t *matrix)
197 {
198  return matrix->numcols_;
199 }
200 
205 JAS_ATTRIBUTE_PURE
206 static inline jas_matind_t jas_matrix_size(const jas_matrix_t *matrix)
207 {
208  return jas_matrix_numcols(matrix) * jas_matrix_numrows(matrix);
209 }
210 
215 JAS_ATTRIBUTE_PURE
216 static inline bool jas_matrix_empty(const jas_matrix_t *matrix)
217 {
218  return jas_matrix_numcols(matrix) == 0 || jas_matrix_numrows(matrix) == 0;
219 }
220 
225 JAS_ATTRIBUTE_PURE
226 static inline jas_seqent_t jas_matrix_get(const jas_matrix_t *matrix, jas_matind_t i, jas_matind_t j)
227 {
228  assert(i >= 0 && i < matrix->numrows_ && j >= 0 && j < matrix->numcols_);
229  return matrix->rows_[i][j];
230 }
231 
236 static inline void jas_matrix_set(jas_matrix_t *matrix, jas_matind_t i, jas_matind_t j, jas_seqent_t v)
237 {
238  assert(i >= 0 && i < matrix->numrows_ && j >= 0 && j < matrix->numcols_);
239  matrix->rows_[i][j] = v;
240 }
241 
246 JAS_ATTRIBUTE_PURE
247 static inline jas_seqent_t jas_matrix_getv(const jas_matrix_t *matrix, jas_matind_t i)
248 {
249  return matrix->numrows_ == 1
250  ? matrix->rows_[0][i]
251  : matrix->rows_[i][0];
252 }
253 
258 static inline void jas_matrix_setv(jas_matrix_t *matrix, jas_matind_t i, jas_seqent_t v)
259 {
260  if (matrix->numrows_ == 1)
261  matrix->rows_[0][i] = v;
262  else
263  matrix->rows_[i][0] = v;
264 }
265 
270 JAS_ATTRIBUTE_PURE
271 static inline jas_seqent_t *jas_matrix_getref(const jas_matrix_t *matrix, jas_matind_t i, jas_matind_t j)
272 {
273  return &matrix->rows_[i][j];
274 }
275 
280 JAS_ATTRIBUTE_PURE
281 static inline jas_seqent_t *jas_matrix_getvref(const jas_matrix_t *matrix, jas_matind_t i)
282 {
283  return matrix->numrows_ > 1
284  ? jas_matrix_getref(matrix, i, 0)
285  : jas_matrix_getref(matrix, 0, i);
286 }
287 
292 JAS_EXPORT
293 jas_matrix_t *jas_matrix_create(jas_matind_t numrows, jas_matind_t numcols);
294 
299 JAS_EXPORT
300 void jas_matrix_destroy(jas_matrix_t *matrix);
301 
306 JAS_EXPORT
307 int jas_matrix_resize(jas_matrix_t *matrix, jas_matind_t numrows, jas_matind_t numcols);
308 
313 JAS_EXPORT
314 int jas_matrix_output(jas_matrix_t *matrix, FILE *out);
315 
320 JAS_EXPORT
321 int jas_matrix_bindsub(jas_matrix_t *mat0, jas_matrix_t *mat1, jas_matind_t r0,
322  jas_matind_t c0, jas_matind_t r1, jas_matind_t c1);
323 
328 static inline int jas_matrix_bindrow(jas_matrix_t *mat0, jas_matrix_t *mat1, jas_matind_t r)
329 {
330  return jas_matrix_bindsub(mat0, mat1, r, 0, r, mat1->numcols_ - 1);
331 }
332 
337 static inline int jas_matrix_bindcol(jas_matrix_t *mat0, jas_matrix_t *mat1, jas_matind_t c)
338 {
339  return jas_matrix_bindsub(mat0, mat1, 0, c, mat1->numrows_ - 1, c);
340 }
341 
346 JAS_EXPORT
347 void jas_matrix_clip(jas_matrix_t *matrix, jas_seqent_t minval,
348  jas_seqent_t maxval);
349 
354 JAS_EXPORT
355 void jas_matrix_asl(jas_matrix_t *matrix, unsigned n);
356 
361 JAS_EXPORT
362 void jas_matrix_asr(jas_matrix_t *matrix, unsigned n);
363 
368 JAS_EXPORT
369 void jas_matrix_divpow2(jas_matrix_t *matrix, unsigned n);
370 
375 JAS_EXPORT
376 void jas_matrix_setall(jas_matrix_t *matrix, jas_seqent_t val);
377 
382 JAS_ATTRIBUTE_PURE
383 static inline size_t jas_matrix_rowstep(const jas_matrix_t *matrix)
384 {
385  return matrix->numrows_ > 1
386  ? (size_t)(matrix->rows_[1] - matrix->rows_[0])
387  : 0u;
388 }
389 
394 JAS_ATTRIBUTE_PURE
395 static inline size_t jas_matrix_step(const jas_matrix_t *matrix)
396 {
397  return matrix->numrows_ > 1
398  ? jas_matrix_rowstep(matrix)
399  : 1;
400 }
401 
406 JAS_EXPORT
407 int jas_matrix_cmp(jas_matrix_t *mat0, jas_matrix_t *mat1);
408 
413 JAS_EXPORT
415 
420 JAS_EXPORT
422 
426 JAS_ATTRIBUTE_CONST
427 static inline jas_seqent_t jas_seqent_asl(jas_seqent_t x, unsigned n)
428 {
429 #ifdef JAS_ENABLE_32BIT
430  return jas_least32_asl(x, n);
431 #else
432  return jas_fast32_asl(x, n);
433 #endif
434 }
435 
439 JAS_ATTRIBUTE_CONST
440 static inline jas_seqent_t jas_seqent_asr(jas_seqent_t x, unsigned n)
441 {
442 #ifdef JAS_ENABLE_32BIT
443  return jas_least32_asr(x, n);
444 #else
445  return jas_fast32_asr(x, n);
446 #endif
447 }
448 
449 /******************************************************************************\
450 * Functions/macros for 2-D sequence class.
451 \******************************************************************************/
452 
457 JAS_EXPORT
459 
464 JAS_EXPORT
465 jas_matrix_t *jas_seq2d_create(jas_matind_t xstart, jas_matind_t ystart,
466  jas_matind_t xend, jas_matind_t yend);
467 
472 static inline void jas_seq2d_destroy(jas_seq2d_t *s)
473 {
475 }
476 
481 JAS_ATTRIBUTE_PURE
482 static inline jas_matind_t jas_seq2d_xstart(const jas_seq2d_t *s)
483 {
484  return s->xstart_;
485 }
486 
491 JAS_ATTRIBUTE_PURE
492 static inline jas_matind_t jas_seq2d_ystart(const jas_seq2d_t *s)
493 {
494  return s->ystart_;
495 }
496 
501 JAS_ATTRIBUTE_PURE
502 static inline jas_matind_t jas_seq2d_xend(const jas_seq2d_t *s)
503 {
504  return s->xend_;
505 }
506 
511 JAS_ATTRIBUTE_PURE
512 static inline jas_matind_t jas_seq2d_yend(const jas_seq2d_t *s)
513 {
514  return s->yend_;
515 }
516 
521 JAS_ATTRIBUTE_PURE
522 static inline jas_seqent_t *jas_seq2d_getref(const jas_seq2d_t *s, jas_matind_t x, jas_matind_t y)
523 {
524  return jas_matrix_getref(s, y - s->ystart_, x - s->xstart_);
525 }
526 
531 JAS_ATTRIBUTE_PURE
532 static inline jas_seqent_t jas_seq2d_get(const jas_seq2d_t *s, jas_matind_t x, jas_matind_t y)
533 {
534  return jas_matrix_get(s, y - s->ystart_, x - s->xstart_);
535 }
536 
541 JAS_ATTRIBUTE_PURE
542 static inline size_t jas_seq2d_rowstep(const jas_seq2d_t *s)
543 {
544  return jas_matrix_rowstep(s);
545 }
546 
551 JAS_ATTRIBUTE_PURE
552 static inline unsigned jas_seq2d_width(const jas_seq2d_t *s)
553 {
554  return (unsigned)(s->xend_ - s->xstart_);
555 }
556 
561 JAS_ATTRIBUTE_PURE
562 static inline unsigned jas_seq2d_height(const jas_seq2d_t *s)
563 {
564  return (unsigned)(s->yend_ - s->ystart_);
565 }
566 
571 static inline void jas_seq2d_setshift(jas_seq2d_t *s, jas_matind_t x, jas_matind_t y)
572 {
573  s->xstart_ = x;
574  s->ystart_ = y;
575  s->xend_ = s->xstart_ + s->numcols_;
576  s->yend_ = s->ystart_ + s->numrows_;
577 }
578 
583 JAS_ATTRIBUTE_PURE
584 static inline jas_matind_t jas_seq2d_size(const jas_seq2d_t *s)
585 {
586  return jas_seq2d_width(s) * jas_seq2d_height(s);
587 }
588 
593 JAS_ATTRIBUTE_PURE
594 static inline bool jas_seq2d_empty(const jas_seq2d_t *s)
595 {
596  return jas_seq2d_width(s) == 0 || jas_seq2d_height(s) == 0;
597 }
598 
603 JAS_EXPORT
604 int jas_seq2d_bindsub(jas_matrix_t *s, jas_matrix_t *s1, jas_matind_t xstart,
605  jas_matind_t ystart, jas_matind_t xend, jas_matind_t yend);
606 
607 /******************************************************************************\
608 * Functions/macros for 1-D sequence class.
609 \******************************************************************************/
610 
615 static inline jas_seq_t *jas_seq_create(jas_matind_t start, jas_matind_t end)
616 {
617  return jas_seq2d_create(start, 0, end, 1);
618 }
619 
624 static inline void jas_seq_destroy(jas_seq_t *seq)
625 {
626  jas_seq2d_destroy(seq);
627 }
628 
633 static inline void jas_seq_set(jas_seq_t *seq, jas_matind_t i, jas_seqent_t v)
634 {
635  seq->rows_[0][i - seq->xstart_] = v;
636 }
637 
642 JAS_ATTRIBUTE_PURE
643 static inline jas_seqent_t *jas_seq_getref(const jas_seq_t *seq, jas_matind_t i)
644 {
645  return &seq->rows_[0][i - seq->xstart_];
646 }
647 
652 JAS_ATTRIBUTE_PURE
653 static inline jas_seqent_t jas_seq_get(const jas_seq_t *seq, jas_matind_t i)
654 {
655  return seq->rows_[0][i - seq->xstart_];
656 }
657 
662 JAS_ATTRIBUTE_PURE
663 static inline jas_matind_t jas_seq_start(const jas_seq_t *seq)
664 {
665  return seq->xstart_;
666 }
667 
672 JAS_ATTRIBUTE_PURE
673 static inline jas_matind_t jas_seq_end(const jas_seq_t *seq)
674 {
675  return seq->xend_;
676 }
677 
682 #ifdef __cplusplus
683 }
684 #endif
685 
686 #endif
jas_seq2d_setshift
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
jas_seq2d_ystart
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_matrix_output
JAS_EXPORT int jas_matrix_output(jas_matrix_t *matrix, FILE *out)
Write a matrix to a C standard library stream.
jas_matrix_setv
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
jas_seq_create
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
jas_seq2d_yend
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
jas_malloc.h
JasPer Memory Allocator.
jas_matrix_divpow2
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
jas_seq_end
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
jas_seq2d_size
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
jas_matrix_setall
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
jas_matrix_step
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
jas_matrix_cmp
int jas_matrix_cmp(jas_matrix_t *mat0, jas_matrix_t *mat1)
Compare two matrices for equality.
Definition: jas_seq.c:257
jas_seq_destroy
static void jas_seq_destroy(jas_seq_t *seq)
Destroy a 1-D sequence.
Definition: jas_seq.h:624
jas_seq_start
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
jas_matrix_size
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
jas_seq2d_bindsub
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
jas_alloc2
void * jas_alloc2(size_t num_elements, size_t element_size)
Allocate array (with overflow checking).
Definition: jas_malloc.c:212
jas_matrix_bindsub
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
jas_matrix_numcols
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
jas_seq2d_get
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
jas_seq2d_destroy
static void jas_seq2d_destroy(jas_seq2d_t *s)
Destroy a 2-D sequence.
Definition: jas_seq.h:472
jas_matrix_input
JAS_EXPORT jas_matrix_t * jas_matrix_input(FILE *)
Read a matrix from a C standard library stream.
jas_matrix_numrows
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
jas_matrix_getv
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_create
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_malloc
JAS_EXPORT void * jas_malloc(size_t size)
Allocate memory.
Definition: jas_malloc.c:136
jas_seq_set
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
jas_seq2d_xend
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
jas_seq.h
Sequence/Matrix Library.
jas_debug.h
JasPer Debugging-Related Functionality.
jas_seq2d_height
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
jas_matrix_getvref
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_copy
jas_matrix_t * jas_matrix_copy(jas_matrix_t *x)
Copy a matrix.
Definition: jas_seq.c:188
jas_free
JAS_EXPORT void jas_free(void *ptr)
Free memory.
Definition: jas_malloc.c:186
jas_seq_t
One-dimensional sequence type.
jas_types.h
Primitive Types.
jas_matrix_getref
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
jas_seq_get
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
jas_matrix_get
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
jas_matrix_clip
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
jas_matrix_asr
void jas_matrix_asr(jas_matrix_t *matrix, unsigned n)
Arithmetic shift right of all elements in a matrix.
Definition: jas_seq.c:327
jas_seq2d_rowstep
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
jas_seq2d_width
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
jas_seq2d_empty
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
jas_math.h
Math-Related Code.
jas_seq2d_xstart
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
jas_matrix_bindrow
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_seq2d_create
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
jas_matrix_set
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
jas_seq2d_t
Two-dimensional sequence type.
jas_matrix_resize
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
jas_matrix_destroy
void jas_matrix_destroy(jas_matrix_t *matrix)
Destroy a matrix.
Definition: jas_seq.c:162
jas_seq2d_getref
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
jas_matrix_rowstep
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
jas_matrix_bindcol
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_copy
jas_seq2d_t * jas_seq2d_copy(jas_seq2d_t *x)
Copy a 2-D sequence.
Definition: jas_seq.c:172
jas_seq_getref
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
jas_matrix_t
Matrix type.
Definition: jas_seq.h:129
jas_matrix_asl
void jas_matrix_asl(jas_matrix_t *matrix, unsigned n)
Arithmetic shift left of all elements in a matrix.
Definition: jas_seq.c:349
jas_matrix_empty
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