1 /*********************************************************************/
2 /*                                                                   */
3 /*            Nagoya Institute of Technology, Aichi, Japan,          */
4 /*       Nara Institute of Science and Technology, Nara, Japan       */
5 /*                                and                                */
6 /*             Carnegie Mellon University, Pittsburgh, PA            */
7 /*                      Copyright (c) 2003-2004                      */
8 /*                        All Rights Reserved.                       */
9 /*                                                                   */
10 /*  Permission is hereby granted, free of charge, to use and         */
11 /*  distribute this software and its documentation without           */
12 /*  restriction, including without limitation the rights to use,     */
13 /*  copy, modify, merge, publish, distribute, sublicense, and/or     */
14 /*  sell copies of this work, and to permit persons to whom this     */
15 /*  work is furnished to do so, subject to the following conditions: */
16 /*                                                                   */
17 /*    1. The code must retain the above copyright notice, this list  */
18 /*       of conditions and the following disclaimer.                 */
19 /*    2. Any modifications must be clearly marked as such.           */
20 /*    3. Original authors' names are not deleted.                    */
21 /*                                                                   */
22 /*  NAGOYA INSTITUTE OF TECHNOLOGY, NARA INSTITUTE OF SCIENCE AND    */
23 /*  TECHNOLOGY, CARNEGIE MELLON UNIVERSITY, AND THE CONTRIBUTORS TO  */
24 /*  THIS WORK DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,  */
25 /*  INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, */
26 /*  IN NO EVENT SHALL NAGOYA INSTITUTE OF TECHNOLOGY, NARA           */
27 /*  INSTITUTE OF SCIENCE AND TECHNOLOGY, CARNEGIE MELLON UNIVERSITY, */
28 /*  NOR THE CONTRIBUTORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR      */
29 /*  CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM   */
30 /*  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,  */
31 /*  NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN        */
32 /*  CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.         */
33 /*                                                                   */
34 /*********************************************************************/
35 /*                                                                   */
36 /*          Author :  Tomoki Toda (tomoki@ics.nitech.ac.jp)          */
37 /*          Date   :  June 2004                                      */
38 /*                                                                   */
39 /* Functions shared between mlpg and mlsa                            */
40 /*-------------------------------------------------------------------*/
41 
42 #ifndef __CST_VC_H
43 #define __CST_VC_H
44 
45 typedef struct LVECTOR_STRUCT {
46     long length;
47     long *data;
48     long *imag;
49 } *LVECTOR;
50 
51 typedef struct DVECTOR_STRUCT {
52     long length;
53     double *data;
54     double *imag;
55 } *DVECTOR;
56 
57 typedef struct DMATRIX_STRUCT {
58     long row;
59     long col;
60     double **data;
61     double **imag;
62 } *DMATRIX;
63 
64 #define XBOOL int
65 #define XTRUE 1
66 #define XFALSE 0
67 
68 #define NODATA NULL
69 
70 #define FABS(x) ((x) >= 0.0 ? (x) : -(x))
71 #define LABS(x) ((x) >= 0 ? (x) : -(x))
72 #define MAX(a, b) ((a) > (b) ? (a) : (b))
73 
74 #define xdvnull() xdvalloc(0)
75 
76 #define xdvnums(length, value) xdvinit((double)(value), 0.0, (double)(length))
77 #define xdvzeros(length) xdvnums(length, 0.0)
78 
79 LVECTOR xlvalloc(long length);
80 void xlvfree(LVECTOR x);
81 DVECTOR xdvalloc(long length);
82 DVECTOR xdvcut(DVECTOR x, long offset, long length);
83 void xdvfree(DVECTOR vector);
84 double dvmax(DVECTOR x, long *index);
85 double dvmin(DVECTOR x, long *index);
86 DMATRIX xdmalloc(long row, long col);
87 void xdmfree(DMATRIX matrix);
88 DVECTOR xdvinit(double j, double incr, double n);
89 
90 double dvsum(DVECTOR x);
91 
92 #define RANDMAX 32767
93 #define   B0         0x00000001
94 #define   B28        0x10000000
95 #define   B31        0x80000000
96 #define   B31_       0x7fffffff
97 #define   Z          0x00000000
98 
99 typedef enum {MFALSE, MTRUE} Boolean;
100 
101 #endif /* __CST_VC_H */
102