1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
/*
VASP modular - vector assembling signal processor / objects for Max/MSP and PD
Copyright (c) 2002 Thomas Grill (xovo@gmx.net)
For information on usage and redistribution, and for a DISCLAIMER OF ALL
WARRANTIES, see the file, "license.txt," in this distribution.
*/
#include "main.h"
#include "classes.h"
#include "util.h"
/*! \class vasp_list
\remark \b vasp.list
\brief Get samples of a single vasp vector.
\since 0.0.1
\param inlet vasp - is stored and output triggered
\param inlet bang - triggers output
\param inlet set - vasp to be stored
\retval outlet vector - vasp samples
\note Outputs 0 if vasp is undefined or invalid
\note Only works for a vasp with one vector. No output otherwise.
*/
class vasp_list:
public vasp_op
{
FLEXT_HEADER(vasp_list,vasp_op)
public:
vasp_list()
{
AddInAnything();
AddOutList();
}
virtual V m_bang()
{
if(!ref.Ok())
post("%s - Invalid vasp!",thisName());
else if(ref.Vectors() > 1)
post("%s - More than one vector in vasp!",thisName());
else {
VBuffer *buf = ref.Buffer(0);
I cnt = buf->Length();
S *p = buf->Pointer();
AtomList lst(cnt);
for(I i = 0; i < cnt; ++i,++p) SetFloat(lst[i],*p);
ToOutList(0,lst);
delete buf;
}
}
virtual V m_help() { post("%s - Get list of samples of a vasp vector",thisName()); }
};
FLEXT_LIB("vasp, vasp.list vasp.?",vasp_list)
/*! \class vasp_nonzero
\remark \b vasp.nonzero
\brief Get samples of a single vasp vector.
\since 0.0.2
\param inlet vasp - is stored and output triggered
\param inlet bang - triggers output
\param inlet set - vasp to be stored
\retval outlet.0 list - non-zero samples positions
\retval outlet.1 list - non-zero sample values
\note Outputs 0 if vasp is undefined or invalid
\note Only works for a vasp with one vector. No output otherwise.
\todo units for position list
*/
class vasp_nonzero:
public vasp_op
{
FLEXT_HEADER(vasp_nonzero,vasp_op)
public:
vasp_nonzero()
{
AddInAnything();
AddOutList(2);
}
virtual V m_bang()
{
if(!ref.Ok())
post("%s - Invalid vasp!",thisName());
else if(ref.Vectors() > 1)
post("%s - More than one vector in vasp!",thisName());
else {
VBuffer *buf = ref.Buffer(0);
I i,cnt = buf->Length(),cp,ci;
S *p = buf->Pointer();
for(cp = i = 0; i < cnt; ++i,++p) if(*p) ++cp;
AtomList pos(cp),lst(cp);
p = buf->Pointer();
for(ci = i = 0; ci < cp; ++i,++p)
if(*p) {
SetFloat(pos[ci],i);
SetFloat(lst[ci],*p);
++ci;
}
ToOutList(0,pos);
ToOutList(1,lst);
delete buf;
}
}
virtual V m_help() { post("%s - Get list of non-zero samples of a vasp vector",thisName()); }
};
FLEXT_LIB("vasp, vasp.nonzero vasp.??",vasp_nonzero)
|