2
* Pure Data Packet module. LU decomposition module.
3
* Copyright (c) by Tom Schouten <pdp@zzz.kotnet.org>
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21
//#include <gsl/gsl_block.h>
22
//#include <gsl/gsl_vector.h>
23
//#include <gsl/gsl_matrix.h>
24
//#include <gsl/gsl_blas.h>
29
typedef struct pdp_mat_LU_struct
37
static void pdp_mat_LU_process_LU_inverse(t_pdp_mat_LU *x)
39
int p = pdp_base_get_packet(x, 0);
40
int p_LU = pdp_packet_matrix_LU_to_inverse(p);
41
pdp_base_set_packet(x, 0, p_LU); // replace packet
44
static void pdp_mat_LU_process_LU(t_pdp_mat_LU *x)
46
int p = pdp_base_get_packet(x, 0);
47
int p_LU = pdp_packet_matrix_LU(p);
48
pdp_base_set_packet(x, 0, p_LU); // replace packet
51
static void pdp_mat_LU_process_LU_solve(t_pdp_mat_LU *x)
53
int p0 = pdp_base_get_packet(x, 0);
54
int p1 = pdp_base_get_packet(x, 1);
57
/* determine which is vector and which is matrix */
58
if (pdp_packet_matrix_ismatrix(p0) && pdp_packet_matrix_isvector(p1)){
67
/* create the result vector */
68
pvr = pdp_packet_matrix_LU_solve(pm, pv);
70
/* replace the active packet */
71
pdp_base_set_packet(x, 0, pvr);
74
static void pdp_mat_LU_free(t_pdp_mat_LU *x)
76
/* remove process method from queue before deleting data */
80
t_class *pdp_mat_LU_class;
83
/* common new methods */
84
t_pdp_mat_LU *pdp_mat_LU_base_new(void)
86
t_pdp_mat_LU *x = (t_pdp_mat_LU *)pd_new(pdp_mat_LU_class);
88
pdp_base_add_pdp_outlet(x);
92
void *pdp_mat_LU_inverse_new(void)
94
t_pdp_mat_LU *x = pdp_mat_LU_base_new();
95
pdp_base_set_process_method(x,(t_pdp_method)pdp_mat_LU_process_LU_inverse);
96
pdp_base_readonly_active_inlet(x);
101
void *pdp_mat_LU_new(void)
103
t_pdp_mat_LU *x = pdp_mat_LU_base_new();
104
pdp_base_set_process_method(x,(t_pdp_method)pdp_mat_LU_process_LU);
105
pdp_base_readonly_active_inlet(x);
109
void *pdp_mat_LU_solve_new(void)
111
t_pdp_mat_LU *x = pdp_mat_LU_base_new();
112
pdp_base_set_process_method(x,(t_pdp_method)pdp_mat_LU_process_LU_solve);
113
pdp_base_readonly_active_inlet(x);
114
pdp_base_add_pdp_inlet(x);
124
void pdp_mat_lu_setup(void)
128
pdp_mat_LU_class = class_new(gensym("pdp_m_LU_inverse"), (t_newmethod)pdp_mat_LU_inverse_new,
129
(t_method)pdp_mat_LU_free, sizeof(t_pdp_mat_LU), 0, A_NULL);
131
pdp_base_setup(pdp_mat_LU_class);
134
class_addcreator((t_newmethod)pdp_mat_LU_new, gensym("pdp_m_LU"), A_NULL);
135
class_addcreator((t_newmethod)pdp_mat_LU_solve_new, gensym("pdp_m_LU_solve"), A_NULL);