1 // Copyright (c) 2015-2016, Massachusetts Institute of Technology
2 // Copyright (c) 2016-2017 Sandia Corporation
3 // Copyright (c) 2017 NTESS, LLC.
4 
5 // This file is part of the Compressed Continuous Computation (C3) Library
6 // Author: Alex A. Gorodetsky
7 // Contact: alex@alexgorodetsky.com
8 
9 // All rights reserved.
10 
11 // Redistribution and use in source and binary forms, with or without modification,
12 // are permitted provided that the following conditions are met:
13 
14 // 1. Redistributions of source code must retain the above copyright notice,
15 //    this list of conditions and the following disclaimer.
16 
17 // 2. Redistributions in binary form must reproduce the above copyright notice,
18 //    this list of conditions and the following disclaimer in the documentation
19 //    and/or other materials provided with the distribution.
20 
21 // 3. Neither the name of the copyright holder nor the names of its contributors
22 //    may be used to endorse or promote products derived from this software
23 //    without specific prior written permission.
24 
25 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28 // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
29 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
33 // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 
36 //Code
37 
38 
39 
40 
41 
42 /** \file quasimatrix.h
43  Provides header files for quasimatrix.c
44 */
45 
46 #ifndef QUASIMATRIX_H
47 #define QUASIMATRIX_H
48 
49 #include "lib_funcs.h"
50 
51 struct Quasimatrix;
52 
53 // allocation
54 struct Quasimatrix *
55 quasimatrix_alloc(size_t);
56 void quasimatrix_free_funcs(struct Quasimatrix *);
57 void quasimatrix_free(struct Quasimatrix *);
58 
59 
60 // getting and setting
61 size_t quasimatrix_get_size(const struct Quasimatrix *);
62 void quasimatrix_set_size(struct Quasimatrix *,size_t);
63 struct GenericFunction *
64 quasimatrix_get_func(const struct Quasimatrix *, size_t);
65 void
66 quasimatrix_set_func(struct Quasimatrix *,
67                      const struct GenericFunction *,
68                      size_t);
69 
70 struct GenericFunction **
71 quasimatrix_get_funcs(const struct Quasimatrix *);
72 void quasimatrix_set_funcs(struct Quasimatrix *, struct GenericFunction **);
73 void
74 quasimatrix_get_funcs_ref(const struct Quasimatrix *,struct GenericFunction ***);
75 
76 /* struct Quasimatrix * */
77 /* quasimatrix_init(size_t,size_t,enum function_class *,void **, */
78 /*                  void **,void **);     */
79 
80 struct Quasimatrix *
81 quasimatrix_approx1d(size_t, struct Fwrap *,
82                      enum function_class *,
83                      void *);
84 
85 /* struct Quasimatrix *  */
86 /* quasimatrix_approx_from_fiber_cuts(size_t, */
87 /*                                    double (*)(double, void *), */
88 /*                                    struct FiberCut **, */
89 /*                                    enum function_class, */
90 /*                                    void *, double, */
91 /*                                    double, void *); */
92 
93 struct Quasimatrix *
94 quasimatrix_copy(const struct Quasimatrix *);
95 
96 unsigned char *
97 quasimatrix_serialize(unsigned char *,
98                       const struct Quasimatrix *,
99                       size_t *);
100 unsigned char *
101 quasimatrix_deserialize(unsigned char *,
102                         struct Quasimatrix **);
103 
104 
105 struct Quasimatrix *
106 quasimatrix_orth1d(size_t,enum function_class,void *);
107 
108 size_t
109 quasimatrix_absmax(struct Quasimatrix *,
110                    double *,double *,void*);
111 
112 ///////////////////////////////////////////
113 // Linear Algebra
114 ///////////////////////////////////////////
115 
116 // (quasimatrix - vector multiplication
117 double quasimatrix_inner(const struct Quasimatrix *,
118                          const struct Quasimatrix *);
119 struct GenericFunction *
120 qmv(const struct Quasimatrix *, const double *);
121 struct Quasimatrix * qmm(const struct Quasimatrix *,
122                          const double *,size_t);
123 struct Quasimatrix * qmmt(const struct Quasimatrix*,
124                           const double *,size_t);
125 struct Quasimatrix *
126 quasimatrix_daxpby(double, const struct Quasimatrix *,
127                    double, const struct Quasimatrix *);
128 
129 
130 // decompositions
131 struct Quasimatrix *
132 quasimatrix_householder_simple(struct Quasimatrix *,double *,void*);
133 int quasimatrix_householder(struct Quasimatrix *,
134                             struct Quasimatrix *,
135                             struct Quasimatrix *, double *);
136 
137 int quasimatrix_qhouse(struct Quasimatrix *,
138                        struct Quasimatrix *);
139 
140 int quasimatrix_lu1d(struct Quasimatrix *,
141                      struct Quasimatrix *,
142                      double *,double *,void*,void *);
143 
144 int quasimatrix_maxvol1d(struct Quasimatrix *,
145                          double *, double *,void*,void*);
146 
147 size_t quasimatrix_rank(const struct Quasimatrix *,void*);
148 double quasimatrix_norm(const struct Quasimatrix *);
149 
150 
151 // Utilities
152 void quasimatrix_print(const struct Quasimatrix *,FILE *,
153                        size_t, void *);
154 
155 #endif
156