~kamalmostafa/ubuntu/lucid/pdp/fix-504941-ftbfs

« back to all changes in this revision

Viewing changes to modules/matrix_basic/pdp_mat_lu.c

  • Committer: Bazaar Package Importer
  • Author(s): Guenter Geiger (Debian/GNU)
  • Date: 2005-03-15 22:21:05 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050315222105-1q287rsihmd9j1tb
Tags: 1:0.12.4-2
* fixed the hardcoded depends
* added 3dp library

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 *   Pure Data Packet module. LU decomposition module.
3
 
 *   Copyright (c) by Tom Schouten <pdp@zzz.kotnet.org>
4
 
 *
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.
9
 
 *
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.
14
 
 *
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.
18
 
 *
19
 
 */
20
 
 
21
 
//#include <gsl/gsl_block.h>
22
 
//#include <gsl/gsl_vector.h>
23
 
//#include <gsl/gsl_matrix.h>
24
 
//#include <gsl/gsl_blas.h>
25
 
#include "pdp.h"
26
 
#include "pdp_base.h"
27
 
 
28
 
 
29
 
typedef struct pdp_mat_LU_struct
30
 
{
31
 
    t_pdp_base x_base;
32
 
 
33
 
} t_pdp_mat_LU;
34
 
 
35
 
 
36
 
 
37
 
static void pdp_mat_LU_process_LU_inverse(t_pdp_mat_LU *x)
38
 
{
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
42
 
}
43
 
 
44
 
static void pdp_mat_LU_process_LU(t_pdp_mat_LU *x)
45
 
{
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
49
 
}
50
 
 
51
 
static void pdp_mat_LU_process_LU_solve(t_pdp_mat_LU *x)
52
 
{
53
 
    int p0 = pdp_base_get_packet(x, 0);
54
 
    int p1 = pdp_base_get_packet(x, 1);
55
 
    int pvr, pm, pv;
56
 
 
57
 
    /* determine which is vector and which is matrix */
58
 
    if (pdp_packet_matrix_ismatrix(p0) && pdp_packet_matrix_isvector(p1)){
59
 
        pm = p0;
60
 
        pv = p1;
61
 
    }
62
 
    else {
63
 
        pm = p1;
64
 
        pv = p0;
65
 
    }
66
 
 
67
 
    /* create the result vector */
68
 
    pvr = pdp_packet_matrix_LU_solve(pm, pv);
69
 
 
70
 
    /* replace the active packet */
71
 
    pdp_base_set_packet(x, 0, pvr);
72
 
}
73
 
 
74
 
static void pdp_mat_LU_free(t_pdp_mat_LU *x)
75
 
{
76
 
    /* remove process method from queue before deleting data */
77
 
    pdp_base_free(x);
78
 
}
79
 
 
80
 
t_class *pdp_mat_LU_class;
81
 
 
82
 
 
83
 
/* common new methods */
84
 
t_pdp_mat_LU *pdp_mat_LU_base_new(void)
85
 
{
86
 
    t_pdp_mat_LU *x = (t_pdp_mat_LU *)pd_new(pdp_mat_LU_class);
87
 
    pdp_base_init(x);
88
 
    pdp_base_add_pdp_outlet(x);
89
 
    return x;
90
 
}
91
 
 
92
 
void *pdp_mat_LU_inverse_new(void)
93
 
{
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);
97
 
    return (void *)x;
98
 
}
99
 
 
100
 
 
101
 
void *pdp_mat_LU_new(void)
102
 
{
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);
106
 
    return (void *)x;
107
 
}
108
 
 
109
 
void *pdp_mat_LU_solve_new(void)
110
 
{
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);
115
 
    return (void *)x;
116
 
}
117
 
 
118
 
#ifdef __cplusplus
119
 
extern "C"
120
 
{
121
 
#endif
122
 
 
123
 
 
124
 
void pdp_mat_lu_setup(void)
125
 
{
126
 
 
127
 
 
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);
130
 
 
131
 
    pdp_base_setup(pdp_mat_LU_class);
132
 
 
133
 
 
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);
136
 
 
137
 
 
138
 
 
139
 
}
140
 
 
141
 
#ifdef __cplusplus
142
 
}
143
 
#endif