aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormusil <tmusil@users.sourceforge.net>2006-11-30 12:46:20 +0000
committermusil <tmusil@users.sourceforge.net>2006-11-30 12:46:20 +0000
commita6395245153880a8b67f49631d3c5208c636a940 (patch)
tree0431e66f94c9353e7705d0108a722c2d49e43f22
initial commitsvn2git-root
changed float to t_float -fno-strict-aliasing #pragma obsolete help-*.pd to *-help.pd svn path=/trunk/externals/iem/iem_matrix/; revision=6543
-rw-r--r--GnuGPL.txt340
-rw-r--r--LICENSE.txt27
-rw-r--r--READ_ME.txt22
-rw-r--r--help/matrix_bundle_stat~-help.pd100
-rw-r--r--help/matrix_diag_mul_line8~-help.pd91
-rw-r--r--help/matrix_diag_mul_line~-help.pd89
-rw-r--r--help/matrix_diag_mul_stat~-help.pd77
-rw-r--r--help/matrix_mul_line8~-help.pd113
-rw-r--r--help/matrix_mul_line~-help.pd111
-rw-r--r--help/matrix_mul_stat~-help.pd99
-rw-r--r--src/iem_matrix.c44
-rw-r--r--src/iem_matrix.dsp85
-rw-r--r--src/iem_matrix.dsw29
-rw-r--r--src/iemlib.h108
-rw-r--r--src/makefile55
-rw-r--r--src/makefile_linux55
-rw-r--r--src/makefile_win46
-rw-r--r--src/matrix_bundle_line8~.c479
-rw-r--r--src/matrix_bundle_line~.c493
-rw-r--r--src/matrix_bundle_stat~.c283
-rw-r--r--src/matrix_diag_mul_line8~.c409
-rw-r--r--src/matrix_diag_mul_line~.c415
-rw-r--r--src/matrix_diag_mul_stat~.c269
-rw-r--r--src/matrix_mul_line8~.c657
-rw-r--r--src/matrix_mul_line~.c686
-rw-r--r--src/matrix_mul_stat~.c462
-rw-r--r--src/matrix_orthogonal.c161
-rw-r--r--src/matrix_pinv.c600
-rw-r--r--src/spherical_line.c264
29 files changed, 6669 insertions, 0 deletions
diff --git a/GnuGPL.txt b/GnuGPL.txt
new file mode 100644
index 0000000..d60c31a
--- /dev/null
+++ b/GnuGPL.txt
@@ -0,0 +1,340 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Library General
+Public License instead of this License.
diff --git a/LICENSE.txt b/LICENSE.txt
new file mode 100644
index 0000000..e560b1f
--- /dev/null
+++ b/LICENSE.txt
@@ -0,0 +1,27 @@
+iem_matrix - dynamic library for pd; some signal matrices multiplier
+
+Copyright (C) 2000-2006 Thomas MUSIL [musil_at_iem.at]
+
+IEM - Institute of Electronic Music and Acoustics, Graz
+Inffeldgasse 10/3, 8010 Graz, Austria
+http://iem.at
+
+
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details ( GnuGPL.txt ).
+ (e.g. http://www.gnu.org/copyleft/gpl.html)
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Graz, 15 Nov. 2006
+ Thomas Musil \ No newline at end of file
diff --git a/READ_ME.txt b/READ_ME.txt
new file mode 100644
index 0000000..efaab73
--- /dev/null
+++ b/READ_ME.txt
@@ -0,0 +1,22 @@
+This library extends the performance of miller puckette's pure data (pd).
+
+iem_matrix is written by Thomas Musil from IEM Graz Austria
+ and it is compatible to miller puckette's pd-0.37-3 to pd-0.39-2.
+see also LICENCE.txt, GnuGPL.txt.
+
+iem_matrix contains 7 objects:
+"matrix_bundle_stat~",
+"matrix_diag_mul_line8~", "matrix_diag_mul_line~", "matrix_diag_mul_stat~",
+"matrix_mul_line8~", "matrix_mul_line~" and "matrix_mul_stat~".
+
+matrix_mul_*~ multiplies a message matrix with a signal array.
+matrix_diag_mul_*~ multiplies a message diagonal matrix with a signal array.
+matrix_bundle_*~ is a kind of additive signal multiplexer.
+
+The extension *_line~ means, each matrix message element will be interpolated
+ from the previous to the current vallue by a signal ramp (like line~ does).
+The extension *_line8~ means, each matrix message element will be interpolated
+ everey 8 samples from the previous to the current vallue by a signal ramp
+ (this ramp has little steps, only every 8 sample, the value change).
+The extension *_stat~ means, each new matrix message element change the
+ signal matrix multiplicator, there is no interpolation (like sig~ does). \ No newline at end of file
diff --git a/help/matrix_bundle_stat~-help.pd b/help/matrix_bundle_stat~-help.pd
new file mode 100644
index 0000000..253417c
--- /dev/null
+++ b/help/matrix_bundle_stat~-help.pd
@@ -0,0 +1,100 @@
+#N canvas 54 38 886 656 10;
+#X obj 18 44 dsp;
+#X obj 18 14 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1
+;
+#X floatatom 18 100 5 0 0 0 - - -;
+#X floatatom 33 74 5 0 0 0 - - -;
+#X obj 47 459 matrix_bundle_stat~ 5 2;
+#X obj 46 347 sig~ 1;
+#X obj 80 369 sig~ 2;
+#X obj 114 391 sig~ 4;
+#X obj 146 413 sig~ 8;
+#X obj 180 436 sig~ 16;
+#X obj 47 488 unsig~;
+#X floatatom 47 512 5 0 0 0 - - -;
+#X obj 180 487 unsig~;
+#X floatatom 180 511 5 0 0 0 - - -;
+#X obj 239 442 any;
+#X msg 239 94 bundle 0 0 0 0 0;
+#X msg 239 120 bundle 1 1 1 1 1;
+#X msg 239 141 bundle 2 2 2 2 2;
+#X msg 239 167 bundle 1 0 0 0 0;
+#X msg 239 187 bundle 0 1 0 0 0;
+#X msg 239 207 bundle 0 0 1 0 0;
+#X msg 239 227 bundle 0 0 0 1 0;
+#X msg 239 247 bundle 0 0 0 0 1;
+#X msg 239 273 bundle 2 0 0 0 0;
+#X msg 239 293 bundle 0 2 0 0 0;
+#X msg 239 313 bundle 0 0 2 0 0;
+#X msg 239 333 bundle 0 0 0 2 0;
+#X msg 239 353 bundle 0 0 0 0 2;
+#X obj 392 442 pp element;
+#X obj 392 419 pack 0 0;
+#X obj 392 397 f;
+#X floatatom 435 368 4 1 5 0 - - -;
+#X floatatom 405 368 4 0 2 0 - - -;
+#X obj 382 375 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
+-1;
+#X text 671 16 SIG_OUT = A * SIG_IN;
+#X text 690 34 A is quadratic;
+#X text 627 51 dim(SIG_OUT) = dim(SIG_IN) = n;
+#X text 88 15 matrix_bundle_stat~;
+#X text 234 51 each matrix-column has only one one \, the other elements
+are zero;
+#X text 261 475 2.arg <float> Nr. of outlets = rows;
+#X text 261 464 1.arg <float> Nr. of inlets = columns;
+#X text 477 336 message "element";
+#X text 491 365 2.) item <float> column_index (1 .. nr_columns);
+#X text 491 353 1.) item <float> row_index (0 .. nr_rows);
+#X text 446 111 message "bundle";
+#X text 516 381 where the single one of the column will be placed;
+#X text 517 393 if (row-index == 0) -> the column has only zeros;
+#X text 449 126 (nr_inlets = nr_columns) <float> row-indices (0 ..
+nr_row);
+#X text 454 162 if (row-index == 0) -> the column has only zeros;
+#X text 453 150 where the single one of each column will be placed
+;
+#X msg 239 383 bundle 1 1 2 1 2;
+#X msg 239 403 bundle 2 2 1 2 1;
+#X text 78 585 IEM KUG;
+#X text 62 573 musil;
+#X text 92 573 @;
+#X text 98 573 iem.at;
+#X text 61 595 Graz \, Austria;
+#X text 13 562 (c) Thomas Musil 2000 - 2006;
+#X text 234 14 multiplies a n-dimensional signal-in-vector with a static
+(like sig~) signal-matrix to a n-dimensional signal-out-vector;
+#X connect 0 0 2 0;
+#X connect 0 1 3 0;
+#X connect 1 0 0 0;
+#X connect 4 0 10 0;
+#X connect 4 1 12 0;
+#X connect 5 0 4 0;
+#X connect 6 0 4 1;
+#X connect 7 0 4 2;
+#X connect 8 0 4 3;
+#X connect 9 0 4 4;
+#X connect 10 0 11 0;
+#X connect 12 0 13 0;
+#X connect 14 0 4 0;
+#X connect 15 0 14 0;
+#X connect 16 0 14 0;
+#X connect 17 0 14 0;
+#X connect 18 0 14 0;
+#X connect 19 0 14 0;
+#X connect 20 0 14 0;
+#X connect 21 0 14 0;
+#X connect 22 0 14 0;
+#X connect 23 0 14 0;
+#X connect 24 0 14 0;
+#X connect 25 0 14 0;
+#X connect 26 0 14 0;
+#X connect 27 0 14 0;
+#X connect 28 0 4 0;
+#X connect 29 0 28 0;
+#X connect 30 0 29 0;
+#X connect 31 0 29 1;
+#X connect 32 0 30 1;
+#X connect 33 0 30 0;
+#X connect 50 0 14 0;
+#X connect 51 0 14 0;
diff --git a/help/matrix_diag_mul_line8~-help.pd b/help/matrix_diag_mul_line8~-help.pd
new file mode 100644
index 0000000..a64bc55
--- /dev/null
+++ b/help/matrix_diag_mul_line8~-help.pd
@@ -0,0 +1,91 @@
+#N canvas 113 27 826 499 10;
+#X obj 18 45 dsp;
+#X obj 18 15 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1
+;
+#X floatatom 18 101 5 0 0 0 - - -;
+#X floatatom 33 75 5 0 0 0 - - -;
+#X obj 33 294 sig~ 1;
+#X obj 117 297 sig~ 2;
+#X obj 202 298 sig~ 4;
+#X obj 34 367 unsig~;
+#X floatatom 34 391 5 0 0 0 - - -;
+#X obj 118 365 unsig~;
+#X floatatom 118 389 5 0 0 0 - - -;
+#X obj 256 321 any;
+#X obj 409 321 pp element;
+#X obj 409 276 f;
+#X floatatom 422 253 4 1 3 0 - - -;
+#X obj 399 254 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
+-1;
+#X obj 203 367 unsig~;
+#X floatatom 203 391 5 0 0 0 - - -;
+#X floatatom 452 254 5 0 0 0 - - -;
+#X msg 256 102 diag 0 0 0;
+#X msg 256 126 diag 1 1 1;
+#X msg 256 147 diag 1 0 0;
+#X msg 256 168 diag 0 0 2;
+#X msg 256 189 diag 0 -10 0;
+#X obj 409 298 pack 0 0;
+#X text 653 17 SIG_OUT = A * SIG_IN;
+#X text 672 35 A is quadratic;
+#X text 356 96 message "diag";
+#X text 367 117 (nr_rows = nr_columns = n) items <float> elements of
+main-diagonal of matrix;
+#X text 609 52 dim(SIG_OUT) = dim(SIG_IN) = n;
+#X text 215 54 the elements of matrix are all zero except the main-diagonal
+;
+#X text 479 275 message "element";
+#X text 493 292 1.) item <float> row_index = column-index (1 .. n)
+;
+#X text 493 305 2.) item <float> matrix-element at index \, index;
+#X text 256 342 1.arg <float> Nr. of inlets = columns = outlets = rows
+;
+#X text 276 365 from previous state to next state of matrix;
+#X text 256 353 2.arg <float> interpolation-time in ms;
+#X text 70 16 matrix_diag_mul_line8~;
+#X obj 34 338 matrix_diag_mul_line8~ 3 3000;
+#X text 218 67 interpolation of matrix-elements will be done only every
+8 samples;
+#X msg 12 153 time 100;
+#X msg 12 179 time 3000;
+#X msg 14 250 stop;
+#X text 29 197 message "time";
+#X text 36 210 1.) item <float> interpolation-time in ms;
+#X text 53 249 message "stop";
+#X text 53 261 interrupts the interpolation;
+#X text 78 446 IEM KUG;
+#X text 62 434 musil;
+#X text 92 434 @;
+#X text 98 434 iem.at;
+#X text 61 456 Graz \, Austria;
+#X text 13 423 (c) Thomas Musil 2000 - 2006;
+#X text 216 15 multiplies a n-dimensional signal-in-vector with a dynamic
+changeable (like line~) signal-matrix to a n-dimensional signal-out-vector
+;
+#X connect 0 0 2 0;
+#X connect 0 1 3 0;
+#X connect 1 0 0 0;
+#X connect 4 0 38 0;
+#X connect 5 0 38 1;
+#X connect 6 0 38 2;
+#X connect 7 0 8 0;
+#X connect 9 0 10 0;
+#X connect 11 0 38 0;
+#X connect 12 0 38 0;
+#X connect 13 0 24 0;
+#X connect 14 0 13 1;
+#X connect 15 0 13 0;
+#X connect 16 0 17 0;
+#X connect 18 0 24 1;
+#X connect 19 0 11 0;
+#X connect 20 0 11 0;
+#X connect 21 0 11 0;
+#X connect 22 0 11 0;
+#X connect 23 0 11 0;
+#X connect 24 0 12 0;
+#X connect 38 0 7 0;
+#X connect 38 1 9 0;
+#X connect 38 2 16 0;
+#X connect 40 0 38 0;
+#X connect 41 0 38 0;
+#X connect 42 0 38 0;
diff --git a/help/matrix_diag_mul_line~-help.pd b/help/matrix_diag_mul_line~-help.pd
new file mode 100644
index 0000000..7333815
--- /dev/null
+++ b/help/matrix_diag_mul_line~-help.pd
@@ -0,0 +1,89 @@
+#N canvas 113 27 828 501 10;
+#X obj 18 44 dsp;
+#X obj 18 14 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1
+;
+#X floatatom 18 100 5 0 0 0 - - -;
+#X floatatom 33 74 5 0 0 0 - - -;
+#X obj 33 293 sig~ 1;
+#X obj 115 296 sig~ 2;
+#X obj 197 297 sig~ 4;
+#X obj 34 366 unsig~;
+#X floatatom 34 390 5 0 0 0 - - -;
+#X obj 115 364 unsig~;
+#X floatatom 115 388 5 0 0 0 - - -;
+#X obj 256 320 any;
+#X obj 409 320 pp element;
+#X obj 409 275 f;
+#X floatatom 422 252 4 1 3 0 - - -;
+#X obj 399 253 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
+-1;
+#X obj 197 366 unsig~;
+#X floatatom 197 390 5 0 0 0 - - -;
+#X floatatom 452 253 5 0 0 0 - - -;
+#X msg 256 101 diag 0 0 0;
+#X msg 256 125 diag 1 1 1;
+#X msg 256 146 diag 1 0 0;
+#X msg 256 167 diag 0 0 2;
+#X msg 256 188 diag 0 -10 0;
+#X obj 409 297 pack 0 0;
+#X text 653 16 SIG_OUT = A * SIG_IN;
+#X text 672 34 A is quadratic;
+#X text 356 95 message "diag";
+#X text 367 116 (nr_rows = nr_columns = n) items <float> elements of
+main-diagonal of matrix;
+#X text 609 51 dim(SIG_OUT) = dim(SIG_IN) = n;
+#X text 215 53 the elements of matrix are all zero except the main-diagonal
+;
+#X text 479 274 message "element";
+#X text 493 291 1.) item <float> row_index = column-index (1 .. n)
+;
+#X text 493 304 2.) item <float> matrix-element at index \, index;
+#X text 70 15 matrix_diag_mul_line~;
+#X obj 34 337 matrix_diag_mul_line~ 3 3000;
+#X text 256 341 1.arg <float> Nr. of inlets = columns = outlets = rows
+;
+#X text 276 364 from previous state to next state of matrix;
+#X text 256 352 2.arg <float> interpolation-time in ms;
+#X msg 12 152 time 100;
+#X msg 12 178 time 3000;
+#X msg 14 249 stop;
+#X text 29 196 message "time";
+#X text 36 209 1.) item <float> interpolation-time in ms;
+#X text 53 248 message "stop";
+#X text 53 260 interrupts the interpolation;
+#X text 78 446 IEM KUG;
+#X text 62 434 musil;
+#X text 92 434 @;
+#X text 98 434 iem.at;
+#X text 61 456 Graz \, Austria;
+#X text 13 423 (c) Thomas Musil 2000 - 2006;
+#X text 216 14 multiplies a n-dimensional signal-in-vector with a dynamic
+changeable (like line~) signal-matrix to a n-dimensional signal-out-vector
+;
+#X connect 0 0 2 0;
+#X connect 0 1 3 0;
+#X connect 1 0 0 0;
+#X connect 4 0 35 0;
+#X connect 5 0 35 1;
+#X connect 6 0 35 2;
+#X connect 7 0 8 0;
+#X connect 9 0 10 0;
+#X connect 11 0 35 0;
+#X connect 12 0 35 0;
+#X connect 13 0 24 0;
+#X connect 14 0 13 1;
+#X connect 15 0 13 0;
+#X connect 16 0 17 0;
+#X connect 18 0 24 1;
+#X connect 19 0 11 0;
+#X connect 20 0 11 0;
+#X connect 21 0 11 0;
+#X connect 22 0 11 0;
+#X connect 23 0 11 0;
+#X connect 24 0 12 0;
+#X connect 35 0 7 0;
+#X connect 35 1 9 0;
+#X connect 35 2 16 0;
+#X connect 39 0 35 0;
+#X connect 40 0 35 0;
+#X connect 41 0 35 0;
diff --git a/help/matrix_diag_mul_stat~-help.pd b/help/matrix_diag_mul_stat~-help.pd
new file mode 100644
index 0000000..cbf33f3
--- /dev/null
+++ b/help/matrix_diag_mul_stat~-help.pd
@@ -0,0 +1,77 @@
+#N canvas 99 75 824 496 10;
+#X obj 18 44 dsp;
+#X obj 18 14 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 1 1
+;
+#X floatatom 18 100 5 0 0 0 - - -;
+#X floatatom 33 74 5 0 0 0 - - -;
+#X obj 33 293 sig~ 1;
+#X obj 100 296 sig~ 2;
+#X obj 167 297 sig~ 4;
+#X obj 34 366 unsig~;
+#X floatatom 34 390 5 0 0 0 - - -;
+#X obj 99 364 unsig~;
+#X floatatom 99 388 5 0 0 0 - - -;
+#X obj 226 320 any;
+#X obj 379 320 pp element;
+#X obj 379 275 f;
+#X floatatom 392 252 4 1 3 0 - - -;
+#X obj 369 253 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
+-1;
+#X obj 167 366 unsig~;
+#X floatatom 167 390 5 0 0 0 - - -;
+#X floatatom 422 253 5 0 0 0 - - -;
+#X obj 34 337 matrix_diag_mul_stat~ 3;
+#X msg 226 101 diag 0 0 0;
+#X msg 226 125 diag 1 1 1;
+#X msg 226 146 diag 1 0 0;
+#X msg 226 167 diag 0 0 2;
+#X msg 226 188 diag 0 -10 0;
+#X obj 379 297 pack 0 0;
+#X text 653 16 SIG_OUT = A * SIG_IN;
+#X text 70 15 matrix_diag_mul_stat~;
+#X text 216 14 multiplies a n-dimensional signal-in-vector with a dynamic
+static (like sig~) signal-matrix to a n-dimensional signal-out-vector
+;
+#X text 672 34 A is quadratic;
+#X text 326 95 message "diag";
+#X text 337 116 (nr_rows = nr_columns = n) items <float> elements of
+main-diagonal of matrix;
+#X text 609 51 dim(SIG_OUT) = dim(SIG_IN) = n;
+#X text 215 53 the elements of matrix are all zero except the main-diagonal
+;
+#X text 449 274 message "element";
+#X text 463 291 1.) item <float> row_index = column-index (1 .. n)
+;
+#X text 463 304 2.) item <float> matrix-element at index \, index;
+#X text 189 341 1.arg <float> Nr. of inlets = columns = outlets = rows
+;
+#X text 78 446 IEM KUG;
+#X text 62 434 musil;
+#X text 92 434 @;
+#X text 98 434 iem.at;
+#X text 61 456 Graz \, Austria;
+#X text 13 423 (c) Thomas Musil 2000 - 2006;
+#X connect 0 0 2 0;
+#X connect 0 1 3 0;
+#X connect 1 0 0 0;
+#X connect 4 0 19 0;
+#X connect 5 0 19 1;
+#X connect 6 0 19 2;
+#X connect 7 0 8 0;
+#X connect 9 0 10 0;
+#X connect 11 0 19 0;
+#X connect 12 0 19 0;
+#X connect 13 0 25 0;
+#X connect 14 0 13 1;
+#X connect 15 0 13 0;
+#X connect 16 0 17 0;
+#X connect 18 0 25 1;
+#X connect 19 0 7 0;
+#X connect 19 1 9 0;
+#X connect 19 2 16 0;
+#X connect 20 0 11 0;
+#X connect 21 0 11 0;
+#X connect 22 0 11 0;
+#X connect 23 0 11 0;
+#X connect 24 0 11 0;
+#X connect 25 0 12 0;
diff --git a/help/matrix_mul_line8~-help.pd b/help/matrix_mul_line8~-help.pd
new file mode 100644
index 0000000..69bf505
--- /dev/null
+++ b/help/matrix_mul_line8~-help.pd
@@ -0,0 +1,113 @@
+#N canvas 44 20 890 532 10;
+#X obj 18 44 dsp;
+#X obj 18 14 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 1 1
+;
+#X floatatom 18 100 5 0 0 0 - - -;
+#X floatatom 33 74 5 0 0 0 - - -;
+#X obj 36 347 sig~ 1;
+#X obj 112 348 sig~ 2;
+#X obj 188 349 sig~ 4;
+#X obj 37 420 unsig~;
+#X floatatom 37 444 5 0 0 0 - - -;
+#X obj 87 420 unsig~;
+#X floatatom 87 444 5 0 0 0 - - -;
+#X obj 229 374 any;
+#X obj 382 374 pp element;
+#X obj 382 329 f;
+#X floatatom 423 300 4 1 3 0 - - -;
+#X floatatom 395 300 4 1 4 0 - - -;
+#X obj 372 307 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
+-1;
+#X obj 137 420 unsig~;
+#X floatatom 137 444 5 0 0 0 - - -;
+#X obj 188 420 unsig~;
+#X floatatom 188 444 5 0 0 0 - - -;
+#X msg 229 86 matrix 4 3 0 0 0 0 0 0 0 0 0 0 0 0;
+#X msg 229 110 matrix 4 3 1 1 1 1 1 1 1 1 1 1 1 1;
+#X obj 382 351 pack 0 0 0;
+#X floatatom 452 300 5 0 0 0 - - -;
+#X msg 229 182 col 1 10 10 10 10;
+#X msg 229 202 col 2 20 20 20 20;
+#X msg 229 222 col 3 30 30 30 30;
+#X msg 229 253 row 1 100 100 100;
+#X msg 229 273 row 2 200 200 200;
+#X msg 229 293 row 3 300 300 300;
+#X msg 229 313 row 4 400 400 400;
+#X msg 229 131 matrix 4 3 1 0 0 0 1 0 0 0 1 0.1 0.1 0.1;
+#X msg 229 152 matrix 4 3 -0.5 -0.5 -0.5 0 0 -1 0 -1 0 -1 0 0;
+#X text 549 81 message "matrix";
+#X text 555 98 1.) item <float> Nr. of outlets = rows;
+#X text 555 111 2.) item <float> Nr. of inlets = columns;
+#X text 578 127 + (nr_rows * nr_columns) elements;
+#X text 555 187 message "col";
+#X text 561 204 1.) item <float> column_index (1 .. nr_columns);
+#X text 592 218 + nr_rows elements;
+#X text 559 249 message "row";
+#X text 562 265 1.) item <float> row_index (1 .. nr_rows);
+#X text 593 279 + nr_columns elements;
+#X text 477 336 message "element";
+#X text 491 353 1.) item <float> row_index (1 .. nr_rows);
+#X text 491 365 2.) item <float> column_index (1 .. nr_columns);
+#X text 491 379 3.) item <float> matrix-element at row_index \, column_index
+;
+#X text 237 411 2.arg <float> Nr. of outlets = rows;
+#X text 237 400 1.arg <float> Nr. of inlets = columns;
+#X text 630 24 SIG_OUT = A * SIG_IN;
+#X text 257 434 from previous state to next state of matrix;
+#X msg 10 179 time 100;
+#X msg 10 205 time 3000;
+#X msg 12 276 stop;
+#X text 216 14 multiplies a nr_columns-dimensional signal-in-vector
+with a dynamic changeable (like line~) signal-matrix to a nr_rows-dimensional
+signal-out-vector;
+#X text 27 223 message "time";
+#X text 34 236 1.) item <float> interpolation-time in ms;
+#X text 51 275 message "stop";
+#X text 51 287 interrupts the interpolation;
+#X text 82 12 matrix_mul_line8~;
+#X obj 37 391 matrix_mul_line8~ 3 4 3000;
+#X text 237 422 3.arg <float> interpolation-time in ms;
+#X text 208 52 interpolation of matrix-elements will be done only every
+8 samples;
+#X text 78 496 IEM KUG;
+#X text 62 484 musil;
+#X text 92 484 @;
+#X text 98 484 iem.at;
+#X text 61 506 Graz \, Austria;
+#X text 13 473 (c) Thomas Musil 2000 - 2006;
+#X connect 0 0 2 0;
+#X connect 0 1 3 0;
+#X connect 1 0 0 0;
+#X connect 4 0 61 0;
+#X connect 5 0 61 1;
+#X connect 6 0 61 2;
+#X connect 7 0 8 0;
+#X connect 9 0 10 0;
+#X connect 11 0 61 0;
+#X connect 12 0 61 0;
+#X connect 13 0 23 0;
+#X connect 14 0 23 1;
+#X connect 15 0 13 1;
+#X connect 16 0 13 0;
+#X connect 17 0 18 0;
+#X connect 19 0 20 0;
+#X connect 21 0 11 0;
+#X connect 22 0 11 0;
+#X connect 23 0 12 0;
+#X connect 24 0 23 2;
+#X connect 25 0 11 0;
+#X connect 26 0 11 0;
+#X connect 27 0 11 0;
+#X connect 28 0 11 0;
+#X connect 29 0 11 0;
+#X connect 30 0 11 0;
+#X connect 31 0 11 0;
+#X connect 32 0 11 0;
+#X connect 33 0 11 0;
+#X connect 52 0 61 0;
+#X connect 53 0 61 0;
+#X connect 54 0 61 0;
+#X connect 61 0 7 0;
+#X connect 61 1 9 0;
+#X connect 61 2 17 0;
+#X connect 61 3 19 0;
diff --git a/help/matrix_mul_line~-help.pd b/help/matrix_mul_line~-help.pd
new file mode 100644
index 0000000..41e0067
--- /dev/null
+++ b/help/matrix_mul_line~-help.pd
@@ -0,0 +1,111 @@
+#N canvas 44 20 892 534 10;
+#X obj 18 44 dsp;
+#X obj 18 14 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 1 1
+;
+#X floatatom 18 100 5 0 0 0 - - -;
+#X floatatom 33 74 5 0 0 0 - - -;
+#X obj 36 347 sig~ 1;
+#X obj 109 348 sig~ 2;
+#X obj 182 349 sig~ 4;
+#X obj 37 420 unsig~;
+#X floatatom 37 444 5 0 0 0 - - -;
+#X obj 86 420 unsig~;
+#X floatatom 86 444 5 0 0 0 - - -;
+#X obj 229 374 any;
+#X obj 382 374 pp element;
+#X obj 382 329 f;
+#X floatatom 425 300 4 1 3 0 - - -;
+#X floatatom 395 300 4 1 4 0 - - -;
+#X obj 372 307 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
+-1;
+#X obj 134 420 unsig~;
+#X floatatom 134 444 5 0 0 0 - - -;
+#X obj 183 420 unsig~;
+#X floatatom 183 444 5 0 0 0 - - -;
+#X msg 229 86 matrix 4 3 0 0 0 0 0 0 0 0 0 0 0 0;
+#X msg 229 110 matrix 4 3 1 1 1 1 1 1 1 1 1 1 1 1;
+#X obj 382 351 pack 0 0 0;
+#X floatatom 463 293 5 0 0 0 - - -;
+#X msg 229 182 col 1 10 10 10 10;
+#X msg 229 202 col 2 20 20 20 20;
+#X msg 229 222 col 3 30 30 30 30;
+#X msg 229 253 row 1 100 100 100;
+#X msg 229 273 row 2 200 200 200;
+#X msg 229 293 row 3 300 300 300;
+#X msg 229 313 row 4 400 400 400;
+#X msg 229 131 matrix 4 3 1 0 0 0 1 0 0 0 1 0.1 0.1 0.1;
+#X msg 229 152 matrix 4 3 -0.5 -0.5 -0.5 0 0 -1 0 -1 0 -1 0 0;
+#X text 549 81 message "matrix";
+#X text 555 98 1.) item <float> Nr. of outlets = rows;
+#X text 555 111 2.) item <float> Nr. of inlets = columns;
+#X text 578 127 + (nr_rows * nr_columns) elements;
+#X text 555 187 message "col";
+#X text 561 204 1.) item <float> column_index (1 .. nr_columns);
+#X text 592 218 + nr_rows elements;
+#X text 559 249 message "row";
+#X text 562 265 1.) item <float> row_index (1 .. nr_rows);
+#X text 593 279 + nr_columns elements;
+#X text 477 336 message "element";
+#X text 491 353 1.) item <float> row_index (1 .. nr_rows);
+#X text 491 365 2.) item <float> column_index (1 .. nr_columns);
+#X text 491 379 3.) item <float> matrix-element at row_index \, column_index
+;
+#X text 237 411 2.arg <float> Nr. of outlets = rows;
+#X text 237 400 1.arg <float> Nr. of inlets = columns;
+#X text 630 24 SIG_OUT = A * SIG_IN;
+#X obj 37 391 matrix_mul_line~ 3 4 3000;
+#X text 257 434 from previous state to next state of matrix;
+#X msg 10 179 time 100;
+#X msg 10 205 time 3000;
+#X msg 12 276 stop;
+#X text 82 12 matrix_mul_line~;
+#X text 216 14 multiplies a nr_columns-dimensional signal-in-vector
+with a dynamic changeable (like line~) signal-matrix to a nr_rows-dimensional
+signal-out-vector;
+#X text 27 223 message "time";
+#X text 34 236 1.) item <float> interpolation-time in ms;
+#X text 51 275 message "stop";
+#X text 51 287 interrupts the interpolation;
+#X text 237 422 3.arg <float> interpolation-time in ms;
+#X text 78 496 IEM KUG;
+#X text 62 484 musil;
+#X text 92 484 @;
+#X text 98 484 iem.at;
+#X text 61 506 Graz \, Austria;
+#X text 13 473 (c) Thomas Musil 2000 - 2006;
+#X connect 0 0 2 0;
+#X connect 0 1 3 0;
+#X connect 1 0 0 0;
+#X connect 4 0 51 0;
+#X connect 5 0 51 1;
+#X connect 6 0 51 2;
+#X connect 7 0 8 0;
+#X connect 9 0 10 0;
+#X connect 11 0 51 0;
+#X connect 12 0 51 0;
+#X connect 13 0 23 0;
+#X connect 14 0 23 1;
+#X connect 15 0 13 1;
+#X connect 16 0 13 0;
+#X connect 17 0 18 0;
+#X connect 19 0 20 0;
+#X connect 21 0 11 0;
+#X connect 22 0 11 0;
+#X connect 23 0 12 0;
+#X connect 24 0 23 2;
+#X connect 25 0 11 0;
+#X connect 26 0 11 0;
+#X connect 27 0 11 0;
+#X connect 28 0 11 0;
+#X connect 29 0 11 0;
+#X connect 30 0 11 0;
+#X connect 31 0 11 0;
+#X connect 32 0 11 0;
+#X connect 33 0 11 0;
+#X connect 51 0 7 0;
+#X connect 51 1 9 0;
+#X connect 51 2 17 0;
+#X connect 51 3 19 0;
+#X connect 53 0 51 0;
+#X connect 54 0 51 0;
+#X connect 55 0 51 0;
diff --git a/help/matrix_mul_stat~-help.pd b/help/matrix_mul_stat~-help.pd
new file mode 100644
index 0000000..e6bec62
--- /dev/null
+++ b/help/matrix_mul_stat~-help.pd
@@ -0,0 +1,99 @@
+#N canvas 56 27 890 532 10;
+#X obj 18 44 dsp;
+#X obj 18 14 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 1 1
+;
+#X floatatom 18 100 5 0 0 0 - - -;
+#X floatatom 33 74 5 0 0 0 - - -;
+#X obj 36 347 sig~ 1;
+#X obj 95 348 sig~ 2;
+#X obj 152 349 sig~ 4;
+#X obj 37 420 unsig~;
+#X floatatom 37 444 5 0 0 0 - - -;
+#X obj 76 420 unsig~;
+#X floatatom 76 444 5 0 0 0 - - -;
+#X obj 229 374 any;
+#X obj 382 374 pp element;
+#X obj 382 329 f;
+#X floatatom 425 300 4 1 3 0 - - -;
+#X floatatom 395 300 4 1 4 0 - - -;
+#X obj 372 307 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
+-1;
+#X obj 37 391 matrix_mul_stat~ 3 4;
+#X obj 114 420 unsig~;
+#X floatatom 114 444 5 0 0 0 - - -;
+#X obj 153 420 unsig~;
+#X floatatom 153 444 5 0 0 0 - - -;
+#X msg 229 86 matrix 4 3 0 0 0 0 0 0 0 0 0 0 0 0;
+#X msg 229 110 matrix 4 3 1 1 1 1 1 1 1 1 1 1 1 1;
+#X obj 382 351 pack 0 0 0;
+#X floatatom 463 293 5 0 0 0 - - -;
+#X msg 229 182 col 1 10 10 10 10;
+#X msg 229 202 col 2 20 20 20 20;
+#X msg 229 222 col 3 30 30 30 30;
+#X msg 229 253 row 1 100 100 100;
+#X msg 229 273 row 2 200 200 200;
+#X msg 229 293 row 3 300 300 300;
+#X msg 229 313 row 4 400 400 400;
+#X msg 229 131 matrix 4 3 1 0 0 0 1 0 0 0 1 0.1 0.1 0.1;
+#X msg 229 152 matrix 4 3 -0.5 -0.5 -0.5 0 0 -1 0 -1 0 -1 0 0;
+#X text 549 81 message "matrix";
+#X text 555 98 1.) item <float> Nr. of outlets = rows;
+#X text 555 111 2.) item <float> Nr. of inlets = columns;
+#X text 578 127 + (nr_rows * nr_columns) elements;
+#X text 555 187 message "col";
+#X text 561 204 1.) item <float> column_index (1 .. nr_columns);
+#X text 592 218 + nr_rows elements;
+#X text 556 248 message "row";
+#X text 562 265 1.) item <float> row_index (1 .. nr_rows);
+#X text 593 279 + nr_columns elements;
+#X text 477 336 message "element";
+#X text 491 353 1.) item <float> row_index (1 .. nr_rows);
+#X text 491 365 2.) item <float> column_index (1 .. nr_columns);
+#X text 491 379 3.) item <float> matrix-element at row_index \, column_index
+;
+#X text 205 409 2.arg <float> Nr. of outlets = rows;
+#X text 205 398 1.arg <float> Nr. of inlets = columns;
+#X text 82 12 matrix_mul_stat~;
+#X text 216 13 multiplies a nr_columns-dimensional signal-in-vector
+with a static (like sig~) signal-matrix to a nr_rows-dimensional signal-out-vector
+;
+#X text 630 24 SIG_OUT = A * SIG_IN;
+#X text 78 496 IEM KUG;
+#X text 62 484 musil;
+#X text 92 484 @;
+#X text 98 484 iem.at;
+#X text 61 506 Graz \, Austria;
+#X text 13 473 (c) Thomas Musil 2000 - 2006;
+#X connect 0 0 2 0;
+#X connect 0 1 3 0;
+#X connect 1 0 0 0;
+#X connect 4 0 17 0;
+#X connect 5 0 17 1;
+#X connect 6 0 17 2;
+#X connect 7 0 8 0;
+#X connect 9 0 10 0;
+#X connect 11 0 17 0;
+#X connect 12 0 17 0;
+#X connect 13 0 24 0;
+#X connect 14 0 24 1;
+#X connect 15 0 13 1;
+#X connect 16 0 13 0;
+#X connect 17 0 7 0;
+#X connect 17 1 9 0;
+#X connect 17 2 18 0;
+#X connect 17 3 20 0;
+#X connect 18 0 19 0;
+#X connect 20 0 21 0;
+#X connect 22 0 11 0;
+#X connect 23 0 11 0;
+#X connect 24 0 12 0;
+#X connect 25 0 24 2;
+#X connect 26 0 11 0;
+#X connect 27 0 11 0;
+#X connect 28 0 11 0;
+#X connect 29 0 11 0;
+#X connect 30 0 11 0;
+#X connect 31 0 11 0;
+#X connect 32 0 11 0;
+#X connect 33 0 11 0;
+#X connect 34 0 11 0;
diff --git a/src/iem_matrix.c b/src/iem_matrix.c
new file mode 100644
index 0000000..d440162
--- /dev/null
+++ b/src/iem_matrix.c
@@ -0,0 +1,44 @@
+/* For information on usage and redistribution, and for a DISCLAIMER OF ALL
+* WARRANTIES, see the file, "LICENSE.txt," in this distribution.
+
+iem_matrix written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2006 */
+
+#include "m_pd.h"
+#include "iemlib.h"
+
+static t_class *iem_matrix_class;
+
+static void *iem_matrix_new(void)
+{
+ t_object *x = (t_object *)pd_new(iem_matrix_class);
+
+ return (x);
+}
+
+void matrix_mul_line_tilde_setup(void);
+void matrix_mul_line8_tilde_setup(void);
+void matrix_mul_stat_tilde_setup(void);
+void matrix_diag_mul_line_tilde_setup(void);
+void matrix_diag_mul_line8_tilde_setup(void);
+void matrix_diag_mul_stat_tilde_setup(void);
+void matrix_bundle_line_tilde_setup(void);
+void matrix_bundle_line8_tilde_setup(void);
+void matrix_bundle_stat_tilde_setup(void);
+
+/* ------------------------ setup routine ------------------------- */
+
+void iem_matrix_setup(void)
+{
+ matrix_mul_line_tilde_setup();
+ matrix_mul_line8_tilde_setup();
+ matrix_mul_stat_tilde_setup();
+ matrix_diag_mul_line_tilde_setup();
+ matrix_diag_mul_line8_tilde_setup();
+ matrix_diag_mul_stat_tilde_setup();
+ matrix_bundle_line_tilde_setup();
+ matrix_bundle_line8_tilde_setup();
+ matrix_bundle_stat_tilde_setup();
+
+ post("iem_matrix (R-1.16) library loaded! (c) Thomas Musil 05.2005");
+ post(" musil%ciem.at iem KUG Graz Austria", '@');
+}
diff --git a/src/iem_matrix.dsp b/src/iem_matrix.dsp
new file mode 100644
index 0000000..1664498
--- /dev/null
+++ b/src/iem_matrix.dsp
@@ -0,0 +1,85 @@
+# Microsoft Developer Studio Project File - Name="iem_matrix" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** NICHT BEARBEITEN **
+
+# TARGTYPE "Win32 (x86) External Target" 0x0106
+
+CFG=iem_matrix - Win32 Debug
+!MESSAGE Dies ist kein gültiges Makefile. Zum Erstellen dieses Projekts mit NMAKE
+!MESSAGE verwenden Sie den Befehl "Makefile exportieren" und führen Sie den Befehl
+!MESSAGE
+!MESSAGE NMAKE /f "iem_matrix.mak".
+!MESSAGE
+!MESSAGE Sie können beim Ausführen von NMAKE eine Konfiguration angeben
+!MESSAGE durch Definieren des Makros CFG in der Befehlszeile. Zum Beispiel:
+!MESSAGE
+!MESSAGE NMAKE /f "iem_matrix.mak" CFG="iem_matrix - Win32 Debug"
+!MESSAGE
+!MESSAGE Für die Konfiguration stehen zur Auswahl:
+!MESSAGE
+!MESSAGE "iem_matrix - Win32 Release" (basierend auf "Win32 (x86) External Target")
+!MESSAGE "iem_matrix - Win32 Debug" (basierend auf "Win32 (x86) External Target")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+
+!IF "$(CFG)" == "iem_matrix - Win32 Release"
+
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Cmd_Line "NMAKE /f makefile_win"
+# PROP BASE Rebuild_Opt "/a"
+# PROP BASE Target_File "makefile_win.exe"
+# PROP BASE Bsc_Name "makefile_win.bsc"
+# PROP BASE Target_Dir ""
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Cmd_Line "NMAKE /f makefile_win"
+# PROP Rebuild_Opt "/a"
+# PROP Target_File "iem_matrix.exe"
+# PROP Bsc_Name "iem_matrix.bsc"
+# PROP Target_Dir ""
+
+!ELSEIF "$(CFG)" == "iem_matrix - Win32 Debug"
+
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Cmd_Line "NMAKE /f makefile_win"
+# PROP BASE Rebuild_Opt "/a"
+# PROP BASE Target_File "makefile_win.exe"
+# PROP BASE Bsc_Name "makefile_win.bsc"
+# PROP BASE Target_Dir ""
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Cmd_Line "NMAKE /f makefile_win"
+# PROP Rebuild_Opt "/a"
+# PROP Target_File "iem_matrix.exe"
+# PROP Bsc_Name "iem_matrix.bsc"
+# PROP Target_Dir ""
+
+!ENDIF
+
+# Begin Target
+
+# Name "iem_matrix - Win32 Release"
+# Name "iem_matrix - Win32 Debug"
+
+!IF "$(CFG)" == "iem_matrix - Win32 Release"
+
+!ELSEIF "$(CFG)" == "iem_matrix - Win32 Debug"
+
+!ENDIF
+
+# Begin Source File
+
+SOURCE=.\makefile_win
+# End Source File
+# End Target
+# End Project
diff --git a/src/iem_matrix.dsw b/src/iem_matrix.dsw
new file mode 100644
index 0000000..13eafa1
--- /dev/null
+++ b/src/iem_matrix.dsw
@@ -0,0 +1,29 @@
+Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNUNG: DIESE ARBEITSBEREICHSDATEI DARF NICHT BEARBEITET ODER GELÖSCHT WERDEN!
+
+###############################################################################
+
+Project: "iem_matrix"=.\iem_matrix.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
diff --git a/src/iemlib.h b/src/iemlib.h
new file mode 100644
index 0000000..36d47ca
--- /dev/null
+++ b/src/iemlib.h
@@ -0,0 +1,108 @@
+/* For information on usage and redistribution, and for a DISCLAIMER OF ALL
+* WARRANTIES, see the file, "LICENSE.txt," in this distribution.
+
+iemlib written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2006 */
+
+#ifndef __IEMLIB_H__
+#define __IEMLIB_H__
+
+
+#define IS_A_POINTER(atom,index) ((atom+index)->a_type == A_POINTER)
+#define IS_A_FLOAT(atom,index) ((atom+index)->a_type == A_FLOAT)
+#define IS_A_SYMBOL(atom,index) ((atom+index)->a_type == A_SYMBOL)
+#define IS_A_DOLLAR(atom,index) ((atom+index)->a_type == A_DOLLAR)
+#define IS_A_DOLLSYM(atom,index) ((atom+index)->a_type == A_DOLLSYM)
+#define IS_A_SEMI(atom,index) ((atom+index)->a_type == A_SEMI)
+#define IS_A_COMMA(atom,index) ((atom+index)->a_type == A_COMMA)
+
+
+#ifdef NT
+int sys_noloadbang;
+//t_symbol *iemgui_key_sym=0;
+#include <io.h>
+#else
+extern int sys_noloadbang;
+//extern t_symbol *iemgui_key_sym;
+#include <unistd.h>
+#endif
+
+#define DEFDELVS 64
+#define XTRASAMPS 4
+#define SAMPBLK 4
+
+
+#define UNITBIT32 1572864. /* 3*2^19; bit 32 has place value 1 */
+
+/* machine-dependent definitions. These ifdefs really
+should have been by CPU type and not by operating system! */
+#ifdef IRIX
+/* big-endian. Most significant byte is at low address in memory */
+#define HIOFFSET 0 /* word offset to find MSB */
+#define LOWOFFSET 1 /* word offset to find LSB */
+#define int32 long /* a data type that has 32 bits */
+#else
+#ifdef MSW
+/* little-endian; most significant byte is at highest address */
+#define HIOFFSET 1
+#define LOWOFFSET 0
+#define int32 long
+#else
+#ifdef __FreeBSD__
+#include <machine/endian.h>
+#if BYTE_ORDER == LITTLE_ENDIAN
+#define HIOFFSET 1
+#define LOWOFFSET 0
+#else
+#define HIOFFSET 0 /* word offset to find MSB */
+#define LOWOFFSET 1 /* word offset to find LSB */
+#endif /* BYTE_ORDER */
+#include <sys/types.h>
+#define int32 int32_t
+#endif
+#ifdef __linux__
+
+#include <endian.h>
+
+#if !defined(__BYTE_ORDER) || !defined(__LITTLE_ENDIAN)
+#error No byte order defined
+#endif
+
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+#define HIOFFSET 1
+#define LOWOFFSET 0
+#else
+#define HIOFFSET 0 /* word offset to find MSB */
+#define LOWOFFSET 1 /* word offset to find LSB */
+#endif /* __BYTE_ORDER */
+
+#include <sys/types.h>
+#define int32 int32_t
+
+#else
+#ifdef __APPLE__
+#define HIOFFSET 0 /* word offset to find MSB */
+#define LOWOFFSET 1 /* word offset to find LSB */
+#define int32 int /* a data type that has 32 bits */
+
+#endif /* __APPLE__ */
+#endif /* __linux__ */
+#endif /* MSW */
+#endif /* SGI */
+
+union tabfudge
+{
+ double tf_d;
+ int32 tf_i[2];
+};
+
+#ifdef __i386__
+#define IEM_DENORMAL(f) ((((*(unsigned int*)&(f))&0x60000000)==0) || \
+(((*(unsigned int*)&(f))&0x60000000)==0x60000000))
+/* more stringent test: anything not between 1e-19 and 1e19 in absolute val */
+#else
+
+#define IEM_DENORMAL(f) 0
+
+#endif
+
+#endif
diff --git a/src/makefile b/src/makefile
new file mode 100644
index 0000000..45c8748
--- /dev/null
+++ b/src/makefile
@@ -0,0 +1,55 @@
+current: all
+
+.SUFFIXES: .pd_linux
+
+INCLUDE = -I. -I/usr/local/src/pd/src
+
+LDFLAGS = -export-dynamic -shared
+LIB = -ldl -lm -lpthread
+
+#select either the DBG and OPT compiler flags below:
+
+CFLAGS = -DPD -DUNIX -W -Werror -Wno-unused \
+ -Wno-parentheses -Wno-switch -O6 -funroll-loops -fomit-frame-pointer -fno-strict-aliasing \
+ -DDL_OPEN
+
+SYSTEM = $(shell uname -m)
+
+# the sources
+
+SRC = matrix_mul_line~.c \
+ matrix_mul_line8~.c \
+ matrix_mul_stat~.c \
+ matrix_diag_mul_line~.c \
+ matrix_diag_mul_line8~.c \
+ matrix_diag_mul_stat~.c \
+ matrix_bundle_line~.c \
+ matrix_bundle_line8~.c \
+ matrix_bundle_stat~.c \
+ iem_matrix.c
+
+TARGET = iem_matrix.pd_linux
+
+
+OBJ = $(SRC:.c=.o)
+
+#
+# ------------------ targets ------------------------------------
+#
+
+clean:
+ rm ..\$(TARGET)
+ rm *.o
+
+all: $(OBJ)
+ @echo :: $(OBJ)
+ $(LD) $(LDFLAGS) -o $(TARGET) *.o $(LIB)
+ strip --strip-unneeded $(TARGET)
+ mv $(TARGET) ..
+
+$(OBJ) : %.o : %.c
+ $(CC) $(CFLAGS) $(INCLUDE) -c -o $*.o $*.c
+
+
+
+
diff --git a/src/makefile_linux b/src/makefile_linux
new file mode 100644
index 0000000..45c8748
--- /dev/null
+++ b/src/makefile_linux
@@ -0,0 +1,55 @@
+current: all
+
+.SUFFIXES: .pd_linux
+
+INCLUDE = -I. -I/usr/local/src/pd/src
+
+LDFLAGS = -export-dynamic -shared
+LIB = -ldl -lm -lpthread
+
+#select either the DBG and OPT compiler flags below:
+
+CFLAGS = -DPD -DUNIX -W -Werror -Wno-unused \
+ -Wno-parentheses -Wno-switch -O6 -funroll-loops -fomit-frame-pointer -fno-strict-aliasing \
+ -DDL_OPEN
+
+SYSTEM = $(shell uname -m)
+
+# the sources
+
+SRC = matrix_mul_line~.c \
+ matrix_mul_line8~.c \
+ matrix_mul_stat~.c \
+ matrix_diag_mul_line~.c \
+ matrix_diag_mul_line8~.c \
+ matrix_diag_mul_stat~.c \
+ matrix_bundle_line~.c \
+ matrix_bundle_line8~.c \
+ matrix_bundle_stat~.c \
+ iem_matrix.c
+
+TARGET = iem_matrix.pd_linux
+
+
+OBJ = $(SRC:.c=.o)
+
+#
+# ------------------ targets ------------------------------------
+#
+
+clean:
+ rm ..\$(TARGET)
+ rm *.o
+
+all: $(OBJ)
+ @echo :: $(OBJ)
+ $(LD) $(LDFLAGS) -o $(TARGET) *.o $(LIB)
+ strip --strip-unneeded $(TARGET)
+ mv $(TARGET) ..
+
+$(OBJ) : %.o : %.c
+ $(CC) $(CFLAGS) $(INCLUDE) -c -o $*.o $*.c
+
+
+
+
diff --git a/src/makefile_win b/src/makefile_win
new file mode 100644
index 0000000..e1cd1da
--- /dev/null
+++ b/src/makefile_win
@@ -0,0 +1,46 @@
+
+all: ..\iem_matrix.dll
+
+VIS_CPP_PATH = "C:\Programme\Microsoft Visual Studio\Vc98"
+
+PD_INST_PATH = "C:\Programme\pd-0.39-2"
+
+PD_WIN_INCLUDE_PATH = /I. /I$(PD_INST_PATH)\src /I$(VIS_CPP_PATH)\include
+
+PD_WIN_C_FLAGS = /nologo /W3 /WX /DMSW /DNT /DPD /DWIN32 /DWINDOWS /Ox -DPA_LITTLE_ENDIAN
+
+PD_WIN_L_FLAGS = /nologo
+
+PD_WIN_LIB = /NODEFAULTLIB:libc /NODEFAULTLIB:oldnames /NODEFAULTLIB:kernel /NODEFAULTLIB:uuid \
+ $(VIS_CPP_PATH)\lib\libc.lib \
+ $(VIS_CPP_PATH)\lib\oldnames.lib \
+ $(VIS_CPP_PATH)\lib\kernel32.lib \
+ $(VIS_CPP_PATH)\lib\wsock32.lib \
+ $(VIS_CPP_PATH)\lib\winmm.lib \
+ $(PD_INST_PATH)\bin\pthreadVC.lib \
+ $(PD_INST_PATH)\bin\pd.lib
+
+
+SRC = matrix_mul_line~.c \
+ matrix_mul_line8~.c \
+ matrix_mul_stat~.c \
+ matrix_diag_mul_line~.c \
+ matrix_diag_mul_line8~.c \
+ matrix_diag_mul_stat~.c \
+ matrix_bundle_line~.c \
+ matrix_bundle_line8~.c \
+ matrix_bundle_stat~.c \
+ iem_matrix.c
+
+
+OBJ = $(SRC:.c=.obj)
+
+.c.obj:
+ cl $(PD_WIN_C_FLAGS) $(PD_WIN_INCLUDE_PATH) /c $*.c
+
+..\iem_matrix.dll: $(OBJ)
+ link $(PD_WIN_L_FLAGS) /dll /export:iem_matrix_setup \
+ /out:..\iem_matrix.dll $(OBJ) $(PD_WIN_LIB)
+
+clean:
+ del *.obj
diff --git a/src/matrix_bundle_line8~.c b/src/matrix_bundle_line8~.c
new file mode 100644
index 0000000..86de343
--- /dev/null
+++ b/src/matrix_bundle_line8~.c
@@ -0,0 +1,479 @@
+/* For information on usage and redistribution, and for a DISCLAIMER OF ALL
+* WARRANTIES, see the file, "LICENSE.txt," in this distribution.
+
+iem_matrix written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2006 */
+
+#include "m_pd.h"
+#include "iemlib.h"
+
+
+/* ---------- matrix_bundle_line8~ - signal matrix multiplication object with message matrix-coeff. ----------- */
+
+typedef struct matrix_bundle_line8_tilde
+{
+ t_object x_obj;
+ int *x_in2out_new;
+ int *x_in2out_old;
+ int *x_remaining_ticks;
+ int *x_retarget;
+ t_float **x_io;
+ t_float *x_outsumbuf;
+ int x_outsumbufsize;
+ int x_n_in; /* columns */
+ int x_n_out; /* rows */
+ t_float x_inc8;
+ t_float x_biginc;
+ t_float x_raise_cur;
+ t_float x_raise_end;
+ t_float x_fall_cur;
+ t_float x_fall_end;
+ t_float x_msi;
+ int x_remaining_ticks_start;
+ t_float x_time_ms;
+ t_float x_ms2tick;
+ t_float x_8overn;
+} t_matrix_bundle_line8_tilde;
+
+t_class *matrix_bundle_line8_tilde_class;
+
+static void matrix_bundle_line8_tilde_time(t_matrix_bundle_line8_tilde *x, t_floatarg time_ms)
+{
+ if(time_ms <= 0.0f)
+ time_ms = 0.0f;
+ x->x_time_ms = time_ms;
+
+ x->x_remaining_ticks_start = (int)(x->x_time_ms * x->x_ms2tick);
+ if(!x->x_remaining_ticks_start)
+ x->x_remaining_ticks_start = 1;
+}
+
+static void matrix_bundle_line8_tilde_element(t_matrix_bundle_line8_tilde *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int inindex, outindex;
+
+ if(argc < 2)
+ {
+ post("matrix_bundle_line8~ : bad list: <int> output_row_index <int> input_col_index !");
+ return;
+ }
+
+ if(x->x_time_ms <= 0.0f)
+ {
+ outindex = (int)atom_getint(argv);
+ argv++;
+ inindex = (int)atom_getint(argv) - 1;
+
+ if(inindex >= x->x_n_in)
+ inindex = x->x_n_in - 1;
+ if(inindex < 0)
+ inindex = 0;
+ if(outindex >= x->x_n_out)
+ outindex = x->x_n_out;
+ if(outindex < 0)
+ outindex = 0;
+
+ x->x_in2out_old[inindex] = x->x_in2out_new[inindex] = outindex;/*retarget = 0*/
+ x->x_remaining_ticks[inindex] = x->x_retarget[inindex] = 0;
+ x->x_fall_end = x->x_fall_cur = 0.0f;
+ x->x_raise_end = x->x_raise_cur = 1.0f;
+ }
+ else
+ {
+ x->x_inc8 = x->x_8overn / (float)x->x_remaining_ticks_start;
+ x->x_biginc = 1.0f / (float)x->x_remaining_ticks_start;
+
+ x->x_fall_end = 0.0f;
+ x->x_fall_cur = 1.0f;
+ x->x_raise_end = 1.0f;
+ x->x_raise_cur = 0.0f;
+
+ outindex = (int)atom_getint(argv);
+ argv++;
+ inindex = (int)atom_getint(argv) - 1;
+
+ if(inindex >= x->x_n_in)
+ inindex = x->x_n_in - 1;
+ if(inindex < 0)
+ inindex = 0;
+ if(outindex >= x->x_n_out)
+ outindex = x->x_n_out;
+ if(outindex < 0)
+ outindex = 0;
+
+ x->x_in2out_new[inindex] = outindex;
+ if(x->x_in2out_new[inindex] == x->x_in2out_old[inindex])
+ x->x_retarget[inindex] = 0;
+ else
+ x->x_retarget[inindex] = 1;
+ }
+}
+
+static void matrix_bundle_line8_tilde_list(t_matrix_bundle_line8_tilde *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int outindex, i, n=x->x_n_in;
+
+ if(argc < n)
+ {
+ post("matrix_bundle_line8~ : bad list: (number_of_input_cols = %d) * <int> output_row_index !", n);
+ return;
+ }
+
+ if(x->x_time_ms <= 0.0f)
+ {
+ for(i=0; i<n; i++)
+ {
+ outindex = (int)atom_getint(argv);
+ argv++;
+ if(outindex >= x->x_n_out)
+ outindex = x->x_n_out;
+ if(outindex < 0)
+ outindex = 0;
+ x->x_in2out_old[i] = x->x_in2out_new[i] = outindex;/*retarget = 0*/
+ x->x_remaining_ticks[i] = x->x_retarget[i] = 0;
+ }
+ x->x_fall_end = x->x_fall_cur = 0.0f;
+ x->x_raise_end = x->x_raise_cur = 1.0f;
+ }
+ else
+ {
+ x->x_inc8 = x->x_8overn / (float)x->x_remaining_ticks_start;
+ x->x_biginc = 1.0f / (float)x->x_remaining_ticks_start;
+
+ x->x_fall_end = 0.0f;
+ x->x_fall_cur = 1.0f;
+ x->x_raise_end = 1.0f;
+ x->x_raise_cur = 0.0f;
+
+ for(i=0; i<argc; i++)
+ {
+ x->x_in2out_old[i] = x->x_in2out_new[i];
+
+ outindex = (int)atom_getint(argv);
+ argv++;
+ if(outindex >= x->x_n_out)
+ outindex = x->x_n_out;
+ if(outindex < 0)
+ outindex = 0;
+ x->x_in2out_new[i] = outindex;
+ if(x->x_in2out_new[i] == x->x_in2out_old[i])
+ x->x_retarget[i] = 0;
+ else
+ x->x_retarget[i] = 1;
+ }
+ }
+}
+
+static void matrix_bundle_line8_tilde_bundle(t_matrix_bundle_line8_tilde *x, t_symbol *s, int argc, t_atom *argv)
+{
+ matrix_bundle_line8_tilde_list(x, &s_list, argc, argv);
+}
+
+static void matrix_bundle_line8_tilde_stop(t_matrix_bundle_line8_tilde *x)
+{
+ int i, n=x->x_n_in;
+
+ x->x_fall_end = x->x_fall_cur;
+ x->x_raise_end = x->x_raise_cur;
+ for(i=0; i<n; i++)
+ {
+ x->x_in2out_new[i] = x->x_in2out_old[i];
+ x->x_remaining_ticks[i] = x->x_retarget[i] = 0;
+ }
+}
+
+/* the dsp thing */
+
+static t_int *matrix_bundle_line8_tilde_perform_zero(t_int *w)
+{
+ t_matrix_bundle_line8_tilde *x = (t_matrix_bundle_line8_tilde *)(w[1]);
+ int n = (int)(w[2]);
+ t_float **io = x->x_io;
+ int n_in = x->x_n_in;
+ int n_out = x->x_n_out;
+ t_float *out;
+ int j, i;
+
+ for(j=0; j<n_out; j++)/* output-vector-row */
+ {
+ out = io[n_in+j];
+ for(i=0; i<n; i++)
+ *out++ = 0.0f;
+ }
+ return (w+3);
+}
+
+static t_int *matrix_bundle_line8_tilde_perf8(t_int *w)
+{
+ t_matrix_bundle_line8_tilde *x = (t_matrix_bundle_line8_tilde *)(w[1]);
+ int n = (int)(w[2]);
+ t_float **io = x->x_io;
+ t_float *outsum;
+ int *in2out_new = x->x_in2out_new;
+ int *in2out_old = x->x_in2out_old;
+ int n_in = x->x_n_in; /* columns */
+ int n_out = x->x_n_out; /* rows */
+ t_float *in, *out, mul;
+ t_float inc8 = x->x_inc8;
+ int i, j, endofticks=0;
+
+ for(i=0; i<n_in; i++)
+ {
+ if(x->x_retarget[i])
+ {
+ x->x_remaining_ticks[i] = x->x_remaining_ticks_start;
+ x->x_retarget[i] = 0;
+ }
+ }
+
+ for(j=0; j<n_out; j++)
+ {
+ outsum = x->x_outsumbuf + j*n;
+ for(i=n; i; i -= 8, outsum += 8)/* reset out-buffer */
+ {
+ outsum[0] = 0.0f;
+ outsum[1] = 0.0f;
+ outsum[2] = 0.0f;
+ outsum[3] = 0.0f;
+ outsum[4] = 0.0f;
+ outsum[5] = 0.0f;
+ outsum[6] = 0.0f;
+ outsum[7] = 0.0f;
+ }
+ }
+
+ for(j=0; j<n_in; j++)
+ {
+ if(x->x_remaining_ticks[j])
+ {
+ in = io[j];
+ if(in2out_new[j])
+ {
+ outsum = x->x_outsumbuf + n*(in2out_new[j] - 1);
+ mul = x->x_raise_cur;
+ for(i=n; i; i -= 8, outsum += 8, in += 8)/* each new in */
+ {
+ outsum[0] += in[0]*mul;
+ outsum[1] += in[1]*mul;
+ outsum[2] += in[2]*mul;
+ outsum[3] += in[3]*mul;
+ outsum[4] += in[4]*mul;
+ outsum[5] += in[5]*mul;
+ outsum[6] += in[6]*mul;
+ outsum[7] += in[7]*mul;
+ mul += inc8;
+ }
+ }
+ // raise_cur = mul;
+
+ in = io[j];
+ if(in2out_old[j])
+ {
+ outsum = x->x_outsumbuf + n*(in2out_old[j] - 1);
+ mul = x->x_fall_cur;
+ for(i=n; i; i -= 8, outsum += 8, in += 8)/* each old in */
+ {
+ outsum[0] += in[0]*mul;
+ outsum[1] += in[1]*mul;
+ outsum[2] += in[2]*mul;
+ outsum[3] += in[3]*mul;
+ outsum[4] += in[4]*mul;
+ outsum[5] += in[5]*mul;
+ outsum[6] += in[6]*mul;
+ outsum[7] += in[7]*mul;
+ mul -= inc8;
+ }
+ }
+ // fall_cur = mul;
+
+ if(!--x->x_remaining_ticks[j])
+ {
+ endofticks = 1;
+ }
+ }
+ else
+ {
+ in = io[j];
+ if(in2out_new[j])
+ {
+ outsum = x->x_outsumbuf + n*(in2out_new[j] - 1);
+ for(i=n; i; i -= 8, outsum += 8, in += 8)/* each in */
+ {
+ outsum[0] += in[0];
+ outsum[1] += in[1];
+ outsum[2] += in[2];
+ outsum[3] += in[3];
+ outsum[4] += in[4];
+ outsum[5] += in[5];
+ outsum[6] += in[6];
+ outsum[7] += in[7];
+ }
+ }
+ }
+ }
+
+ if(x->x_remaining_ticks[j])
+ {
+ x->x_raise_cur += x->x_biginc;
+ x->x_fall_cur -= x->x_biginc;
+ }
+
+ if(endofticks)
+ {
+ x->x_fall_cur = x->x_fall_end;
+ x->x_raise_cur = x->x_raise_end;
+ }
+
+ outsum = x->x_outsumbuf;
+ for(j=0; j<n_out; j++)/* copy out-buffer to out */
+ {
+ out = io[n_in+j];
+ for (i=n; i; i -= 8, out += 8, outsum += 8)
+ {
+ out[0] = outsum[0];
+ out[1] = outsum[1];
+ out[2] = outsum[2];
+ out[3] = outsum[3];
+ out[4] = outsum[4];
+ out[5] = outsum[5];
+ out[6] = outsum[6];
+ out[7] = outsum[7];
+ }
+ }
+ return (w+3);
+}
+
+static void matrix_bundle_line8_tilde_dsp(t_matrix_bundle_line8_tilde *x, t_signal **sp)
+{
+ int i, n=sp[0]->s_n*x->x_n_out;
+
+ if(!x->x_outsumbuf)
+ {
+ x->x_outsumbufsize = n;
+ x->x_outsumbuf = (t_float *)getbytes(x->x_outsumbufsize * sizeof(t_float));
+ }
+ else if(x->x_outsumbufsize != n)
+ {
+ x->x_outsumbuf = (t_float *)resizebytes(x->x_outsumbuf, x->x_outsumbufsize*sizeof(t_float), n*sizeof(t_float));
+ x->x_outsumbufsize = n;
+ }
+
+ n = x->x_n_in + x->x_n_out;
+ for(i=0; i<n; i++)
+ x->x_io[i] = sp[i]->s_vec;
+
+ n = sp[0]->s_n;
+ x->x_ms2tick = 0.001f * (float)(sp[0]->s_sr) / (float)n;
+ x->x_8overn = 8.0f / (float)n;
+
+ x->x_remaining_ticks_start = (int)(x->x_time_ms * x->x_ms2tick);
+ if(!x->x_remaining_ticks_start)
+ x->x_remaining_ticks_start = 1;
+
+ if(n&7)
+ {
+ dsp_add(matrix_bundle_line8_tilde_perform_zero, 2, x, n);
+ post("ERROR!!! matrix_bundle_line8_tilde~ : blocksize is %d and not a multiple of 8", n);
+ }
+ else
+ dsp_add(matrix_bundle_line8_tilde_perf8, 2, x, n);
+}
+
+
+/* setup/setdown things */
+
+static void matrix_bundle_line8_tilde_free(t_matrix_bundle_line8_tilde *x)
+{
+ freebytes(x->x_in2out_new, x->x_n_in * sizeof(int));
+ freebytes(x->x_in2out_old, x->x_n_in * sizeof(int));
+ freebytes(x->x_remaining_ticks, x->x_n_in * sizeof(int));
+ freebytes(x->x_retarget, x->x_n_in * sizeof(int));
+ freebytes(x->x_io, (x->x_n_in + x->x_n_out) * sizeof(t_float *));
+ if(x->x_outsumbuf)
+ freebytes(x->x_outsumbuf, x->x_outsumbufsize * sizeof(t_float));
+}
+
+static void *matrix_bundle_line8_tilde_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_matrix_bundle_line8_tilde *x = (t_matrix_bundle_line8_tilde *)pd_new(matrix_bundle_line8_tilde_class);
+ int i, n;
+
+ switch (argc)
+ {
+ case 0:
+ x->x_n_in = x->x_n_out = 1;
+ x->x_time_ms = 50.0f;
+ break;
+ case 1:
+ x->x_n_in = x->x_n_out = (int)atom_getint(argv);
+ x->x_time_ms = 50.0f;
+ break;
+ case 2:
+ x->x_n_in = (int)atom_getint(argv);
+ x->x_n_out = (int)atom_getint(argv+1);
+ x->x_time_ms = 50.0f;
+ break;
+ default:
+ x->x_n_in = (int)atom_getint(argv);
+ x->x_n_out = (int)atom_getint(argv+1);
+ x->x_time_ms = atom_getfloat(argv+2);
+ break;
+ }
+
+ if(x->x_n_in < 1)
+ x->x_n_in = 1;
+ if(x->x_n_out < 1)
+ x->x_n_out = 1;
+ if(x->x_time_ms < 0.0f)
+ x->x_time_ms = 50.0f;
+ i = x->x_n_in - 1;
+ while(i--)
+ inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal);
+ i = x->x_n_out;
+ while(i--)
+ outlet_new(&x->x_obj, &s_signal);
+
+ x->x_in2out_new = (int *)getbytes(x->x_n_in * sizeof(int));
+ x->x_in2out_old = (int *)getbytes(x->x_n_in * sizeof(int));
+ x->x_remaining_ticks = (int *)getbytes(x->x_n_in * sizeof(int));
+ x->x_retarget = (int *)getbytes(x->x_n_in * sizeof(int));
+ x->x_io = (t_float **)getbytes((x->x_n_in + x->x_n_out) * sizeof(t_float *));
+ x->x_outsumbuf = (t_float *)0;
+ x->x_outsumbufsize = 0;
+
+ x->x_raise_cur = 1.0f;
+ x->x_raise_end = 1.0f;
+ x->x_fall_cur = 0.0f;
+ x->x_fall_end = 0.0f;
+ x->x_inc8 = 0.0f;
+ x->x_biginc = 0.0f;
+ x->x_msi = 0;
+ x->x_ms2tick = 0.001f * 44100.0f / 64.0f;
+ x->x_8overn = 8.0f / 64.0f;
+ x->x_remaining_ticks_start = (int)(x->x_time_ms * x->x_ms2tick);
+ if(!x->x_remaining_ticks_start)
+ x->x_remaining_ticks_start = 1;
+
+ n = x->x_n_in;
+ for(i=0; i<n; i++)
+ {
+ x->x_in2out_new[i] = 0;
+ x->x_in2out_old[i] = 0;
+ x->x_remaining_ticks[i] = 0;
+ x->x_retarget[i] = 0;
+ }
+ return(x);
+}
+
+void matrix_bundle_line8_tilde_setup(void)
+{
+ matrix_bundle_line8_tilde_class = class_new(gensym("matrix_bundle_line8~"), (t_newmethod)matrix_bundle_line8_tilde_new, (t_method)matrix_bundle_line8_tilde_free,
+ sizeof(t_matrix_bundle_line8_tilde), 0, A_GIMME, 0);
+ CLASS_MAINSIGNALIN(matrix_bundle_line8_tilde_class, t_matrix_bundle_line8_tilde, x_msi);
+ class_addmethod(matrix_bundle_line8_tilde_class, (t_method)matrix_bundle_line8_tilde_dsp, gensym("dsp"), 0);
+ class_addlist(matrix_bundle_line8_tilde_class, (t_method)matrix_bundle_line8_tilde_list);
+ class_addmethod(matrix_bundle_line8_tilde_class, (t_method)matrix_bundle_line8_tilde_element, gensym("element"), A_GIMME, 0);
+ class_addmethod(matrix_bundle_line8_tilde_class, (t_method)matrix_bundle_line8_tilde_bundle, gensym("bundle"), A_GIMME, 0);
+ class_addmethod(matrix_bundle_line8_tilde_class, (t_method)matrix_bundle_line8_tilde_stop, gensym("stop"), 0);
+ class_addmethod(matrix_bundle_line8_tilde_class, (t_method)matrix_bundle_line8_tilde_time, gensym("time"), A_FLOAT, 0);
+ class_sethelpsymbol(matrix_bundle_line8_tilde_class, gensym("iemhelp/matrix_bundle_line8~-help"));
+}
diff --git a/src/matrix_bundle_line~.c b/src/matrix_bundle_line~.c
new file mode 100644
index 0000000..bbeb4ef
--- /dev/null
+++ b/src/matrix_bundle_line~.c
@@ -0,0 +1,493 @@
+/* For information on usage and redistribution, and for a DISCLAIMER OF ALL
+* WARRANTIES, see the file, "LICENSE.txt," in this distribution.
+
+iem_matrix written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2006 */
+
+#include "m_pd.h"
+#include "iemlib.h"
+
+
+/* ---------- matrix_bundle_line~ - signal matrix multiplication object with message matrix-coeff. ----------- */
+
+typedef struct matrix_bundle_line_tilde
+{
+ t_object x_obj;
+ int *x_in2out_new;
+ int *x_in2out_old;
+ int *x_remaining_ticks;
+ int *x_retarget;
+ t_float **x_io;
+ t_float *x_outsumbuf;
+ int x_outsumbufsize;
+ int x_n_in; /* columns */
+ int x_n_out; /* rows */
+ t_float x_inc;
+ t_float x_biginc;
+ t_float x_raise_cur;
+ t_float x_raise_end;
+ t_float x_fall_cur;
+ t_float x_fall_end;
+ t_float x_msi;
+ int x_remaining_ticks_start;
+ t_float x_time_ms;
+ t_float x_ms2tick;
+ t_float x_1overn;
+} t_matrix_bundle_line_tilde;
+
+t_class *matrix_bundle_line_tilde_class;
+
+static void matrix_bundle_line_tilde_time(t_matrix_bundle_line_tilde *x, t_floatarg time_ms)
+{
+ if(time_ms <= 0.0f)
+ time_ms = 0.0f;
+ x->x_time_ms = time_ms;
+
+ x->x_remaining_ticks_start = (int)(x->x_time_ms * x->x_ms2tick);
+ if(!x->x_remaining_ticks_start)
+ x->x_remaining_ticks_start = 1;
+}
+
+static void matrix_bundle_line_tilde_element(t_matrix_bundle_line_tilde *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int inindex, outindex;
+
+ if(argc < 2)
+ {
+ post("matrix_bundle_line~ : bad list: <int> output_row_index <int> input_col_index !");
+ return;
+ }
+
+ if(x->x_time_ms <= 0.0f)
+ {
+ outindex = (int)atom_getint(argv);
+ argv++;
+ inindex = (int)atom_getint(argv) - 1;
+
+ if(inindex >= x->x_n_in)
+ inindex = x->x_n_in - 1;
+ if(inindex < 0)
+ inindex = 0;
+ if(outindex >= x->x_n_out)
+ outindex = x->x_n_out;
+ if(outindex < 0)
+ outindex = 0;
+
+ x->x_in2out_old[inindex] = x->x_in2out_new[inindex] = outindex;/*retarget = 0*/
+ x->x_remaining_ticks[inindex] = x->x_retarget[inindex] = 0;
+ x->x_fall_end = x->x_fall_cur = 0.0f;
+ x->x_raise_end = x->x_raise_cur = 1.0f;
+ }
+ else
+ {
+ x->x_inc = x->x_1overn / (float)x->x_remaining_ticks_start;
+ x->x_biginc = 1.0f / (float)x->x_remaining_ticks_start;
+
+ x->x_fall_end = 0.0f;
+ x->x_fall_cur = 1.0f;
+ x->x_raise_end = 1.0f;
+ x->x_raise_cur = 0.0f;
+
+ outindex = (int)atom_getint(argv);
+ argv++;
+ inindex = (int)atom_getint(argv) - 1;
+
+ if(inindex >= x->x_n_in)
+ inindex = x->x_n_in - 1;
+ if(inindex < 0)
+ inindex = 0;
+ if(outindex >= x->x_n_out)
+ outindex = x->x_n_out;
+ if(outindex < 0)
+ outindex = 0;
+
+ x->x_in2out_new[inindex] = outindex;
+ if(x->x_in2out_new[inindex] == x->x_in2out_old[inindex])
+ x->x_retarget[inindex] = 0;
+ else
+ x->x_retarget[inindex] = 1;
+ }
+}
+
+static void matrix_bundle_line_tilde_list(t_matrix_bundle_line_tilde *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int outindex, i, n=x->x_n_in;
+
+ if(argc < n)
+ {
+ post("matrix_bundle_line~ : bad list: (number_of_input_cols = %d) * <int> output_row_index !", n);
+ return;
+ }
+
+ if(x->x_time_ms <= 0.0f)
+ {
+ for(i=0; i<n; i++)
+ {
+ outindex = (int)atom_getint(argv);
+ argv++;
+ if(outindex >= x->x_n_out)
+ outindex = x->x_n_out;
+ if(outindex < 0)
+ outindex = 0;
+ x->x_in2out_old[i] = x->x_in2out_new[i] = outindex;/*retarget = 0*/
+ x->x_remaining_ticks[i] = x->x_retarget[i] = 0;
+ }
+ x->x_fall_end = x->x_fall_cur = 0.0f;
+ x->x_raise_end = x->x_raise_cur = 1.0f;
+ }
+ else
+ {
+ x->x_inc = x->x_1overn / (float)x->x_remaining_ticks_start;
+ x->x_biginc = 1.0f / (float)x->x_remaining_ticks_start;
+
+ x->x_fall_end = 0.0f;
+ x->x_fall_cur = 1.0f;
+ x->x_raise_end = 1.0f;
+ x->x_raise_cur = 0.0f;
+
+ for(i=0; i<argc; i++)
+ {
+ x->x_in2out_old[i] = x->x_in2out_new[i];
+
+ outindex = (int)atom_getint(argv);
+ argv++;
+ if(outindex >= x->x_n_out)
+ outindex = x->x_n_out;
+ if(outindex < 0)
+ outindex = 0;
+ x->x_in2out_new[i] = outindex;
+ if(x->x_in2out_new[i] == x->x_in2out_old[i])
+ x->x_retarget[i] = 0;
+ else
+ x->x_retarget[i] = 1;
+ }
+ }
+}
+
+static void matrix_bundle_line_tilde_bundle(t_matrix_bundle_line_tilde *x, t_symbol *s, int argc, t_atom *argv)
+{
+ matrix_bundle_line_tilde_list(x, &s_list, argc, argv);
+}
+
+static void matrix_bundle_line_tilde_stop(t_matrix_bundle_line_tilde *x)
+{
+ int i, n=x->x_n_in;
+
+ x->x_fall_end = x->x_fall_cur;
+ x->x_raise_end = x->x_raise_cur;
+ for(i=0; i<n; i++)
+ {
+ x->x_in2out_new[i] = x->x_in2out_old[i];
+ x->x_remaining_ticks[i] = x->x_retarget[i] = 0;
+ }
+}
+
+/* the dsp thing */
+
+static t_int *matrix_bundle_line_tilde_perform_zero(t_int *w)
+{
+ t_matrix_bundle_line_tilde *x = (t_matrix_bundle_line_tilde *)(w[1]);
+ int n = (int)(w[2]);
+ t_float **io = x->x_io;
+ int n_in = x->x_n_in;
+ int n_out = x->x_n_out;
+ t_float *out;
+ int j, i;
+
+ for(j=0; j<n_out; j++)/* output-vector-row */
+ {
+ out = io[n_in+j];
+ for(i=0; i<n; i++)
+ *out++ = 0.0f;
+ }
+ return (w+3);
+}
+
+static t_int *matrix_bundle_line_tilde_perf8(t_int *w)
+{
+ t_matrix_bundle_line_tilde *x = (t_matrix_bundle_line_tilde *)(w[1]);
+ int n = (int)(w[2]);
+ t_float **io = x->x_io;
+ t_float *outsum;
+ int *in2out_new = x->x_in2out_new;
+ int *in2out_old = x->x_in2out_old;
+ int n_in = x->x_n_in; /* columns */
+ int n_out = x->x_n_out; /* rows */
+ t_float *in, *out, mul;
+ t_float inc = x->x_inc;
+ int i, j, endofticks=0;
+
+ for(i=0; i<n_in; i++)
+ {
+ if(x->x_retarget[i])
+ {
+ x->x_remaining_ticks[i] = x->x_remaining_ticks_start;
+ x->x_retarget[i] = 0;
+ }
+ }
+
+ for(j=0; j<n_out; j++)
+ {
+ outsum = x->x_outsumbuf + j*n;
+ for(i=n; i; i -= 8, outsum += 8)/* reset out-buffer */
+ {
+ outsum[0] = 0.0f;
+ outsum[1] = 0.0f;
+ outsum[2] = 0.0f;
+ outsum[3] = 0.0f;
+ outsum[4] = 0.0f;
+ outsum[5] = 0.0f;
+ outsum[6] = 0.0f;
+ outsum[7] = 0.0f;
+ }
+ }
+
+ for(j=0; j<n_in; j++)
+ {
+ if(x->x_remaining_ticks[j])
+ {
+ in = io[j];
+ if(in2out_new[j])
+ {
+ outsum = x->x_outsumbuf + n*(in2out_new[j] - 1);
+ mul = x->x_raise_cur;
+ for(i=n; i; i -= 8, outsum += 8, in += 8)/* each new in */
+ {
+ outsum[0] += in[0]*mul;
+ mul += inc;
+ outsum[1] += in[1]*mul;
+ mul += inc;
+ outsum[2] += in[2]*mul;
+ mul += inc;
+ outsum[3] += in[3]*mul;
+ mul += inc;
+ outsum[4] += in[4]*mul;
+ mul += inc;
+ outsum[5] += in[5]*mul;
+ mul += inc;
+ outsum[6] += in[6]*mul;
+ mul += inc;
+ outsum[7] += in[7]*mul;
+ mul += inc;
+ }
+ }
+ // raise_cur = mul;
+
+ in = io[j];
+ if(in2out_old[j])
+ {
+ outsum = x->x_outsumbuf + n*(in2out_old[j] - 1);
+ mul = x->x_fall_cur;
+ for(i=n; i; i -= 8, outsum += 8, in += 8)/* each old in */
+ {
+ outsum[0] += in[0]*mul;
+ mul -= inc;
+ outsum[1] += in[1]*mul;
+ mul -= inc;
+ outsum[2] += in[2]*mul;
+ mul -= inc;
+ outsum[3] += in[3]*mul;
+ mul -= inc;
+ outsum[4] += in[4]*mul;
+ mul -= inc;
+ outsum[5] += in[5]*mul;
+ mul -= inc;
+ outsum[6] += in[6]*mul;
+ mul -= inc;
+ outsum[7] += in[7]*mul;
+ mul -= inc;
+ }
+ }
+ // fall_cur = mul;
+
+ if(!--x->x_remaining_ticks[j])
+ {
+ endofticks = 1;
+ }
+ }
+ else
+ {
+ in = io[j];
+ if(in2out_new[j])
+ {
+ outsum = x->x_outsumbuf + n*(in2out_new[j] - 1);
+ for(i=n; i; i -= 8, outsum += 8, in += 8)/* each in */
+ {
+ outsum[0] += in[0];
+ outsum[1] += in[1];
+ outsum[2] += in[2];
+ outsum[3] += in[3];
+ outsum[4] += in[4];
+ outsum[5] += in[5];
+ outsum[6] += in[6];
+ outsum[7] += in[7];
+ }
+ }
+ }
+ }
+
+ if(x->x_remaining_ticks[j])
+ {
+ x->x_raise_cur += x->x_biginc;
+ x->x_fall_cur -= x->x_biginc;
+ }
+
+ if(endofticks)
+ {
+ x->x_fall_cur = x->x_fall_end;
+ x->x_raise_cur = x->x_raise_end;
+ }
+
+ outsum = x->x_outsumbuf;
+ for(j=0; j<n_out; j++)/* copy out-buffer to out */
+ {
+ out = io[n_in+j];
+ for (i=n; i; i -= 8, out += 8, outsum += 8)
+ {
+ out[0] = outsum[0];
+ out[1] = outsum[1];
+ out[2] = outsum[2];
+ out[3] = outsum[3];
+ out[4] = outsum[4];
+ out[5] = outsum[5];
+ out[6] = outsum[6];
+ out[7] = outsum[7];
+ }
+ }
+ return (w+3);
+}
+
+static void matrix_bundle_line_tilde_dsp(t_matrix_bundle_line_tilde *x, t_signal **sp)
+{
+ int i, n=sp[0]->s_n*x->x_n_out;
+
+ if(!x->x_outsumbuf)
+ {
+ x->x_outsumbufsize = n;
+ x->x_outsumbuf = (t_float *)getbytes(x->x_outsumbufsize * sizeof(t_float));
+ }
+ else if(x->x_outsumbufsize != n)
+ {
+ x->x_outsumbuf = (t_float *)resizebytes(x->x_outsumbuf, x->x_outsumbufsize*sizeof(t_float), n*sizeof(t_float));
+ x->x_outsumbufsize = n;
+ }
+
+ n = x->x_n_in + x->x_n_out;
+ for(i=0; i<n; i++)
+ x->x_io[i] = sp[i]->s_vec;
+
+ n = sp[0]->s_n;
+ x->x_ms2tick = 0.001f * (float)(sp[0]->s_sr) / (float)n;
+ x->x_1overn = 1.0f / (float)n;
+
+ x->x_remaining_ticks_start = (int)(x->x_time_ms * x->x_ms2tick);
+ if(!x->x_remaining_ticks_start)
+ x->x_remaining_ticks_start = 1;
+
+ if(n&7)
+ {
+ dsp_add(matrix_bundle_line_tilde_perform_zero, 2, x, n);
+ post("ERROR!!! matrix_bundle_line_tilde~ : blocksize is %d and not a multiple of 8", n);
+ }
+ else
+ dsp_add(matrix_bundle_line_tilde_perf8, 2, x, n);
+}
+
+
+/* setup/setdown things */
+
+static void matrix_bundle_line_tilde_free(t_matrix_bundle_line_tilde *x)
+{
+ freebytes(x->x_in2out_new, x->x_n_in * sizeof(int));
+ freebytes(x->x_in2out_old, x->x_n_in * sizeof(int));
+ freebytes(x->x_remaining_ticks, x->x_n_in * sizeof(int));
+ freebytes(x->x_retarget, x->x_n_in * sizeof(int));
+ freebytes(x->x_io, (x->x_n_in + x->x_n_out) * sizeof(t_float *));
+ if(x->x_outsumbuf)
+ freebytes(x->x_outsumbuf, x->x_outsumbufsize * sizeof(t_float));
+}
+
+static void *matrix_bundle_line_tilde_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_matrix_bundle_line_tilde *x = (t_matrix_bundle_line_tilde *)pd_new(matrix_bundle_line_tilde_class);
+ int i, n;
+
+ switch (argc)
+ {
+ case 0:
+ x->x_n_in = x->x_n_out = 1;
+ x->x_time_ms = 50.0f;
+ break;
+ case 1:
+ x->x_n_in = x->x_n_out = (int)atom_getint(argv);
+ x->x_time_ms = 50.0f;
+ break;
+ case 2:
+ x->x_n_in = (int)atom_getint(argv);
+ x->x_n_out = (int)atom_getint(argv+1);
+ x->x_time_ms = 50.0f;
+ break;
+ default:
+ x->x_n_in = (int)atom_getint(argv);
+ x->x_n_out = (int)atom_getint(argv+1);
+ x->x_time_ms = atom_getfloat(argv+2);
+ break;
+ }
+
+ if(x->x_n_in < 1)
+ x->x_n_in = 1;
+ if(x->x_n_out < 1)
+ x->x_n_out = 1;
+ if(x->x_time_ms < 0.0f)
+ x->x_time_ms = 50.0f;
+ i = x->x_n_in - 1;
+ while(i--)
+ inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal);
+ i = x->x_n_out;
+ while(i--)
+ outlet_new(&x->x_obj, &s_signal);
+
+ x->x_in2out_new = (int *)getbytes(x->x_n_in * sizeof(int));
+ x->x_in2out_old = (int *)getbytes(x->x_n_in * sizeof(int));
+ x->x_remaining_ticks = (int *)getbytes(x->x_n_in * sizeof(int));
+ x->x_retarget = (int *)getbytes(x->x_n_in * sizeof(int));
+ x->x_io = (t_float **)getbytes((x->x_n_in + x->x_n_out) * sizeof(t_float *));
+ x->x_outsumbuf = (t_float *)0;
+ x->x_outsumbufsize = 0;
+
+ x->x_raise_cur = 1.0f;
+ x->x_raise_end = 1.0f;
+ x->x_fall_cur = 0.0f;
+ x->x_fall_end = 0.0f;
+ x->x_inc = 0.0f;
+ x->x_biginc = 0.0f;
+ x->x_msi = 0;
+ x->x_ms2tick = 0.001f * 44100.0f / 64.0f;
+ x->x_1overn = 1.0f / 64.0f;
+ x->x_remaining_ticks_start = (int)(x->x_time_ms * x->x_ms2tick);
+ if(!x->x_remaining_ticks_start)
+ x->x_remaining_ticks_start = 1;
+
+ n = x->x_n_in;
+ for(i=0; i<n; i++)
+ {
+ x->x_in2out_new[i] = 0;
+ x->x_in2out_old[i] = 0;
+ x->x_remaining_ticks[i] = 0;
+ x->x_retarget[i] = 0;
+ }
+ return(x);
+}
+
+void matrix_bundle_line_tilde_setup(void)
+{
+ matrix_bundle_line_tilde_class = class_new(gensym("matrix_bundle_line~"), (t_newmethod)matrix_bundle_line_tilde_new, (t_method)matrix_bundle_line_tilde_free,
+ sizeof(t_matrix_bundle_line_tilde), 0, A_GIMME, 0);
+ CLASS_MAINSIGNALIN(matrix_bundle_line_tilde_class, t_matrix_bundle_line_tilde, x_msi);
+ class_addmethod(matrix_bundle_line_tilde_class, (t_method)matrix_bundle_line_tilde_dsp, gensym("dsp"), 0);
+ class_addlist(matrix_bundle_line_tilde_class, (t_method)matrix_bundle_line_tilde_list);
+ class_addmethod(matrix_bundle_line_tilde_class, (t_method)matrix_bundle_line_tilde_element, gensym("element"), A_GIMME, 0);
+ class_addmethod(matrix_bundle_line_tilde_class, (t_method)matrix_bundle_line_tilde_bundle, gensym("bundle"), A_GIMME, 0);
+ class_addmethod(matrix_bundle_line_tilde_class, (t_method)matrix_bundle_line_tilde_stop, gensym("stop"), 0);
+ class_addmethod(matrix_bundle_line_tilde_class, (t_method)matrix_bundle_line_tilde_time, gensym("time"), A_FLOAT, 0);
+ class_sethelpsymbol(matrix_bundle_line_tilde_class, gensym("iemhelp/matrix_bundle_line~-help"));
+}
diff --git a/src/matrix_bundle_stat~.c b/src/matrix_bundle_stat~.c
new file mode 100644
index 0000000..bee2593
--- /dev/null
+++ b/src/matrix_bundle_stat~.c
@@ -0,0 +1,283 @@
+/* For information on usage and redistribution, and for a DISCLAIMER OF ALL
+* WARRANTIES, see the file, "LICENSE.txt," in this distribution.
+
+iem_matrix written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2006 */
+
+#include "m_pd.h"
+#include "iemlib.h"
+
+
+/* ---------- matrix_bundle_stat~ - signal matrix multiplication object with message matrix-coeff. ----------- */
+
+typedef struct matrix_bundle_stat_tilde
+{
+ t_object x_obj;
+ int *x_matbuf;
+ t_float **x_io;
+ t_float *x_outsumbuf;
+ int x_outsumbufsize;
+ int x_n_in; /* columns */
+ int x_n_out; /* rows */
+ t_float x_msi;
+} t_matrix_bundle_stat_tilde;
+
+t_class *matrix_bundle_stat_tilde_class;
+
+static void matrix_bundle_stat_tilde_element(t_matrix_bundle_stat_tilde *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int inindex, outindex;
+ int *matrix = x->x_matbuf;
+
+ if(argc < 2)
+ {
+ post("matrix_bundle_stat~ : bad list: <int> output_row_index <int> input_col_index !");
+ return;
+ }
+
+ outindex = (int)atom_getint(argv);
+ argv++;
+ inindex = (int)atom_getint(argv) - 1;
+
+ if(inindex >= x->x_n_in)
+ inindex = x->x_n_in - 1;
+ if(inindex < 0)
+ inindex = 0;
+ if(outindex >= x->x_n_out)
+ outindex = x->x_n_out;
+ if(outindex < 0)
+ outindex = 0;
+
+ matrix[inindex] = outindex;
+}
+
+static void matrix_bundle_stat_tilde_list(t_matrix_bundle_stat_tilde *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int outindex, i, n=x->x_n_in;
+ int *matrix = x->x_matbuf;
+
+ if(argc < n)
+ {
+ post("matrix_bundle_stat~ : bad list: (number_of_input_cols = %d) * <int> output_row_index !", n);
+ return;
+ }
+
+ for(i=0; i<n; i++)
+ {
+ outindex = (int)atom_getint(argv);
+ argv++;
+ if(outindex >= x->x_n_out)
+ outindex = x->x_n_out;
+ if(outindex < 0)
+ outindex = 0;
+ matrix[i] = outindex;
+ }
+}
+
+static void matrix_bundle_stat_tilde_bundle(t_matrix_bundle_stat_tilde *x, t_symbol *s, int argc, t_atom *argv)
+{
+ matrix_bundle_stat_tilde_list(x, &s_list, argc, argv);
+}
+
+/* the dsp thing */
+
+static t_int *matrix_bundle_stat_tilde_perform(t_int *w)
+{
+ t_matrix_bundle_stat_tilde *x = (t_matrix_bundle_stat_tilde *)(w[1]);
+ int n = (int)(w[2]);
+
+ t_float **io = x->x_io;
+ t_float *outsum;
+ int *mat = x->x_matbuf;
+ int n_in = x->x_n_in; /* columns */
+ int n_out = x->x_n_out; /* rows */
+ t_float *in, *out;
+ int i, j, thrw;
+
+ outsum = x->x_outsumbuf;
+ for(j=0; j<n_out; j++)/* reset out-buffer */
+ {
+ for(i=0; i<n; i++)
+ *outsum++ = 0.0f;
+ }
+
+ for(j=0; j<n_in; j++)/* each in */
+ {
+ in = io[j];
+ thrw = mat[j];
+ if(thrw)
+ {
+ thrw--;/* transform index from 1..n to 0..(n-1) */
+ outsum = x->x_outsumbuf + n*thrw;
+ for(i=0; i<n; i++)
+ *outsum++ += *in++;
+ }
+ }
+
+ outsum = x->x_outsumbuf;
+ for(j=0; j<n_out; j++)/* copy out-buffer to out */
+ {
+ out = io[n_in+j];
+ for(i=0; i<n; i++)
+ *out++ = *outsum++;
+ }
+ return (w+3);
+}
+
+static t_int *matrix_bundle_stat_tilde_perf8(t_int *w)
+{
+ t_matrix_bundle_stat_tilde *x = (t_matrix_bundle_stat_tilde *)(w[1]);
+ int n = (int)(w[2]);
+
+ t_float **io = x->x_io;
+ t_float *outsum;
+ int *mat = x->x_matbuf;
+ int n_in = x->x_n_in; /* columns */
+ int n_out = x->x_n_out; /* rows */
+ t_float *in, *out;
+ int i, j, thrw;
+
+ outsum = x->x_outsumbuf;
+ for(j=0; j<n_out; j++)/* reset out-buffer */
+ {
+ for(i=n; i; i -= 8, outsum += 8)
+ {
+ outsum[0] = 0.0f;
+ outsum[1] = 0.0f;
+ outsum[2] = 0.0f;
+ outsum[3] = 0.0f;
+ outsum[4] = 0.0f;
+ outsum[5] = 0.0f;
+ outsum[6] = 0.0f;
+ outsum[7] = 0.0f;
+ }
+ }
+
+ for(j=0; j<n_in; j++)/* each in */
+ {
+ in = io[j];
+ thrw = mat[j];
+ if(thrw)
+ {
+ thrw--;
+ outsum = x->x_outsumbuf + n*thrw;
+ for(i=n; i; i -= 8, outsum += 8, in += 8)
+ {
+ outsum[0] += in[0];
+ outsum[1] += in[1];
+ outsum[2] += in[2];
+ outsum[3] += in[3];
+ outsum[4] += in[4];
+ outsum[5] += in[5];
+ outsum[6] += in[6];
+ outsum[7] += in[7];
+ }
+ }
+ }
+
+ outsum = x->x_outsumbuf;
+ for(j=0; j<n_out; j++)/* copy out-buffer to out */
+ {
+ out = io[n_in+j];
+ for (i=n; i; i -= 8, out += 8, outsum += 8)
+ {
+ out[0] = outsum[0];
+ out[1] = outsum[1];
+ out[2] = outsum[2];
+ out[3] = outsum[3];
+ out[4] = outsum[4];
+ out[5] = outsum[5];
+ out[6] = outsum[6];
+ out[7] = outsum[7];
+ }
+ }
+ return (w+3);
+}
+
+static void matrix_bundle_stat_tilde_dsp(t_matrix_bundle_stat_tilde *x, t_signal **sp)
+{
+ int i, n=sp[0]->s_n*x->x_n_out;
+
+ if(!x->x_outsumbuf)
+ {
+ x->x_outsumbufsize = n;
+ x->x_outsumbuf = (t_float *)getbytes(x->x_outsumbufsize * sizeof(t_float));
+ }
+ else if(x->x_outsumbufsize != n)
+ {
+ x->x_outsumbuf = (t_float *)resizebytes(x->x_outsumbuf, x->x_outsumbufsize*sizeof(t_float), n*sizeof(t_float));
+ x->x_outsumbufsize = n;
+ }
+
+ n = x->x_n_in + x->x_n_out;
+ for(i=0; i<n; i++)
+ {
+ x->x_io[i] = sp[i]->s_vec;
+ /*post("iovec_addr = %d", (unsigned int)x->x_io[i]);*/
+ }
+
+ n = sp[0]->s_n;
+ if(n&7)
+ dsp_add(matrix_bundle_stat_tilde_perform, 2, x, sp[0]->s_n);
+ else
+ dsp_add(matrix_bundle_stat_tilde_perf8, 2, x, sp[0]->s_n);
+}
+
+
+/* setup/setdown things */
+
+static void matrix_bundle_stat_tilde_free(t_matrix_bundle_stat_tilde *x)
+{
+ freebytes(x->x_matbuf, x->x_n_in * sizeof(int));
+ freebytes(x->x_io, (x->x_n_in + x->x_n_out) * sizeof(t_float *));
+ if(x->x_outsumbuf)
+ freebytes(x->x_outsumbuf, x->x_outsumbufsize * sizeof(t_float));
+}
+
+static void *matrix_bundle_stat_tilde_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_matrix_bundle_stat_tilde *x = (t_matrix_bundle_stat_tilde *)pd_new(matrix_bundle_stat_tilde_class);
+ int i;
+
+ switch (argc)
+ {
+ case 0:
+ x->x_n_in = x->x_n_out = 1;
+ break;
+ case 1:
+ x->x_n_in = x->x_n_out = (int)atom_getint(argv);
+ break;
+ default:
+ x->x_n_in = (int)atom_getint(argv);
+ x->x_n_out = (int)atom_getint(argv+1);
+ break;
+ }
+
+ if(x->x_n_in < 1)
+ x->x_n_in = 1;
+ if(x->x_n_out < 1)
+ x->x_n_out = 1;
+ i = x->x_n_in - 1;
+ while(i--)
+ inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal);
+ i = x->x_n_out;
+ while(i--)
+ outlet_new(&x->x_obj, &s_signal);
+ x->x_msi = 0;
+ x->x_outsumbuf = (t_float *)0;
+ x->x_outsumbufsize = 0;
+ x->x_matbuf = (int *)getbytes(x->x_n_in * sizeof(int));
+ x->x_io = (t_float **)getbytes((x->x_n_in + x->x_n_out) * sizeof(t_float *));
+ return (x);
+}
+
+void matrix_bundle_stat_tilde_setup(void)
+{
+ matrix_bundle_stat_tilde_class = class_new(gensym("matrix_bundle_stat~"), (t_newmethod)matrix_bundle_stat_tilde_new, (t_method)matrix_bundle_stat_tilde_free,
+ sizeof(t_matrix_bundle_stat_tilde), 0, A_GIMME, 0);
+ CLASS_MAINSIGNALIN(matrix_bundle_stat_tilde_class, t_matrix_bundle_stat_tilde, x_msi);
+ class_addmethod(matrix_bundle_stat_tilde_class, (t_method)matrix_bundle_stat_tilde_dsp, gensym("dsp"), 0);
+ class_addlist(matrix_bundle_stat_tilde_class, (t_method)matrix_bundle_stat_tilde_list);
+ class_addmethod(matrix_bundle_stat_tilde_class, (t_method)matrix_bundle_stat_tilde_element, gensym("element"), A_GIMME, 0);
+ class_addmethod(matrix_bundle_stat_tilde_class, (t_method)matrix_bundle_stat_tilde_bundle, gensym("bundle"), A_GIMME, 0);
+ class_sethelpsymbol(matrix_bundle_stat_tilde_class, gensym("iemhelp2/matrix_bundle_stat~-help"));
+}
diff --git a/src/matrix_diag_mul_line8~.c b/src/matrix_diag_mul_line8~.c
new file mode 100644
index 0000000..6de4150
--- /dev/null
+++ b/src/matrix_diag_mul_line8~.c
@@ -0,0 +1,409 @@
+/* For information on usage and redistribution, and for a DISCLAIMER OF ALL
+* WARRANTIES, see the file, "LICENSE.txt," in this distribution.
+
+iem_matrix written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2006 */
+
+#include "m_pd.h"
+#include "iemlib.h"
+
+
+/* ---------- matrix_diag_mul_line8~ - signal matrix multiplication object with message matrix-coeff. ----------- */
+
+typedef struct matrix_diag_mul_line8_tilde
+{
+ t_object x_obj;
+ t_float *x_matcur;
+ t_float *x_matend;
+ t_float *x_inc8;
+ t_float *x_biginc;
+ t_float **x_io;
+ t_float *x_buf;
+ int x_bufsize;
+ int x_n_io;
+ t_float x_msi;
+ int x_retarget;
+ t_float x_time_ms;
+ int x_remaining_ticks;
+ t_float x_ms2tick;
+ t_float x_8overn;
+} t_matrix_diag_mul_line8_tilde;
+
+t_class *matrix_diag_mul_line8_tilde_class;
+
+static void matrix_diag_mul_line8_tilde_time(t_matrix_diag_mul_line8_tilde *x, t_floatarg time_ms)
+{
+ if(time_ms <= 0.0f)
+ time_ms = 0.0f;
+ x->x_time_ms = time_ms;
+}
+
+static void matrix_diag_mul_line8_tilde_element(t_matrix_diag_mul_line8_tilde *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int i, j, n=x->x_n_io;
+ t_float *matcur = x->x_matcur;
+ t_float *matend = x->x_matend;
+
+ if(x->x_time_ms <= 0.0f)
+ {
+ if(argc == 2)
+ {
+ i = (int)(atom_getint(argv));
+ argv++;
+ if((i >= 1) && (i <= n))
+ matend[i-1] = matcur[i-1] = atom_getfloat(argv);
+ }
+ else if(argc == 3)
+ {
+ i = (int)(atom_getint(argv));
+ argv++;
+ j = (int)(atom_getint(argv));
+ argv++;
+ if((i >= 1) && (i <= n) && (i == j))
+ matend[i-1] = matcur[i-1] = atom_getfloat(argv);
+ }
+ x->x_remaining_ticks = x->x_retarget = 0;
+ }
+ else
+ {
+ if(argc == 2)
+ {
+ i = (int)(atom_getint(argv));
+ argv++;
+ if((i >= 1) && (i <= n))
+ matend[i-1] = atom_getfloat(argv);
+ }
+ else if(argc == 3)
+ {
+ i = (int)(atom_getint(argv));
+ argv++;
+ j = (int)(atom_getint(argv));
+ argv++;
+ if((i >= 1) && (i <= n) && (i == j))
+ matend[i-1] = atom_getfloat(argv);
+ }
+ x->x_retarget = 1;
+ }
+}
+
+static void matrix_diag_mul_line8_tilde_list(t_matrix_diag_mul_line8_tilde *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int i, n=x->x_n_io;
+ t_float *matcur = x->x_matcur;
+ t_float *matend = x->x_matend;
+
+ if(argc < n)
+ {
+ post("matrix_diag_mul_line8~ : dimensions do not match !!");
+ return;
+ }
+
+ if(x->x_time_ms <= 0.0f)
+ {
+ for(i=0; i<n; i++)
+ {
+ *matend++ = *matcur++ = atom_getfloat(argv);
+ argv++;
+ }
+ x->x_remaining_ticks = x->x_retarget = 0;
+ }
+ else
+ {
+ for(i=0; i<n; i++)
+ {
+ *matend++ = atom_getfloat(argv);
+ argv++;
+ }
+ x->x_retarget = 1;
+ }
+}
+
+static void matrix_diag_mul_line8_tilde_diag(t_matrix_diag_mul_line8_tilde *x, t_symbol *s, int argc, t_atom *argv)
+{
+ matrix_diag_mul_line8_tilde_list(x, &s_list, argc, argv);
+}
+
+static void matrix_diag_mul_line8_tilde_stop(t_matrix_diag_mul_line8_tilde *x)
+{
+ int i = x->x_n_io;
+ t_float *matend=x->x_matend;
+ t_float *matcur=x->x_matcur;
+
+ while(i--)
+ {
+ *matend++ = *matcur++;
+ }
+ x->x_remaining_ticks = x->x_retarget = 0;
+}
+
+/* the dsp thing */
+
+static t_int *matrix_diag_mul_line8_tilde_perform_zero(t_int *w)
+{
+ t_matrix_diag_mul_line8_tilde *x = (t_matrix_diag_mul_line8_tilde *)(w[1]);
+ int n = (int)(w[2]);
+ t_float **io = x->x_io;
+ int n_io = x->x_n_io;
+ t_float *out;
+ int i, j;
+
+ for(j=0; j<n_io; j++)/* output-vector-row */
+ {
+ out = io[n_io+j];
+ for(i=0; i<n; i++)
+ *out++ = 0.0f;
+ }
+ return (w+3);
+}
+
+static t_int *matrix_diag_mul_line8_tilde_perf8(t_int *w)
+{
+ t_matrix_diag_mul_line8_tilde *x = (t_matrix_diag_mul_line8_tilde *)(w[1]);
+ int n = (int)(w[2]);
+ t_float **io = x->x_io;
+ t_float *buf;
+ t_float *matcur, *matend;
+ t_float *inc8, *biginc, inc;
+ int n_io = x->x_n_io;
+ int hn_io = n_io / 2;
+ int dn_io = 2 * n_io;
+ t_float *in, *out1, *out2, mul;
+ int i, j;
+
+ if(x->x_retarget)
+ {
+ int nticks = (int)(x->x_time_ms * x->x_ms2tick);
+
+ if(!nticks)
+ nticks = 1;
+ x->x_remaining_ticks = nticks;
+ j = n_io;
+ inc8 = x->x_inc8;
+ matcur = x->x_matcur;
+ matend = x->x_matend;
+ mul = x->x_8overn / (t_float)nticks;
+ while(j--)
+ {
+ *inc8++ = (*matend++ - *matcur++) * mul;
+ }
+ j = n_io;
+ biginc = x->x_biginc;
+ matcur = x->x_matcur;
+ matend = x->x_matend;
+ mul = 1.0f / (t_float)nticks;
+ while(j--)
+ {
+ *biginc++ = (*matend++ - *matcur++) * mul;
+ }
+ x->x_retarget = 0;
+ }
+
+ if(x->x_remaining_ticks)
+ {
+ inc8 = x->x_inc8;
+ biginc = x->x_biginc;
+ matcur = x->x_matcur;
+ for(j=0; j<n_io; j++)
+ {
+ inc = inc8[j];
+ mul = matcur[j];
+ in = io[j];
+ for(i=n; i; i -= 8, in += 8)
+ {
+ in[0] *= mul;
+ in[1] *= mul;
+ in[2] *= mul;
+ in[3] *= mul;
+ in[4] *= mul;
+ in[5] *= mul;
+ in[6] *= mul;
+ in[7] *= mul;
+ mul += inc;
+ }
+ matcur[j] += biginc[j];
+ }
+ if(!--x->x_remaining_ticks)
+ {
+ matcur = x->x_matcur;
+ matend = x->x_matend;
+ i = n_io;
+ while(i--)
+ *matcur++ = *matend++;
+ }
+ }
+ else
+ {
+ matend = x->x_matend;
+ for(j=0; j<n_io; j++)
+ {
+ mul = matend[j];
+ in = io[j];
+ for(i=n; i; i -= 8, in += 8)
+ {
+ in[0] *= mul;
+ in[1] *= mul;
+ in[2] *= mul;
+ in[3] *= mul;
+ in[4] *= mul;
+ in[5] *= mul;
+ in[6] *= mul;
+ in[7] *= mul;
+ }
+ }
+ }
+
+ for(j=0; j<hn_io; j++)
+ {
+ in = io[j];
+ buf = x->x_buf;
+ for(i=n; i; i -= 8, buf += 8, in += 8)
+ {
+ buf[0] = in[0];
+ buf[1] = in[1];
+ buf[2] = in[2];
+ buf[3] = in[3];
+ buf[4] = in[4];
+ buf[5] = in[5];
+ buf[6] = in[6];
+ buf[7] = in[7];
+ }
+ in = io[n_io-j-1];
+ out1 = io[j+n_io];
+ out2 = io[dn_io-j-1];
+ buf = x->x_buf;
+ for(i=n; i; i -= 8, buf += 8, in += 8, out1 += 8, out2 += 8)
+ {
+ out2[0] = in[0];
+ out2[1] = in[1];
+ out2[2] = in[2];
+ out2[3] = in[3];
+ out2[4] = in[4];
+ out2[5] = in[5];
+ out2[6] = in[6];
+ out2[7] = in[7];
+ out1[0] = buf[0];
+ out1[1] = buf[1];
+ out1[2] = buf[2];
+ out1[3] = buf[3];
+ out1[4] = buf[4];
+ out1[5] = buf[5];
+ out1[6] = buf[6];
+ out1[7] = buf[7];
+ }
+ }
+ return (w+3);
+}
+
+static void matrix_diag_mul_line8_tilde_dsp(t_matrix_diag_mul_line8_tilde *x, t_signal **sp)
+{
+ int i, n=sp[0]->s_n;
+
+ if(!x->x_buf)
+ {
+ x->x_bufsize = n;
+ x->x_buf = (t_float *)getbytes(x->x_bufsize * sizeof(t_float));
+ }
+ else if(x->x_bufsize != n)
+ {
+ x->x_buf = (t_float *)resizebytes(x->x_buf, x->x_bufsize*sizeof(t_float), n*sizeof(t_float));
+ x->x_bufsize = n;
+ }
+
+ n = 2 * x->x_n_io;
+ for(i=0; i<n; i++)
+ {
+ x->x_io[i] = sp[i]->s_vec;
+ // post("iovec_addr = %d", (unsigned int)x->x_io[i]);
+ }
+
+ n = sp[0]->s_n;
+ x->x_ms2tick = 0.001f * (t_float)(sp[0]->s_sr) / (t_float)n;
+ x->x_8overn = 8.0f / (t_float)n;
+
+ if(n&7)
+ dsp_add(matrix_diag_mul_line8_tilde_perform_zero, 2, x, n);
+ else
+ dsp_add(matrix_diag_mul_line8_tilde_perf8, 2, x, n);
+}
+
+
+/* setup/setdown things */
+
+static void matrix_diag_mul_line8_tilde_free(t_matrix_diag_mul_line8_tilde *x)
+{
+ freebytes(x->x_matcur, x->x_n_io * sizeof(t_float));
+ freebytes(x->x_matend, x->x_n_io * sizeof(t_float));
+ freebytes(x->x_inc8, x->x_n_io * sizeof(t_float));
+ freebytes(x->x_biginc, x->x_n_io * sizeof(t_float));
+ freebytes(x->x_io, 2 * x->x_n_io * sizeof(t_float *));
+ if(x->x_buf)
+ freebytes(x->x_buf, x->x_bufsize * sizeof(t_float));
+}
+
+static void *matrix_diag_mul_line8_tilde_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_matrix_diag_mul_line8_tilde *x = (t_matrix_diag_mul_line8_tilde *)pd_new(matrix_diag_mul_line8_tilde_class);
+ int i, n;
+
+ switch (argc)
+ {
+ case 0:
+ x->x_n_io = 1;
+ x->x_time_ms = 50.0f;
+ break;
+ case 1:
+ x->x_n_io = (int)atom_getint(argv);
+ x->x_time_ms = 50.0f;
+ break;
+ default:
+ x->x_n_io = (int)atom_getint(argv);
+ x->x_time_ms = atom_getfloat(argv+1);
+ break;
+ }
+
+ if(x->x_time_ms < 0.0f)
+ x->x_time_ms = 50.0f;
+ if(x->x_n_io < 1)
+ x->x_n_io = 1;
+ i = x->x_n_io - 1;
+ while(i--)
+ inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal);
+ i = x->x_n_io;
+ while(i--)
+ outlet_new(&x->x_obj, &s_signal);
+ x->x_msi = 0;
+ x->x_buf = (t_float *)0;
+ x->x_bufsize = 0;
+ x->x_matcur = (t_float *)getbytes(x->x_n_io * sizeof(t_float));
+ x->x_matend = (t_float *)getbytes(x->x_n_io * sizeof(t_float));
+ x->x_inc8 = (t_float *)getbytes(x->x_n_io * sizeof(t_float));
+ x->x_biginc = (t_float *)getbytes(x->x_n_io * sizeof(t_float));
+ x->x_io = (t_float **)getbytes(2 * x->x_n_io * sizeof(t_float *));
+ x->x_ms2tick = 0.001f * 44100.0f / 64.0f;
+ x->x_8overn = 8.0f / 64.0f;
+ x->x_remaining_ticks = 0;
+ x->x_retarget = 0;
+
+ n = x->x_n_io;
+ for(i=0; i<n; i++)
+ {
+ x->x_matcur[i] = 0.0f;
+ x->x_matend[i] = 0.0f;
+ x->x_inc8[i] = 0.0f;
+ x->x_biginc[i] = 0.0f;
+ }
+ return(x);
+}
+
+void matrix_diag_mul_line8_tilde_setup(void)
+{
+ matrix_diag_mul_line8_tilde_class = class_new(gensym("matrix_diag_mul_line8~"), (t_newmethod)matrix_diag_mul_line8_tilde_new, (t_method)matrix_diag_mul_line8_tilde_free,
+ sizeof(t_matrix_diag_mul_line8_tilde), 0, A_GIMME, 0);
+ CLASS_MAINSIGNALIN(matrix_diag_mul_line8_tilde_class, t_matrix_diag_mul_line8_tilde, x_msi);
+ class_addmethod(matrix_diag_mul_line8_tilde_class, (t_method)matrix_diag_mul_line8_tilde_dsp, gensym("dsp"), 0);
+ class_addlist(matrix_diag_mul_line8_tilde_class, (t_method)matrix_diag_mul_line8_tilde_list);
+ class_addmethod(matrix_diag_mul_line8_tilde_class, (t_method)matrix_diag_mul_line8_tilde_diag, gensym("diag"), A_GIMME, 0);
+ class_addmethod(matrix_diag_mul_line8_tilde_class, (t_method)matrix_diag_mul_line8_tilde_element, gensym("element"), A_GIMME, 0);
+ class_addmethod(matrix_diag_mul_line8_tilde_class, (t_method)matrix_diag_mul_line8_tilde_stop, gensym("stop"), 0);
+ class_addmethod(matrix_diag_mul_line8_tilde_class, (t_method)matrix_diag_mul_line8_tilde_time, gensym("time"), A_FLOAT, 0);
+ class_sethelpsymbol(matrix_diag_mul_line8_tilde_class, gensym("iemhelp2/matrix_diag_mul_line8~-help"));
+}
diff --git a/src/matrix_diag_mul_line~.c b/src/matrix_diag_mul_line~.c
new file mode 100644
index 0000000..bb4c9e7
--- /dev/null
+++ b/src/matrix_diag_mul_line~.c
@@ -0,0 +1,415 @@
+/* For information on usage and redistribution, and for a DISCLAIMER OF ALL
+* WARRANTIES, see the file, "LICENSE.txt," in this distribution.
+
+iem_matrix written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2006 */
+
+#include "m_pd.h"
+#include "iemlib.h"
+
+/* ---------- matrix_diag_mul_line~ - signal matrix multiplication object with message matrix-coeff. ----------- */
+
+typedef struct matrix_diag_mul_line_tilde
+{
+ t_object x_obj;
+ t_float *x_matcur;
+ t_float *x_matend;
+ t_float *x_inc;
+ t_float *x_biginc;
+ t_float **x_io;
+ t_float *x_buf;
+ int x_bufsize;
+ int x_n_io;
+ t_float x_msi;
+ int x_retarget;
+ t_float x_time_ms;
+ int x_remaining_ticks;
+ t_float x_ms2tick;
+ t_float x_1overn;
+} t_matrix_diag_mul_line_tilde;
+
+t_class *matrix_diag_mul_line_tilde_class;
+
+static void matrix_diag_mul_line_tilde_time(t_matrix_diag_mul_line_tilde *x, t_floatarg time_ms)
+{
+ if(time_ms <= 0.0f)
+ time_ms = 0.0f;
+ x->x_time_ms = time_ms;
+}
+
+static void matrix_diag_mul_line_tilde_element(t_matrix_diag_mul_line_tilde *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int i, j, n=x->x_n_io;
+ t_float *matcur = x->x_matcur;
+ t_float *matend = x->x_matend;
+
+ if(x->x_time_ms <= 0.0f)
+ {
+ if(argc == 2)
+ {
+ i = (int)(atom_getint(argv));
+ argv++;
+ if((i >= 1) && (i <= n))
+ matend[i-1] = matcur[i-1] = atom_getfloat(argv);
+ }
+ else if(argc == 3)
+ {
+ i = (int)(atom_getint(argv));
+ argv++;
+ j = (int)(atom_getint(argv));
+ argv++;
+ if((i >= 1) && (i <= n) && (i == j))
+ matend[i-1] = matcur[i-1] = atom_getfloat(argv);
+ }
+ x->x_remaining_ticks = x->x_retarget = 0;
+ }
+ else
+ {
+ if(argc == 2)
+ {
+ i = (int)(atom_getint(argv));
+ argv++;
+ if((i >= 1) && (i <= n))
+ matend[i-1] = atom_getfloat(argv);
+ }
+ else if(argc == 3)
+ {
+ i = (int)(atom_getint(argv));
+ argv++;
+ j = (int)(atom_getint(argv));
+ argv++;
+ if((i >= 1) && (i <= n) && (i == j))
+ matend[i-1] = atom_getfloat(argv);
+ }
+ x->x_retarget = 1;
+ }
+}
+
+static void matrix_diag_mul_line_tilde_list(t_matrix_diag_mul_line_tilde *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int i, n=x->x_n_io;
+ t_float *matcur = x->x_matcur;
+ t_float *matend = x->x_matend;
+
+ if(argc < n)
+ {
+ post("matrix_diag_mul_line~ : dimensions do not match !!");
+ return;
+ }
+
+ if(x->x_time_ms <= 0.0f)
+ {
+ for(i=0; i<n; i++)
+ {
+ *matend++ = *matcur++ = atom_getfloat(argv);
+ argv++;
+ }
+ x->x_remaining_ticks = x->x_retarget = 0;
+ }
+ else
+ {
+ for(i=0; i<n; i++)
+ {
+ *matend++ = atom_getfloat(argv);
+ argv++;
+ }
+ x->x_retarget = 1;
+ }
+}
+
+static void matrix_diag_mul_line_tilde_diag(t_matrix_diag_mul_line_tilde *x, t_symbol *s, int argc, t_atom *argv)
+{
+ matrix_diag_mul_line_tilde_list(x, &s_list, argc, argv);
+}
+
+static void matrix_diag_mul_line_tilde_stop(t_matrix_diag_mul_line_tilde *x)
+{
+ int i = x->x_n_io;
+ t_float *matend=x->x_matend;
+ t_float *matcur=x->x_matcur;
+
+ while(i--)
+ {
+ *matend++ = *matcur++;
+ }
+ x->x_remaining_ticks = x->x_retarget = 0;
+}
+
+/* the dsp thing */
+
+static t_int *matrix_diag_mul_line_tilde_perform_zero(t_int *w)
+{
+ t_matrix_diag_mul_line_tilde *x = (t_matrix_diag_mul_line_tilde *)(w[1]);
+ int n = (int)(w[2]);
+ t_float **io = x->x_io;
+ int n_io = x->x_n_io;
+ t_float *out;
+ int i, j;
+
+ for(j=0; j<n_io; j++)/* output-vector-row */
+ {
+ out = io[n_io+j];
+ for(i=0; i<n; i++)
+ *out++ = 0.0f;
+ }
+ return (w+3);
+}
+
+static t_int *matrix_diag_mul_line_tilde_perf8(t_int *w)
+{
+ t_matrix_diag_mul_line_tilde *x = (t_matrix_diag_mul_line_tilde *)(w[1]);
+ int n = (int)(w[2]);
+ t_float **io = x->x_io;
+ t_float *buf;
+ t_float *matcur, *matend;
+ t_float *incp, *biginc, inc;
+ int n_io = x->x_n_io;
+ int hn_io = n_io / 2;
+ int dn_io = 2 * n_io;
+ t_float *in, *out1, *out2, mul;
+ int i, j;
+
+ if(x->x_retarget)
+ {
+ int nticks = (int)(x->x_time_ms * x->x_ms2tick);
+
+ if(!nticks)
+ nticks = 1;
+ x->x_remaining_ticks = nticks;
+ j = n_io;
+ incp = x->x_inc;
+ matcur = x->x_matcur;
+ matend = x->x_matend;
+ mul = x->x_1overn / (t_float)nticks;
+ while(j--)
+ {
+ *incp++ = (*matend++ - *matcur++) * mul;
+ }
+ j = n_io;
+ biginc = x->x_biginc;
+ matcur = x->x_matcur;
+ matend = x->x_matend;
+ mul = 1.0f / (t_float)nticks;
+ while(j--)
+ {
+ *biginc++ = (*matend++ - *matcur++) * mul;
+ }
+ x->x_retarget = 0;
+ }
+
+ if(x->x_remaining_ticks)
+ {
+ incp = x->x_inc;
+ biginc = x->x_biginc;
+ matcur = x->x_matcur;
+ for(j=0; j<n_io; j++)
+ {
+ inc = incp[j];
+ mul = matcur[j];
+ in = io[j];
+ for(i=n; i; i -= 8, in += 8)
+ {
+ in[0] *= mul;
+ mul += inc;
+ in[1] *= mul;
+ mul += inc;
+ in[2] *= mul;
+ mul += inc;
+ in[3] *= mul;
+ mul += inc;
+ in[4] *= mul;
+ mul += inc;
+ in[5] *= mul;
+ mul += inc;
+ in[6] *= mul;
+ mul += inc;
+ in[7] *= mul;
+ mul += inc;
+ }
+ matcur[j] += biginc[j];
+ }
+ if(!--x->x_remaining_ticks)
+ {
+ matcur = x->x_matcur;
+ matend = x->x_matend;
+ i = n_io;
+ while(i--)
+ *matcur++ = *matend++;
+ }
+ }
+ else
+ {
+ matend = x->x_matend;
+ for(j=0; j<n_io; j++)
+ {
+ mul = matend[j];
+ in = io[j];
+ for(i=n; i; i -= 8, in += 8)
+ {
+ in[0] *= mul;
+ in[1] *= mul;
+ in[2] *= mul;
+ in[3] *= mul;
+ in[4] *= mul;
+ in[5] *= mul;
+ in[6] *= mul;
+ in[7] *= mul;
+ }
+ }
+ }
+
+ for(j=0; j<hn_io; j++)
+ {
+ in = io[j];
+ buf = x->x_buf;
+ for(i=n; i; i -= 8, buf += 8, in += 8)
+ {
+ buf[0] = in[0];
+ buf[1] = in[1];
+ buf[2] = in[2];
+ buf[3] = in[3];
+ buf[4] = in[4];
+ buf[5] = in[5];
+ buf[6] = in[6];
+ buf[7] = in[7];
+ }
+ in = io[n_io-j-1];
+ out1 = io[j+n_io];
+ out2 = io[dn_io-j-1];
+ buf = x->x_buf;
+ for(i=n; i; i -= 8, buf += 8, in += 8, out1 += 8, out2 += 8)
+ {
+ out2[0] = in[0];
+ out2[1] = in[1];
+ out2[2] = in[2];
+ out2[3] = in[3];
+ out2[4] = in[4];
+ out2[5] = in[5];
+ out2[6] = in[6];
+ out2[7] = in[7];
+ out1[0] = buf[0];
+ out1[1] = buf[1];
+ out1[2] = buf[2];
+ out1[3] = buf[3];
+ out1[4] = buf[4];
+ out1[5] = buf[5];
+ out1[6] = buf[6];
+ out1[7] = buf[7];
+ }
+ }
+ return (w+3);
+}
+
+static void matrix_diag_mul_line_tilde_dsp(t_matrix_diag_mul_line_tilde *x, t_signal **sp)
+{
+ int i, n=sp[0]->s_n;
+
+ if(!x->x_buf)
+ {
+ x->x_bufsize = n;
+ x->x_buf = (t_float *)getbytes(x->x_bufsize * sizeof(t_float));
+ }
+ else if(x->x_bufsize != n)
+ {
+ x->x_buf = (t_float *)resizebytes(x->x_buf, x->x_bufsize*sizeof(t_float), n*sizeof(t_float));
+ x->x_bufsize = n;
+ }
+
+ n = 2 * x->x_n_io;
+ for(i=0; i<n; i++)
+ {
+ x->x_io[i] = sp[i]->s_vec;
+ // post("iovec_addr = %d", (unsigned int)x->x_io[i]);
+ }
+
+ n = sp[0]->s_n;
+ x->x_ms2tick = 0.001f * (t_float)(sp[0]->s_sr) / (t_float)n;
+ x->x_1overn = 1.0f / (t_float)n;
+
+ if(n&7)
+ dsp_add(matrix_diag_mul_line_tilde_perform_zero, 2, x, n);
+ else
+ dsp_add(matrix_diag_mul_line_tilde_perf8, 2, x, n);
+}
+
+
+/* setup/setdown things */
+
+static void matrix_diag_mul_line_tilde_free(t_matrix_diag_mul_line_tilde *x)
+{
+ freebytes(x->x_matcur, x->x_n_io * sizeof(t_float));
+ freebytes(x->x_matend, x->x_n_io * sizeof(t_float));
+ freebytes(x->x_inc, x->x_n_io * sizeof(t_float));
+ freebytes(x->x_biginc, x->x_n_io * sizeof(t_float));
+ freebytes(x->x_io, 2 * x->x_n_io * sizeof(t_float *));
+ if(x->x_buf)
+ freebytes(x->x_buf, x->x_bufsize * sizeof(t_float));
+}
+
+static void *matrix_diag_mul_line_tilde_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_matrix_diag_mul_line_tilde *x = (t_matrix_diag_mul_line_tilde *)pd_new(matrix_diag_mul_line_tilde_class);
+ int i, n;
+
+ switch (argc)
+ {
+ case 0:
+ x->x_n_io = 1;
+ x->x_time_ms = 50.0f;
+ break;
+ case 1:
+ x->x_n_io = (int)atom_getint(argv);
+ x->x_time_ms = 50.0f;
+ break;
+ default:
+ x->x_n_io = (int)atom_getint(argv);
+ x->x_time_ms = atom_getfloat(argv+1);
+ break;
+ }
+
+ if(x->x_time_ms < 0.0f)
+ x->x_time_ms = 50.0f;
+ if(x->x_n_io < 1)
+ x->x_n_io = 1;
+ i = x->x_n_io - 1;
+ while(i--)
+ inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal);
+ i = x->x_n_io;
+ while(i--)
+ outlet_new(&x->x_obj, &s_signal);
+ x->x_msi = 0;
+ x->x_buf = (t_float *)0;
+ x->x_bufsize = 0;
+ x->x_matcur = (t_float *)getbytes(x->x_n_io * sizeof(t_float));
+ x->x_matend = (t_float *)getbytes(x->x_n_io * sizeof(t_float));
+ x->x_inc = (t_float *)getbytes(x->x_n_io * sizeof(t_float));
+ x->x_biginc = (t_float *)getbytes(x->x_n_io * sizeof(t_float));
+ x->x_io = (t_float **)getbytes(2 * x->x_n_io * sizeof(t_float *));
+ x->x_ms2tick = 0.001f * 44100.0f / 64.0f;
+ x->x_1overn = 1.0f / 64.0f;
+ x->x_remaining_ticks = 0;
+ x->x_retarget = 0;
+
+ n = x->x_n_io;
+ for(i=0; i<n; i++)
+ {
+ x->x_matcur[i] = 0.0f;
+ x->x_matend[i] = 0.0f;
+ x->x_inc[i] = 0.0f;
+ x->x_biginc[i] = 0.0f;
+ }
+ return(x);
+}
+
+void matrix_diag_mul_line_tilde_setup(void)
+{
+ matrix_diag_mul_line_tilde_class = class_new(gensym("matrix_diag_mul_line~"), (t_newmethod)matrix_diag_mul_line_tilde_new, (t_method)matrix_diag_mul_line_tilde_free,
+ sizeof(t_matrix_diag_mul_line_tilde), 0, A_GIMME, 0);
+ CLASS_MAINSIGNALIN(matrix_diag_mul_line_tilde_class, t_matrix_diag_mul_line_tilde, x_msi);
+ class_addmethod(matrix_diag_mul_line_tilde_class, (t_method)matrix_diag_mul_line_tilde_dsp, gensym("dsp"), 0);
+ class_addmethod(matrix_diag_mul_line_tilde_class, (t_method)matrix_diag_mul_line_tilde_diag, gensym("diag"), A_GIMME, 0);
+ class_addmethod(matrix_diag_mul_line_tilde_class, (t_method)matrix_diag_mul_line_tilde_element, gensym("element"), A_GIMME, 0);
+ class_addlist(matrix_diag_mul_line_tilde_class, (t_method)matrix_diag_mul_line_tilde_list);
+ class_addmethod(matrix_diag_mul_line_tilde_class, (t_method)matrix_diag_mul_line_tilde_stop, gensym("stop"), 0);
+ class_addmethod(matrix_diag_mul_line_tilde_class, (t_method)matrix_diag_mul_line_tilde_time, gensym("time"), A_FLOAT, 0);
+ class_sethelpsymbol(matrix_diag_mul_line_tilde_class, gensym("iemhelp2/matrix_diag_mul_line~-help"));
+}
diff --git a/src/matrix_diag_mul_stat~.c b/src/matrix_diag_mul_stat~.c
new file mode 100644
index 0000000..3b9e9e5
--- /dev/null
+++ b/src/matrix_diag_mul_stat~.c
@@ -0,0 +1,269 @@
+/* For information on usage and redistribution, and for a DISCLAIMER OF ALL
+* WARRANTIES, see the file, "LICENSE.txt," in this distribution.
+
+iem_matrix written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2006 */
+
+#include "m_pd.h"
+#include "iemlib.h"
+
+
+/* ---------- matrix_diag_mul_stat~ - signal matrix multiplication object with message matrix-coeff. ----------- */
+
+typedef struct matrix_diag_mul_stat_tilde
+{
+ t_object x_obj;
+ t_float *x_matbuf;
+ t_float **x_io;
+ t_float *x_buf;
+ int x_bufsize;
+ int x_n_io;
+ t_float x_msi;
+} t_matrix_diag_mul_stat_tilde;
+
+t_class *matrix_diag_mul_stat_tilde_class;
+
+static void matrix_diag_mul_stat_tilde_list(t_matrix_diag_mul_stat_tilde *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int i, n=x->x_n_io;
+ t_float *matrix = x->x_matbuf;
+
+ if(argc < n)
+ {
+ post("matrix_diag_mul_stat~ : dimensions do not match !!");
+ return;
+ }
+
+ for(i=0; i<n; i++)
+ {
+ *matrix++ = atom_getfloat(argv);
+ argv++;
+ }
+}
+
+static void matrix_diag_mul_stat_tilde_diag(t_matrix_diag_mul_stat_tilde *x, t_symbol *s, int argc, t_atom *argv)
+{
+ matrix_diag_mul_stat_tilde_list(x, &s_list, argc, argv);
+}
+
+static void matrix_diag_mul_stat_tilde_element(t_matrix_diag_mul_stat_tilde *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int i, j, n=x->x_n_io;
+ t_float *matrix = x->x_matbuf;
+
+ if(argc == 2)
+ {
+ i = (int)(atom_getint(argv));
+ argv++;
+ if((i >= 1) && (i <= n))
+ matrix[i-1] = atom_getfloat(argv);
+ }
+ else if(argc == 3)
+ {
+ i = (int)(atom_getint(argv));
+ argv++;
+ j = (int)(atom_getint(argv));
+ argv++;
+ if((i >= 1) && (i <= n) && (i == j))
+ matrix[i-1] = atom_getfloat(argv);
+ }
+}
+
+/* the dsp thing */
+
+static t_int *matrix_diag_mul_stat_tilde_perform(t_int *w)
+{
+ t_matrix_diag_mul_stat_tilde *x = (t_matrix_diag_mul_stat_tilde *)(w[1]);
+ int n = (int)(w[2]);
+ t_float **io = x->x_io;
+ t_float *buf = x->x_buf;
+ t_float *mat = x->x_matbuf;
+ int n_io = x->x_n_io;
+ int hn_io = n_io / 2;
+ int dn_io = 2 * n_io;
+ t_float *in, *out1, *out2, mul;
+ int i, j;
+
+ for(j=0; j<n_io; j++)
+ {
+ mul = mat[j];
+ in = io[j];
+ for(i=0; i<n; i++)
+ {
+ in[i] *= mul;
+ }
+ }
+ for(j=0; j<hn_io; j++)
+ {
+ in = io[j];
+ for(i=0; i<n; i++)
+ {
+ buf[i] = in[i];
+ }
+ in = io[n_io-j-1];
+ out1 = io[j+n_io];
+ out2 = io[dn_io-j-1];
+ for(i=0; i<n; i++)
+ {
+ out1[i] = in[i];
+ out2[i] = buf[i];
+ }
+ }
+ return (w+3);
+}
+
+static t_int *matrix_diag_mul_stat_tilde_perf8(t_int *w)
+{
+ t_matrix_diag_mul_stat_tilde *x = (t_matrix_diag_mul_stat_tilde *)(w[1]);
+ int n = (int)(w[2]);
+ t_float **io = x->x_io;
+ t_float *buf;
+ t_float *mat = x->x_matbuf;
+ int n_io = x->x_n_io;
+ int hn_io = n_io / 2;
+ int dn_io = 2 * n_io;
+ t_float *in, *out1, *out2, mul;
+ int i, j;
+
+ for(j=0; j<n_io; j++)
+ {
+ mul = mat[j];
+ in = io[j];
+ for(i=n; i; i -= 8, in += 8)
+ {
+ in[0] *= mul;
+ in[1] *= mul;
+ in[2] *= mul;
+ in[3] *= mul;
+ in[4] *= mul;
+ in[5] *= mul;
+ in[6] *= mul;
+ in[7] *= mul;
+ }
+ }
+ for(j=0; j<hn_io; j++)
+ {
+ in = io[j];
+ buf = x->x_buf;
+ for(i=n; i; i -= 8, buf += 8, in += 8)
+ {
+ buf[0] = in[0];
+ buf[1] = in[1];
+ buf[2] = in[2];
+ buf[3] = in[3];
+ buf[4] = in[4];
+ buf[5] = in[5];
+ buf[6] = in[6];
+ buf[7] = in[7];
+ }
+ in = io[n_io-j-1];
+ out1 = io[j+n_io];
+ out2 = io[dn_io-j-1];
+ buf = x->x_buf;
+ for(i=n; i; i -= 8, buf += 8, in += 8, out1 += 8, out2 += 8)
+ {
+ out2[0] = in[0];
+ out2[1] = in[1];
+ out2[2] = in[2];
+ out2[3] = in[3];
+ out2[4] = in[4];
+ out2[5] = in[5];
+ out2[6] = in[6];
+ out2[7] = in[7];
+ out1[0] = buf[0];
+ out1[1] = buf[1];
+ out1[2] = buf[2];
+ out1[3] = buf[3];
+ out1[4] = buf[4];
+ out1[5] = buf[5];
+ out1[6] = buf[6];
+ out1[7] = buf[7];
+ }
+ }
+ return (w+3);
+}
+
+static void matrix_diag_mul_stat_tilde_dsp(t_matrix_diag_mul_stat_tilde *x, t_signal **sp)
+{
+ int i, n=sp[0]->s_n;
+
+ if(!x->x_buf)
+ {
+ x->x_bufsize = n;
+ x->x_buf = (t_float *)getbytes(x->x_bufsize * sizeof(t_float));
+ }
+ else if(x->x_bufsize != n)
+ {
+ x->x_buf = (t_float *)resizebytes(x->x_buf, x->x_bufsize*sizeof(t_float), n*sizeof(t_float));
+ x->x_bufsize = n;
+ }
+
+ n = 2 * x->x_n_io;
+ for(i=0; i<n; i++)
+ {
+ x->x_io[i] = sp[i]->s_vec;
+ // post("iovec_addr = %d", (unsigned int)x->x_io[i]);
+ }
+
+ n = sp[0]->s_n;
+ if(n&7)
+ dsp_add(matrix_diag_mul_stat_tilde_perform, 2, x, n);
+ else
+ dsp_add(matrix_diag_mul_stat_tilde_perf8, 2, x, n);
+}
+
+
+/* setup/setdown things */
+
+static void matrix_diag_mul_stat_tilde_free(t_matrix_diag_mul_stat_tilde *x)
+{
+ freebytes(x->x_matbuf, x->x_n_io * sizeof(t_float));
+ freebytes(x->x_io, 2 * x->x_n_io * sizeof(t_float *));
+ if(x->x_buf)
+ freebytes(x->x_buf, x->x_bufsize * sizeof(t_float));
+}
+
+static void *matrix_diag_mul_stat_tilde_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_matrix_diag_mul_stat_tilde *x = (t_matrix_diag_mul_stat_tilde *)pd_new(matrix_diag_mul_stat_tilde_class);
+ int i;
+
+ switch (argc)
+ {
+ case 0:
+ x->x_n_io = 1;
+ break;
+ default:
+ x->x_n_io = (int)atom_getint(argv);
+ break;
+ }
+
+ if(x->x_n_io < 1)
+ x->x_n_io = 1;
+ i = x->x_n_io - 1;
+ while(i--)
+ inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal);
+ i = x->x_n_io;
+ while(i--)
+ outlet_new(&x->x_obj, &s_signal);
+ x->x_msi = 0;
+ x->x_buf = (t_float *)0;
+ x->x_bufsize = 0;
+ x->x_matbuf = (t_float *)getbytes(x->x_n_io * sizeof(t_float));
+ i = x->x_n_io;
+ while(i--)
+ x->x_matbuf[i] = 0.0f;
+ x->x_io = (t_float **)getbytes(2 * x->x_n_io * sizeof(t_float *));
+ return(x);
+}
+
+void matrix_diag_mul_stat_tilde_setup(void)
+{
+ matrix_diag_mul_stat_tilde_class = class_new(gensym("matrix_diag_mul_stat~"), (t_newmethod)matrix_diag_mul_stat_tilde_new, (t_method)matrix_diag_mul_stat_tilde_free,
+ sizeof(t_matrix_diag_mul_stat_tilde), 0, A_GIMME, 0);
+ CLASS_MAINSIGNALIN(matrix_diag_mul_stat_tilde_class, t_matrix_diag_mul_stat_tilde, x_msi);
+ class_addmethod(matrix_diag_mul_stat_tilde_class, (t_method)matrix_diag_mul_stat_tilde_dsp, gensym("dsp"), 0);
+ class_addmethod(matrix_diag_mul_stat_tilde_class, (t_method)matrix_diag_mul_stat_tilde_diag, gensym("diag"), A_GIMME, 0);
+ class_addmethod(matrix_diag_mul_stat_tilde_class, (t_method)matrix_diag_mul_stat_tilde_element, gensym("element"), A_GIMME, 0);
+ class_addlist(matrix_diag_mul_stat_tilde_class, (t_method)matrix_diag_mul_stat_tilde_list);
+ class_sethelpsymbol(matrix_diag_mul_stat_tilde_class, gensym("iemhelp2/matrix_diag_mul_stat~-help"));
+}
diff --git a/src/matrix_mul_line8~.c b/src/matrix_mul_line8~.c
new file mode 100644
index 0000000..5f15bb4
--- /dev/null
+++ b/src/matrix_mul_line8~.c
@@ -0,0 +1,657 @@
+/* For information on usage and redistribution, and for a DISCLAIMER OF ALL
+* WARRANTIES, see the file, "LICENSE.txt," in this distribution.
+
+iem_matrix written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2006 */
+
+#include "m_pd.h"
+#include "iemlib.h"
+
+/* ---------- matrix_mul_line8~ - signal matrix multiplication object with message matrix-coeff. ----------- */
+
+typedef struct matrix_mul_line8_tilde
+{
+ t_object x_obj;
+ t_float *x_matcur;
+ t_float *x_matend;
+ t_float *x_inc8;
+ t_float *x_biginc;
+ t_float **x_io;
+ t_float *x_outsumbuf;
+ int x_outsumbufsize;
+ int x_n_in; /* columns */
+ int x_n_out; /* rows */
+ t_float x_msi;
+ int x_retarget;
+ t_float x_time_ms;
+ int x_remaining_ticks;
+ t_float x_ms2tick;
+ t_float x_8overn;
+} t_matrix_mul_line8_tilde;
+
+t_class *matrix_mul_line8_tilde_class;
+
+static void matrix_mul_line8_tilde_time(t_matrix_mul_line8_tilde *x, t_floatarg time_ms)
+{
+ if(time_ms <= 0.0f)
+ time_ms = 0.0f;
+ x->x_time_ms = time_ms;
+}
+
+static void matrix_mul_line8_tilde_matrix(t_matrix_mul_line8_tilde *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int col, row, i;
+ t_float *matcur = x->x_matcur;
+ t_float *matend = x->x_matend;
+
+ if(argc<2)
+ {
+ post("matrix_mul_line8~ : bad matrix: <int> out_rows <int> in_cols !");
+ return;
+ }
+
+ row = atom_getint(argv);
+ argv++;
+ col = atom_getint(argv);
+ argv++;
+ argc-=2;
+
+ if((col!=x->x_n_in)||(row!=x->x_n_out))
+ {
+ post("matrix_mul_line8~ : matrix dimensions do not match !!");
+ return;
+ }
+ if(argc<row*col)
+ {
+ post("matrix_mul_line8~ : reduced matrices not yet supported");
+ return;
+ }
+
+ col *= row;
+ if(x->x_time_ms <= 0.0f)
+ {
+ for(i=0; i<col; i++)
+ {
+ *matend++ = *matcur++ = atom_getfloat(argv);
+ argv++;
+ }
+ x->x_remaining_ticks = x->x_retarget = 0;
+ }
+ else
+ {
+ for(i=0; i<col; i++)
+ {
+ *matend++ = atom_getfloat(argv);
+ argv++;
+ }
+ x->x_retarget = 1;
+ }
+}
+
+static void matrix_mul_line8_tilde_element(t_matrix_mul_line8_tilde *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int col, row, n_in_cols=x->x_n_in;
+ t_float element;
+ t_float *matcur = x->x_matcur;
+ t_float *matend = x->x_matend;
+
+ if(argc != 3)
+ {
+ post("matrix_mul_line8~ : bad element: 3 floats: <int> out_row <int> in_col <float> element !");
+ return;
+ }
+
+ row = atom_getint(argv) - 1;
+ col = atom_getint(argv+1) - 1;
+ element = atom_getfloat(argv+2);
+
+ if((row >= x->x_n_out) || (row < 0))
+ {
+ post("matrix_mul_line8~ : row dimensions do not match !!");
+ return;
+ }
+ if((col >= n_in_cols) || (col < 0))
+ {
+ post("matrix_mul_line8~ : col dimensions do not match !!");
+ return;
+ }
+
+ matend += row * n_in_cols + col;
+ matcur += row * n_in_cols + col;
+
+ if(x->x_time_ms <= 0.0f)
+ {
+ *matend = *matcur = element;
+ x->x_remaining_ticks = x->x_retarget = 0;
+ }
+ else
+ {
+ *matend = element;
+ x->x_retarget = 1;
+ }
+}
+
+static void matrix_mul_line8_tilde_row(t_matrix_mul_line8_tilde *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int col, nth_row, i;
+ t_float *matcur = x->x_matcur;
+ t_float *matend = x->x_matend;
+
+ if(argc<1)
+ {
+ post("matrix_mul_line8~ : bad row: <int> in_row !");
+ return;
+ }
+
+ nth_row = atom_getint(argv) - 1;
+ argv++;
+ argc--;
+
+ if((nth_row >= x->x_n_out) || (nth_row < 0))
+ {
+ post("matrix_mul_line8~ : row dimensions do not match !!");
+ return;
+ }
+ col = x->x_n_in;
+ if(argc < col)
+ {
+ post("matrix_mul_line8~ : col dimensions do not match !!");
+ return;
+ }
+
+ matend += nth_row * col;
+ matcur += nth_row * col;
+ if(x->x_time_ms <= 0.0f)
+ {
+ for(i=0; i<col; i++)
+ {
+ *matend++ = *matcur++ = atom_getfloat(argv);
+ argv++;
+ }
+ x->x_remaining_ticks = x->x_retarget = 0;
+ }
+ else
+ {
+ for(i=0; i<col; i++)
+ {
+ *matend++ = atom_getfloat(argv);
+ argv++;
+ }
+ x->x_retarget = 1;
+ }
+}
+
+static void matrix_mul_line8_tilde_col(t_matrix_mul_line8_tilde *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int row, col, nth_col, i;
+ t_float *matcur = x->x_matcur;
+ t_float *matend = x->x_matend;
+
+ if(argc<1)
+ {
+ post("matrix_mul_line8~ : bad col: <int> in_cols !");
+ return;
+ }
+
+ nth_col = atom_getint(argv) - 1;
+ argv++;
+ argc--;
+
+ col = x->x_n_in;
+ if((nth_col < 0)||(nth_col >= col))
+ {
+ post("matrix_mul_line8~ : col dimensions do not match !!");
+ return;
+ }
+ row = x->x_n_out;
+ if(argc < row)
+ {
+ post("matrix_mul_line8~ : row dimensions do not match !!");
+ return;
+ }
+
+ matend += nth_col;
+ matcur += nth_col;
+ if(x->x_time_ms <= 0.0f)
+ {
+ for(i=0; i<row; i++)
+ {
+ *matend = *matcur = atom_getfloat(argv);
+ argv++;
+ matend += col;
+ matcur += col;
+ }
+ x->x_remaining_ticks = x->x_retarget = 0;
+ }
+ else
+ {
+ for(i=0; i<row; i++)
+ {
+ *matend = atom_getfloat(argv);
+ argv++;
+ matend += col;
+ matcur += col;
+ }
+ x->x_retarget = 1;
+ }
+}
+
+static void matrix_mul_line8_tilde_stop(t_matrix_mul_line8_tilde *x)
+{
+ int i = x->x_n_out*x->x_n_in;
+ t_float *matend=x->x_matend;
+ t_float *matcur=x->x_matcur;
+
+ while(i--)
+ {
+ *matend++ = *matcur++;
+ }
+ x->x_remaining_ticks = x->x_retarget = 0;
+}
+
+/* the dsp thing */
+
+static t_int *matrix_mul_line8_tilde_perform_zero(t_int *w)
+{
+ t_matrix_mul_line8_tilde *x = (t_matrix_mul_line8_tilde *)(w[1]);
+ int n = (int)(w[2]);
+ t_float **io = x->x_io;
+ int n_in = x->x_n_in; /* columns */
+ int n_out = x->x_n_out; /* rows */
+ t_float *out;
+ int r, i;
+
+ for(r=0; r<n_out; r++)/* output-vector-row */
+ {
+ out = io[n_in+r];
+ for(i=0; i<n; i++)
+ *out++ = 0.0f;
+ }
+ return (w+3);
+}
+
+static t_int *matrix_mul_line8_tilde_perf8(t_int *w)
+{
+ t_matrix_mul_line8_tilde *x = (t_matrix_mul_line8_tilde *)(w[1]);
+ int n = (int)(w[2]);
+ t_float **io = x->x_io;
+ t_float *outsum, *houtsum;
+ t_float *matcur, *matend;
+ t_float *inc8 ,*biginc, inc;
+ int n_in = x->x_n_in; /* columns */
+ int n_out = x->x_n_out; /* rows */
+ t_float *in, *out, mul, bigmul;
+ int r, c, i;
+
+ if(x->x_retarget)
+ {
+ int nticks = (int)(x->x_time_ms * x->x_ms2tick);
+
+ if(!nticks)
+ nticks = 1;
+ x->x_remaining_ticks = nticks;
+ inc8 = x->x_inc8;
+ biginc = x->x_biginc;
+ matcur = x->x_matcur;
+ matend = x->x_matend;
+ mul = x->x_8overn / (t_float)nticks;
+ bigmul = 1.0f / (t_float)nticks;
+ i = n_out*n_in;
+ while(i--)
+ {
+ inc = *matend++ - *matcur++;
+ *inc8++ = inc * mul;
+ *biginc++ = inc * bigmul;
+ }
+ x->x_retarget = 0;
+ //post("time = %f ms, ticks = %d, inc = %f", x->x_time_ms, nticks, *inc);
+ }
+
+ if(x->x_remaining_ticks)
+ {
+ inc8 = x->x_inc8;
+ biginc = x->x_biginc;
+ matcur = x->x_matcur;
+ /* 1. output-vector-row */
+ in = io[0];
+ houtsum = x->x_outsumbuf;
+ outsum = houtsum;
+ inc = *inc8++;
+ mul = *matcur;
+ for(i=n; i; i -= 8, outsum += 8, in += 8)
+ {
+ outsum[0] = in[0] * mul;
+ outsum[1] = in[1] * mul;
+ outsum[2] = in[2] * mul;
+ outsum[3] = in[3] * mul;
+ outsum[4] = in[4] * mul;
+ outsum[5] = in[5] * mul;
+ outsum[6] = in[6] * mul;
+ outsum[7] = in[7] * mul;
+ mul += inc;
+ }
+ *matcur++ += *biginc++;
+ for(c=1; c<n_in; c++)/* c+1. element of 1. row */
+ {
+ in = io[c];
+ outsum = houtsum;
+ inc = *inc8++;
+ mul = *matcur;
+ for(i=n; i; i -= 8, outsum += 8, in += 8)
+ {
+ outsum[0] += in[0] * mul;
+ outsum[1] += in[1] * mul;
+ outsum[2] += in[2] * mul;
+ outsum[3] += in[3] * mul;
+ outsum[4] += in[4] * mul;
+ outsum[5] += in[5] * mul;
+ outsum[6] += in[6] * mul;
+ outsum[7] += in[7] * mul;
+ mul += inc;
+ }
+ *matcur++ += *biginc++;
+ }
+ for(r=1; r<n_out; r++)/* 2. .. n_out. output-vector-row */
+ {
+ in = io[0];
+ houtsum += n;
+ outsum = houtsum;
+ inc = *inc8++;
+ mul = *matcur;
+ for(i=n; i; i -= 8, outsum += 8, in += 8)
+ {
+ outsum[0] = in[0] * mul;
+ outsum[1] = in[1] * mul;
+ outsum[2] = in[2] * mul;
+ outsum[3] = in[3] * mul;
+ outsum[4] = in[4] * mul;
+ outsum[5] = in[5] * mul;
+ outsum[6] = in[6] * mul;
+ outsum[7] = in[7] * mul;
+ mul += inc;
+ }
+ *matcur++ += *biginc++;
+ for(c=1; c<n_in; c++)/* c+1. element of r+1. row */
+ {
+ in = io[c];
+ outsum = houtsum;
+ inc = *inc8++;
+ mul = *matcur;
+ for(i=n; i; i -= 8, outsum += 8, in += 8)
+ {
+ outsum[0] += in[0] * mul;
+ outsum[1] += in[1] * mul;
+ outsum[2] += in[2] * mul;
+ outsum[3] += in[3] * mul;
+ outsum[4] += in[4] * mul;
+ outsum[5] += in[5] * mul;
+ outsum[6] += in[6] * mul;
+ outsum[7] += in[7] * mul;
+ mul += inc;
+ }
+ *matcur++ += *biginc++;
+ }
+ }
+
+ if(!--x->x_remaining_ticks)
+ {
+ matcur = x->x_matcur;
+ matend = x->x_matend;
+ i = n_in * n_out;
+ while(i--)
+ *matcur++ = *matend++;
+ }
+ }
+ else
+ {
+ matend = x->x_matend;
+ /* 1. output-vector-row */
+ in = io[0];
+ houtsum = x->x_outsumbuf;
+ outsum = houtsum;
+ mul = *matend++;
+ if(mul == 0.0f)
+ {
+ for(i=n; i; i -= 8, outsum += 8, in += 8)
+ {
+ outsum[0] = 0.0f;
+ outsum[1] = 0.0f;
+ outsum[2] = 0.0f;
+ outsum[3] = 0.0f;
+ outsum[4] = 0.0f;
+ outsum[5] = 0.0f;
+ outsum[6] = 0.0f;
+ outsum[7] = 0.0f;
+ }
+ }
+ else
+ {
+ for(i=n; i; i -= 8, outsum += 8, in += 8)
+ {
+ outsum[0] = in[0] * mul;
+ outsum[1] = in[1] * mul;
+ outsum[2] = in[2] * mul;
+ outsum[3] = in[3] * mul;
+ outsum[4] = in[4] * mul;
+ outsum[5] = in[5] * mul;
+ outsum[6] = in[6] * mul;
+ outsum[7] = in[7] * mul;
+ }
+ }
+ for(c=1; c<n_in; c++)/* c+1. element of 1. row */
+ {
+ in = io[c];
+ outsum = houtsum;
+ mul = *matend++;
+ if(mul != 0.0f)
+ {
+ for(i=n; i; i -= 8, outsum += 8, in += 8)
+ {
+ outsum[0] += in[0] * mul;
+ outsum[1] += in[1] * mul;
+ outsum[2] += in[2] * mul;
+ outsum[3] += in[3] * mul;
+ outsum[4] += in[4] * mul;
+ outsum[5] += in[5] * mul;
+ outsum[6] += in[6] * mul;
+ outsum[7] += in[7] * mul;
+ }
+ }
+ }
+ for(r=1; r<n_out; r++)/* 2. .. n_out. output-vector-row */
+ {
+ in = io[0];
+ houtsum += n;
+ outsum = houtsum;
+ mul = *matend++;
+ if(mul == 0.0f)
+ {
+ for(i=n; i; i -= 8, outsum += 8, in += 8)
+ {
+ outsum[0] = 0.0f;
+ outsum[1] = 0.0f;
+ outsum[2] = 0.0f;
+ outsum[3] = 0.0f;
+ outsum[4] = 0.0f;
+ outsum[5] = 0.0f;
+ outsum[6] = 0.0f;
+ outsum[7] = 0.0f;
+ }
+ }
+ else
+ {
+ for(i=n; i; i -= 8, outsum += 8, in += 8)
+ {
+ outsum[0] = in[0] * mul;
+ outsum[1] = in[1] * mul;
+ outsum[2] = in[2] * mul;
+ outsum[3] = in[3] * mul;
+ outsum[4] = in[4] * mul;
+ outsum[5] = in[5] * mul;
+ outsum[6] = in[6] * mul;
+ outsum[7] = in[7] * mul;
+ }
+ }
+ for(c=1; c<n_in; c++)/* c+1. element of r+1. row */
+ {
+ in = io[c];
+ outsum = houtsum;
+ mul = *matend++;
+ if(mul != 0.0f)
+ {
+ for(i=n; i; i -= 8, outsum += 8, in += 8)
+ {
+ outsum[0] += in[0] * mul;
+ outsum[1] += in[1] * mul;
+ outsum[2] += in[2] * mul;
+ outsum[3] += in[3] * mul;
+ outsum[4] += in[4] * mul;
+ outsum[5] += in[5] * mul;
+ outsum[6] += in[6] * mul;
+ outsum[7] += in[7] * mul;
+ }
+ }
+ }
+ }
+ }
+ outsum = x->x_outsumbuf;
+ for(r=0; r<n_out; r++)/* output-vector-row */
+ {
+ out = io[n_in+r];
+ for (i=n; i; i -= 8, out += 8, outsum += 8)
+ {
+ out[0] = outsum[0];
+ out[1] = outsum[1];
+ out[2] = outsum[2];
+ out[3] = outsum[3];
+ out[4] = outsum[4];
+ out[5] = outsum[5];
+ out[6] = outsum[6];
+ out[7] = outsum[7];
+ }
+ }
+ return (w+3);
+}
+
+static void matrix_mul_line8_tilde_dsp(t_matrix_mul_line8_tilde *x, t_signal **sp)
+{
+ int i, n=sp[0]->s_n*x->x_n_out;
+
+ if(!x->x_outsumbuf)
+ {
+ x->x_outsumbufsize = n;
+ x->x_outsumbuf = (t_float *)getbytes(x->x_outsumbufsize * sizeof(t_float));
+ }
+ else if(x->x_outsumbufsize != n)
+ {
+ x->x_outsumbuf = (t_float *)resizebytes(x->x_outsumbuf, x->x_outsumbufsize*sizeof(t_float), n*sizeof(t_float));
+ x->x_outsumbufsize = n;
+ }
+
+ n = x->x_n_in + x->x_n_out;
+ for(i=0; i<n; i++)
+ x->x_io[i] = sp[i]->s_vec;
+
+ n = sp[0]->s_n;
+ x->x_ms2tick = 0.001f * (t_float)(sp[0]->s_sr) / (t_float)n;
+ x->x_8overn = 8.0f / (t_float)n;
+
+ if(n&7)
+ {
+ dsp_add(matrix_mul_line8_tilde_perform_zero, 2, x, n);
+ post("ERROR!!! matrix_mul_line8~ : blocksize is %d and not a multiple of 8", n);
+ }
+ else
+ dsp_add(matrix_mul_line8_tilde_perf8, 2, x, n);
+}
+
+
+/* setup/setdown things */
+
+static void matrix_mul_line8_tilde_free(t_matrix_mul_line8_tilde *x)
+{
+ freebytes(x->x_matcur, x->x_n_in * x->x_n_out * sizeof(t_float));
+ freebytes(x->x_matend, x->x_n_in * x->x_n_out * sizeof(t_float));
+ freebytes(x->x_inc8, x->x_n_in * x->x_n_out * sizeof(t_float));
+ freebytes(x->x_biginc, x->x_n_in * x->x_n_out * sizeof(t_float));
+ freebytes(x->x_io, (x->x_n_in + x->x_n_out) * sizeof(t_float *));
+ if(x->x_outsumbuf)
+ freebytes(x->x_outsumbuf, x->x_outsumbufsize * sizeof(t_float));
+}
+
+static void *matrix_mul_line8_tilde_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_matrix_mul_line8_tilde *x = (t_matrix_mul_line8_tilde *)pd_new(matrix_mul_line8_tilde_class);
+ int i, n;
+
+ switch(argc)
+ {
+ case 0:
+ x->x_n_in = x->x_n_out = 1;
+ x->x_time_ms = 50.0f;
+ break;
+ case 1:
+ x->x_n_in = x->x_n_out = (int)atom_getint(argv);
+ x->x_time_ms = 50.0f;
+ break;
+ case 2:
+ x->x_n_in = (int)atom_getint(argv);
+ x->x_n_out = (int)atom_getint(argv+1);
+ x->x_time_ms = 50.0f;
+ break;
+ default:
+ x->x_n_in = (int)atom_getint(argv);
+ x->x_n_out = (int)atom_getint(argv+1);
+ x->x_time_ms = atom_getfloat(argv+2);
+ break;
+ }
+
+ if(x->x_time_ms < 0.0f)
+ x->x_time_ms = 50.0f;
+ if(x->x_n_in < 1)
+ x->x_n_in = 1;
+ if(x->x_n_out < 1)
+ x->x_n_out = 1;
+ i = x->x_n_in - 1;
+ while(i--)
+ inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal);
+ i = x->x_n_out;
+ while(i--)
+ outlet_new(&x->x_obj, &s_signal);
+ x->x_msi = 0;
+ x->x_outsumbuf = (t_float *)0;
+ x->x_outsumbufsize = 0;
+ x->x_matcur = (t_float *)getbytes(x->x_n_in * x->x_n_out * sizeof(t_float));
+ x->x_matend = (t_float *)getbytes(x->x_n_in * x->x_n_out * sizeof(t_float));
+ x->x_inc8 = (t_float *)getbytes(x->x_n_in * x->x_n_out * sizeof(t_float));
+ x->x_biginc = (t_float *)getbytes(x->x_n_in * x->x_n_out * sizeof(t_float));
+ x->x_io = (t_float **)getbytes((x->x_n_in + x->x_n_out) * sizeof(t_float *));
+ x->x_ms2tick = 0.001f * 44100.0f / 64.0f;
+ x->x_8overn = 8.0f / 64.0f;
+ x->x_remaining_ticks = 0;
+ x->x_retarget = 0;
+
+ n = x->x_n_in * x->x_n_out;
+ for(i=0; i<n; i++)
+ {
+ x->x_matcur[i] = 0.0f;
+ x->x_matend[i] = 0.0f;
+ x->x_inc8[i] = 0.0f;
+ x->x_biginc[i] = 0.0f;
+ }
+ return (x);
+}
+
+void matrix_mul_line8_tilde_setup(void)
+{
+ matrix_mul_line8_tilde_class = class_new(gensym("matrix_mul_line8~"), (t_newmethod)matrix_mul_line8_tilde_new, (t_method)matrix_mul_line8_tilde_free,
+ sizeof(t_matrix_mul_line8_tilde), 0, A_GIMME, 0);
+ CLASS_MAINSIGNALIN(matrix_mul_line8_tilde_class, t_matrix_mul_line8_tilde, x_msi);
+ class_addmethod(matrix_mul_line8_tilde_class, (t_method)matrix_mul_line8_tilde_dsp, gensym("dsp"), 0);
+ class_addmethod(matrix_mul_line8_tilde_class, (t_method)matrix_mul_line8_tilde_matrix, gensym("matrix"), A_GIMME, 0);
+ class_addmethod(matrix_mul_line8_tilde_class, (t_method)matrix_mul_line8_tilde_element, gensym("element"), A_GIMME, 0);
+ class_addmethod(matrix_mul_line8_tilde_class, (t_method)matrix_mul_line8_tilde_row, gensym("row"), A_GIMME, 0);
+ class_addmethod(matrix_mul_line8_tilde_class, (t_method)matrix_mul_line8_tilde_col, gensym("col"), A_GIMME, 0);
+ class_addmethod(matrix_mul_line8_tilde_class, (t_method)matrix_mul_line8_tilde_stop, gensym("stop"), 0);
+ class_addmethod(matrix_mul_line8_tilde_class, (t_method)matrix_mul_line8_tilde_time, gensym("time"), A_FLOAT, 0);
+ class_sethelpsymbol(matrix_mul_line8_tilde_class, gensym("iemhelp2/matrix_mul_line8~-help"));
+}
diff --git a/src/matrix_mul_line~.c b/src/matrix_mul_line~.c
new file mode 100644
index 0000000..bc61cec
--- /dev/null
+++ b/src/matrix_mul_line~.c
@@ -0,0 +1,686 @@
+/* For information on usage and redistribution, and for a DISCLAIMER OF ALL
+* WARRANTIES, see the file, "LICENSE.txt," in this distribution.
+
+iem_matrix written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2006 */
+
+#include "m_pd.h"
+#include "iemlib.h"
+
+
+/* ---------- matrix_mul_line~ - signal matrix multiplication object with message matrix-coeff. ----------- */
+
+typedef struct matrix_mul_line_tilde
+{
+ t_object x_obj;
+ t_float *x_matcur;
+ t_float *x_matend;
+ t_float *x_inc;
+ t_float *x_biginc;
+ t_float **x_io;
+ t_float *x_outsumbuf;
+ int x_outsumbufsize;
+ int x_n_in; /* columns */
+ int x_n_out; /* rows */
+ t_float x_msi;
+ int x_retarget;
+ t_float x_time_ms;
+ int x_remaining_ticks;
+ t_float x_ms2tick;
+ t_float x_1overn;
+} t_matrix_mul_line_tilde;
+
+t_class *matrix_mul_line_tilde_class;
+
+static void matrix_mul_line_tilde_time(t_matrix_mul_line_tilde *x, t_floatarg time_ms)
+{
+ if(time_ms <= 0.0f)
+ time_ms = 0.0f;
+ x->x_time_ms = time_ms;
+}
+
+static void matrix_mul_line_tilde_matrix(t_matrix_mul_line_tilde *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int col, row, i;
+ t_float *matcur = x->x_matcur;
+ t_float *matend = x->x_matend;
+
+ if(argc<2)
+ {
+ post("matrix_mul_line~ : bad matrix: <int> out_rows <int> in_cols !");
+ return;
+ }
+
+ row = atom_getint(argv);
+ argv++;
+ col = atom_getint(argv);
+ argv++;
+ argc-=2;
+
+ if((col!=x->x_n_in)||(row!=x->x_n_out))
+ {
+ post("matrix_mul_line~ : matrix dimensions do not match !!");
+ return;
+ }
+ if(argc<row*col)
+ {
+ post("matrix_mul_line~ : reduced matrices not yet supported");
+ return;
+ }
+
+ col *= row;
+ if(x->x_time_ms <= 0.0f)
+ {
+ for(i=0; i<col; i++)
+ {
+ *matend++ = *matcur++ = atom_getfloat(argv);
+ argv++;
+ }
+ x->x_remaining_ticks = x->x_retarget = 0;
+ }
+ else
+ {
+ for(i=0; i<col; i++)
+ {
+ *matend++ = atom_getfloat(argv);
+ argv++;
+ }
+ x->x_retarget = 1;
+ }
+}
+
+static void matrix_mul_line_tilde_element(t_matrix_mul_line_tilde *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int col, row, n_in_cols=x->x_n_in;
+ t_float element;
+ t_float *matcur = x->x_matcur;
+ t_float *matend = x->x_matend;
+
+ if(argc != 3)
+ {
+ post("matrix_mul_line~ : bad element: 3 floats: <int> out_row <int> in_col <float> element !");
+ return;
+ }
+
+ row = atom_getint(argv) - 1;
+ col = atom_getint(argv+1) - 1;
+ element = atom_getfloat(argv+2);
+
+ if((row >= x->x_n_out) || (row < 0))
+ {
+ post("matrix_mul_line~ : row dimensions do not match !!");
+ return;
+ }
+ if((col >= n_in_cols) || (col < 0))
+ {
+ post("matrix_mul_line~ : col dimensions do not match !!");
+ return;
+ }
+
+ matend += row * n_in_cols + col;
+ matcur += row * n_in_cols + col;
+
+ if(x->x_time_ms <= 0.0f)
+ {
+ *matend = *matcur = element;
+ x->x_remaining_ticks = x->x_retarget = 0;
+ }
+ else
+ {
+ *matend = element;
+ x->x_retarget = 1;
+ }
+}
+
+static void matrix_mul_line_tilde_row(t_matrix_mul_line_tilde *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int col, nth_row, i;
+ t_float *matcur = x->x_matcur;
+ t_float *matend = x->x_matend;
+
+ if(argc<1)
+ {
+ post("matrix_mul_line~ : bad row: <int> in_row !");
+ return;
+ }
+
+ nth_row = atom_getint(argv) - 1;
+ argv++;
+ argc--;
+
+ if((nth_row >= x->x_n_out) || (nth_row < 0))
+ {
+ post("matrix_mul_line~ : row dimensions do not match !!");
+ return;
+ }
+ col = x->x_n_in;
+ if(argc < col)
+ {
+ post("matrix_mul_line~ : col dimensions do not match !!");
+ return;
+ }
+
+ matend += nth_row * col;
+ matcur += nth_row * col;
+ if(x->x_time_ms <= 0.0f)
+ {
+ for(i=0; i<col; i++)
+ {
+ *matend++ = *matcur++ = atom_getfloat(argv);
+ argv++;
+ }
+ x->x_remaining_ticks = x->x_retarget = 0;
+ }
+ else
+ {
+ for(i=0; i<col; i++)
+ {
+ *matend++ = atom_getfloat(argv);
+ argv++;
+ }
+ x->x_retarget = 1;
+ }
+}
+
+static void matrix_mul_line_tilde_col(t_matrix_mul_line_tilde *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int row, col, nth_col, i;
+ t_float *matcur = x->x_matcur;
+ t_float *matend = x->x_matend;
+
+ if(argc<1)
+ {
+ post("matrix_mul_line~ : bad col: <int> in_cols !");
+ return;
+ }
+
+ nth_col = atom_getint(argv) - 1;
+ argv++;
+ argc--;
+
+ col = x->x_n_in;
+ if((nth_col < 0)||(nth_col >= col))
+ {
+ post("matrix_mul_line~ : col dimensions do not match !!");
+ return;
+ }
+ row = x->x_n_out;
+ if(argc < row)
+ {
+ post("matrix_mul_line~ : row dimensions do not match !!");
+ return;
+ }
+
+ matend += nth_col;
+ matcur += nth_col;
+ if(x->x_time_ms <= 0.0f)
+ {
+ for(i=0; i<row; i++)
+ {
+ *matend = *matcur = atom_getfloat(argv);
+ argv++;
+ matend += col;
+ matcur += col;
+ }
+ x->x_remaining_ticks = x->x_retarget = 0;
+ }
+ else
+ {
+ for(i=0; i<row; i++)
+ {
+ *matend = atom_getfloat(argv);
+ argv++;
+ matend += col;
+ matcur += col;
+ }
+ x->x_retarget = 1;
+ }
+}
+
+static void matrix_mul_line_tilde_stop(t_matrix_mul_line_tilde *x)
+{
+ int i = x->x_n_out*x->x_n_in;
+ t_float *matend=x->x_matend;
+ t_float *matcur=x->x_matcur;
+
+ while(i--)
+ {
+ *matend++ = *matcur++;
+ }
+ x->x_remaining_ticks = x->x_retarget = 0;
+}
+
+/* the dsp thing */
+
+static t_int *matrix_mul_line_tilde_perform_zero(t_int *w)
+{
+ t_matrix_mul_line_tilde *x = (t_matrix_mul_line_tilde *)(w[1]);
+ int n = (int)(w[2]);
+ t_float **io = x->x_io;
+ int n_in = x->x_n_in; /* columns */
+ int n_out = x->x_n_out; /* rows */
+ t_float *out;
+ int r, i;
+
+ for(r=0; r<n_out; r++)/* output-vector-row */
+ {
+ out = io[n_in+r];
+ for(i=0; i<n; i++)
+ *out++ = 0.0f;
+ }
+ return (w+3);
+}
+
+static t_int *matrix_mul_line_tilde_perf8(t_int *w)
+{
+ t_matrix_mul_line_tilde *x = (t_matrix_mul_line_tilde *)(w[1]);
+ int n = (int)(w[2]);
+ t_float **io = x->x_io;
+ t_float *outsum, *houtsum;
+ t_float *matcur, *matend;
+ t_float *inc1 ,*biginc, inc;
+ int n_in = x->x_n_in; /* columns */
+ int n_out = x->x_n_out; /* rows */
+ t_float *in, *out, mul, bigmul;
+ int r, c, i;
+
+ if(x->x_retarget)
+ {
+ int nticks = (int)(x->x_time_ms * x->x_ms2tick);
+
+ if(!nticks)
+ nticks = 1;
+ x->x_remaining_ticks = nticks;
+ inc1 = x->x_inc;
+ biginc = x->x_biginc;
+ matcur = x->x_matcur;
+ matend = x->x_matend;
+ mul = x->x_1overn / (t_float)nticks;
+ bigmul = 1.0f / (t_float)nticks;
+ i = n_out*n_in;
+ while(i--)
+ {
+ inc = *matend++ - *matcur++;
+ *inc1++ = inc * mul;
+ *biginc++ = inc * bigmul;
+ }
+ x->x_retarget = 0;
+ //post("time = %f ms, ticks = %d, inc = %f", x->x_time_ms, nticks, *inc);
+ }
+
+ if(x->x_remaining_ticks)
+ {
+ inc1 = x->x_inc;
+ biginc = x->x_biginc;
+ matcur = x->x_matcur;
+ /* 1. output-vector-row */
+ in = io[0];
+ houtsum = x->x_outsumbuf;
+ outsum = houtsum;
+ inc = *inc1++;
+ mul = *matcur;
+ for(i=n; i; i -= 8, outsum += 8, in += 8)
+ {
+ outsum[0] = in[0] * mul;
+ mul += inc;
+ outsum[1] = in[1] * mul;
+ mul += inc;
+ outsum[2] = in[2] * mul;
+ mul += inc;
+ outsum[3] = in[3] * mul;
+ mul += inc;
+ outsum[4] = in[4] * mul;
+ mul += inc;
+ outsum[5] = in[5] * mul;
+ mul += inc;
+ outsum[6] = in[6] * mul;
+ mul += inc;
+ outsum[7] = in[7] * mul;
+ mul += inc;
+ }
+ *matcur++ += *biginc++;
+ for(c=1; c<n_in; c++)/* c+1. element of 1. row */
+ {
+ in = io[c];
+ outsum = houtsum;
+ inc = *inc1++;
+ mul = *matcur;
+ for(i=n; i; i -= 8, outsum += 8, in += 8)
+ {
+ outsum[0] += in[0] * mul;
+ mul += inc;
+ outsum[1] += in[1] * mul;
+ mul += inc;
+ outsum[2] += in[2] * mul;
+ mul += inc;
+ outsum[3] += in[3] * mul;
+ mul += inc;
+ outsum[4] += in[4] * mul;
+ mul += inc;
+ outsum[5] += in[5] * mul;
+ mul += inc;
+ outsum[6] += in[6] * mul;
+ mul += inc;
+ outsum[7] += in[7] * mul;
+ mul += inc;
+ }
+ *matcur++ += *biginc++;
+ }
+ for(r=1; r<n_out; r++)/* 2. .. n_out. output-vector-row */
+ {
+ in = io[0];
+ houtsum += n;
+ outsum = houtsum;
+ inc = *inc1++;
+ mul = *matcur;
+ for(i=n; i; i -= 8, outsum += 8, in += 8)
+ {
+ outsum[0] = in[0] * mul;
+ mul += inc;
+ outsum[1] = in[1] * mul;
+ mul += inc;
+ outsum[2] = in[2] * mul;
+ mul += inc;
+ outsum[3] = in[3] * mul;
+ mul += inc;
+ outsum[4] = in[4] * mul;
+ mul += inc;
+ outsum[5] = in[5] * mul;
+ mul += inc;
+ outsum[6] = in[6] * mul;
+ mul += inc;
+ outsum[7] = in[7] * mul;
+ mul += inc;
+ }
+ *matcur++ += *biginc++;
+ for(c=1; c<n_in; c++)/* c+1. element of r+1. row */
+ {
+ in = io[c];
+ outsum = houtsum;
+ inc = *inc1++;
+ mul = *matcur;
+ for(i=n; i; i -= 8, outsum += 8, in += 8)
+ {
+ outsum[0] += in[0] * mul;
+ mul += inc;
+ outsum[1] += in[1] * mul;
+ mul += inc;
+ outsum[2] += in[2] * mul;
+ mul += inc;
+ outsum[3] += in[3] * mul;
+ mul += inc;
+ outsum[4] += in[4] * mul;
+ mul += inc;
+ outsum[5] += in[5] * mul;
+ mul += inc;
+ outsum[6] += in[6] * mul;
+ mul += inc;
+ outsum[7] += in[7] * mul;
+ mul += inc;
+ }
+ *matcur++ += *biginc++;
+ }
+ }
+
+ if(!--x->x_remaining_ticks)
+ {
+ matcur = x->x_matcur;
+ matend = x->x_matend;
+ i = n_in * n_out;
+ while(i--)
+ *matcur++ = *matend++;
+ }
+ }
+ else
+ {
+ matend = x->x_matend;
+ /* 1. output-vector-row */
+ in = io[0];
+ houtsum = x->x_outsumbuf;
+ outsum = houtsum;
+ mul = *matend++;
+ if(mul == 0.0f)
+ {
+ for(i=n; i; i -= 8, outsum += 8, in += 8)
+ {
+ outsum[0] = 0.0f;
+ outsum[1] = 0.0f;
+ outsum[2] = 0.0f;
+ outsum[3] = 0.0f;
+ outsum[4] = 0.0f;
+ outsum[5] = 0.0f;
+ outsum[6] = 0.0f;
+ outsum[7] = 0.0f;
+ }
+ }
+ else
+ {
+ for(i=n; i; i -= 8, outsum += 8, in += 8)
+ {
+ outsum[0] = in[0] * mul;
+ outsum[1] = in[1] * mul;
+ outsum[2] = in[2] * mul;
+ outsum[3] = in[3] * mul;
+ outsum[4] = in[4] * mul;
+ outsum[5] = in[5] * mul;
+ outsum[6] = in[6] * mul;
+ outsum[7] = in[7] * mul;
+ }
+ }
+ for(c=1; c<n_in; c++)/* c+1. element of 1. row */
+ {
+ in = io[c];
+ outsum = houtsum;
+ mul = *matend++;
+ if(mul != 0.0f)
+ {
+ for(i=n; i; i -= 8, outsum += 8, in += 8)
+ {
+ outsum[0] += in[0] * mul;
+ outsum[1] += in[1] * mul;
+ outsum[2] += in[2] * mul;
+ outsum[3] += in[3] * mul;
+ outsum[4] += in[4] * mul;
+ outsum[5] += in[5] * mul;
+ outsum[6] += in[6] * mul;
+ outsum[7] += in[7] * mul;
+ }
+ }
+ }
+ for(r=1; r<n_out; r++)/* 2. .. n_out. output-vector-row */
+ {
+ in = io[0];
+ houtsum += n;
+ outsum = houtsum;
+ mul = *matend++;
+ if(mul == 0.0f)
+ {
+ for(i=n; i; i -= 8, outsum += 8, in += 8)
+ {
+ outsum[0] = 0.0f;
+ outsum[1] = 0.0f;
+ outsum[2] = 0.0f;
+ outsum[3] = 0.0f;
+ outsum[4] = 0.0f;
+ outsum[5] = 0.0f;
+ outsum[6] = 0.0f;
+ outsum[7] = 0.0f;
+ }
+ }
+ else
+ {
+ for(i=n; i; i -= 8, outsum += 8, in += 8)
+ {
+ outsum[0] = in[0] * mul;
+ outsum[1] = in[1] * mul;
+ outsum[2] = in[2] * mul;
+ outsum[3] = in[3] * mul;
+ outsum[4] = in[4] * mul;
+ outsum[5] = in[5] * mul;
+ outsum[6] = in[6] * mul;
+ outsum[7] = in[7] * mul;
+ }
+ }
+ for(c=1; c<n_in; c++)/* c+1. element of r+1. row */
+ {
+ in = io[c];
+ outsum = houtsum;
+ mul = *matend++;
+ if(mul != 0.0f)
+ {
+ for(i=n; i; i -= 8, outsum += 8, in += 8)
+ {
+ outsum[0] += in[0] * mul;
+ outsum[1] += in[1] * mul;
+ outsum[2] += in[2] * mul;
+ outsum[3] += in[3] * mul;
+ outsum[4] += in[4] * mul;
+ outsum[5] += in[5] * mul;
+ outsum[6] += in[6] * mul;
+ outsum[7] += in[7] * mul;
+ }
+ }
+ }
+ }
+ }
+ outsum = x->x_outsumbuf;
+ for(r=0; r<n_out; r++)/* output-vector-row */
+ {
+ out = io[n_in+r];
+ for (i=n; i; i -= 8, out += 8, outsum += 8)
+ {
+ out[0] = outsum[0];
+ out[1] = outsum[1];
+ out[2] = outsum[2];
+ out[3] = outsum[3];
+ out[4] = outsum[4];
+ out[5] = outsum[5];
+ out[6] = outsum[6];
+ out[7] = outsum[7];
+ }
+ }
+ return (w+3);
+}
+
+static void matrix_mul_line_tilde_dsp(t_matrix_mul_line_tilde *x, t_signal **sp)
+{
+ int i, n=sp[0]->s_n*x->x_n_out;
+
+ if(!x->x_outsumbuf)
+ {
+ x->x_outsumbufsize = n;
+ x->x_outsumbuf = (t_float *)getbytes(x->x_outsumbufsize * sizeof(t_float));
+ }
+ else if(x->x_outsumbufsize != n)
+ {
+ x->x_outsumbuf = (t_float *)resizebytes(x->x_outsumbuf, x->x_outsumbufsize*sizeof(t_float), n*sizeof(t_float));
+ x->x_outsumbufsize = n;
+ }
+
+ n = x->x_n_in + x->x_n_out;
+ for(i=0; i<n; i++)
+ x->x_io[i] = sp[i]->s_vec;
+
+ n = sp[0]->s_n;
+ x->x_ms2tick = 0.001f * (t_float)(sp[0]->s_sr) / (t_float)n;
+ x->x_1overn = 1.0f / (t_float)n;
+
+ if(n&7)
+ {
+ dsp_add(matrix_mul_line_tilde_perform_zero, 2, x, n);
+ post("ERROR!!! matrix_mul_line~ : blocksize is %d and not a multiple of 8", n);
+ }
+ else
+ dsp_add(matrix_mul_line_tilde_perf8, 2, x, n);
+}
+
+
+/* setup/setdown things */
+
+static void matrix_mul_line_tilde_free(t_matrix_mul_line_tilde *x)
+{
+ freebytes(x->x_matcur, x->x_n_in * x->x_n_out * sizeof(t_float));
+ freebytes(x->x_matend, x->x_n_in * x->x_n_out * sizeof(t_float));
+ freebytes(x->x_inc, x->x_n_in * x->x_n_out * sizeof(t_float));
+ freebytes(x->x_biginc, x->x_n_in * x->x_n_out * sizeof(t_float));
+ freebytes(x->x_io, (x->x_n_in + x->x_n_out) * sizeof(t_float *));
+ if(x->x_outsumbuf)
+ freebytes(x->x_outsumbuf, x->x_outsumbufsize * sizeof(t_float));
+}
+
+static void *matrix_mul_line_tilde_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_matrix_mul_line_tilde *x = (t_matrix_mul_line_tilde *)pd_new(matrix_mul_line_tilde_class);
+ int i, n;
+
+ switch(argc)
+ {
+ case 0:
+ x->x_n_in = x->x_n_out = 1;
+ x->x_time_ms = 50.0f;
+ break;
+ case 1:
+ x->x_n_in = x->x_n_out = (int)atom_getint(argv);
+ x->x_time_ms = 50.0f;
+ break;
+ case 2:
+ x->x_n_in = (int)atom_getint(argv);
+ x->x_n_out = (int)atom_getint(argv+1);
+ x->x_time_ms = 50.0f;
+ break;
+ default:
+ x->x_n_in = (int)atom_getint(argv);
+ x->x_n_out = (int)atom_getint(argv+1);
+ x->x_time_ms = atom_getfloat(argv+2);
+ break;
+ }
+
+ if(x->x_time_ms < 0.0f)
+ x->x_time_ms = 50.0f;
+ if(x->x_n_in < 1)
+ x->x_n_in = 1;
+ if(x->x_n_out < 1)
+ x->x_n_out = 1;
+ i = x->x_n_in - 1;
+ while(i--)
+ inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal);
+ i = x->x_n_out;
+ while(i--)
+ outlet_new(&x->x_obj, &s_signal);
+ x->x_msi = 0;
+ x->x_outsumbuf = (t_float *)0;
+ x->x_outsumbufsize = 0;
+ x->x_matcur = (t_float *)getbytes(x->x_n_in * x->x_n_out * sizeof(t_float));
+ x->x_matend = (t_float *)getbytes(x->x_n_in * x->x_n_out * sizeof(t_float));
+ x->x_inc = (t_float *)getbytes(x->x_n_in * x->x_n_out * sizeof(t_float));
+ x->x_biginc = (t_float *)getbytes(x->x_n_in * x->x_n_out * sizeof(t_float));
+ x->x_io = (t_float **)getbytes((x->x_n_in + x->x_n_out) * sizeof(t_float *));
+ x->x_ms2tick = 0.001f * 44100.0f / 64.0f;
+ x->x_1overn = 1.0f / 64.0f;
+ x->x_remaining_ticks = 0;
+ x->x_retarget = 0;
+
+ n = x->x_n_in * x->x_n_out;
+ for(i=0; i<n; i++)
+ {
+ x->x_matcur[i] = 0.0f;
+ x->x_matend[i] = 0.0f;
+ x->x_inc[i] = 0.0f;
+ x->x_biginc[i] = 0.0f;
+ }
+ return (x);
+}
+
+void matrix_mul_line_tilde_setup(void)
+{
+ matrix_mul_line_tilde_class = class_new(gensym("matrix_mul_line~"), (t_newmethod)matrix_mul_line_tilde_new, (t_method)matrix_mul_line_tilde_free,
+ sizeof(t_matrix_mul_line_tilde), 0, A_GIMME, 0);
+ CLASS_MAINSIGNALIN(matrix_mul_line_tilde_class, t_matrix_mul_line_tilde, x_msi);
+ class_addmethod(matrix_mul_line_tilde_class, (t_method)matrix_mul_line_tilde_dsp, gensym("dsp"), 0);
+ class_addmethod(matrix_mul_line_tilde_class, (t_method)matrix_mul_line_tilde_matrix, gensym("matrix"), A_GIMME, 0);
+ class_addmethod(matrix_mul_line_tilde_class, (t_method)matrix_mul_line_tilde_element, gensym("element"), A_GIMME, 0);
+ class_addmethod(matrix_mul_line_tilde_class, (t_method)matrix_mul_line_tilde_row, gensym("row"), A_GIMME, 0);
+ class_addmethod(matrix_mul_line_tilde_class, (t_method)matrix_mul_line_tilde_col, gensym("col"), A_GIMME, 0);
+ class_addmethod(matrix_mul_line_tilde_class, (t_method)matrix_mul_line_tilde_stop, gensym("stop"), 0);
+ class_addmethod(matrix_mul_line_tilde_class, (t_method)matrix_mul_line_tilde_time, gensym("time"), A_FLOAT, 0);
+ class_sethelpsymbol(matrix_mul_line_tilde_class, gensym("iemhelp2/matrix_mul_line~-help"));
+}
diff --git a/src/matrix_mul_stat~.c b/src/matrix_mul_stat~.c
new file mode 100644
index 0000000..a2fc04d
--- /dev/null
+++ b/src/matrix_mul_stat~.c
@@ -0,0 +1,462 @@
+/* For information on usage and redistribution, and for a DISCLAIMER OF ALL
+* WARRANTIES, see the file, "LICENSE.txt," in this distribution.
+
+iem_matrix written by Thomas Musil (c) IEM KUG Graz Austria 2002 - 2006 */
+
+#include "m_pd.h"
+#include "iemlib.h"
+
+
+/* ---------- matrix_mul_stat~ - signal matrix multiplication object with message matrix-coeff. ----------- */
+
+typedef struct matrix_mul_stat_tilde
+{
+ t_object x_obj;
+ t_float *x_matbuf;
+ t_float **x_io;
+ t_float *x_outsumbuf;
+ int x_outsumbufsize;
+ int x_n_in; /* columns */
+ int x_n_out; /* rows */
+ t_float x_msi;
+} t_matrix_mul_stat_tilde;
+
+t_class *matrix_mul_stat_tilde_class;
+
+static void matrix_mul_stat_tilde_matrix(t_matrix_mul_stat_tilde *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int col, row, i;
+ t_float *matrix = x->x_matbuf;
+
+ if(argc<2)
+ {
+ post("matrix_mul_stat~ : bad matrix: <int> out_rows <int> in_cols !");
+ return;
+ }
+
+ row = atom_getint(argv);
+ argv++;
+ col = atom_getint(argv);
+ argv++;
+ argc-=2;
+
+ if((col!=x->x_n_in)||(row!=x->x_n_out))
+ {
+ post("matrix_mul_stat~ : matrix dimensions do not match !!");
+ return;
+ }
+ if(argc<row*col)
+ {
+ post("matrix_mul_stat~ : reduced matrices not yet supported");
+ return;
+ }
+
+ col *= row;
+ for(i=0; i<col; i++)
+ {
+ *matrix++ = atom_getfloat(argv);
+ argv++;
+ }
+}
+
+static void matrix_mul_stat_tilde_element(t_matrix_mul_stat_tilde *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int col, row, n_in_cols=x->x_n_in;
+ t_float element;
+ t_float *matrix = x->x_matbuf;
+
+ if(argc != 3)
+ {
+ post("matrix_mul_stat~ : bad element: 3 floats: <int> out_row <int> in_col <float> element !");
+ return;
+ }
+
+ row = atom_getint(argv) - 1;
+ col = atom_getint(argv+1) - 1;
+ element = atom_getfloat(argv+2);
+
+ if((row >= x->x_n_out) || (row < 0))
+ {
+ post("matrix_mul_stat~ : row dimensions do not match !!");
+ return;
+ }
+ if((col >= n_in_cols) || (col < 0))
+ {
+ post("matrix_mul_stat~ : col dimensions do not match !!");
+ return;
+ }
+
+ matrix += row * n_in_cols + col;
+
+ *matrix = element;
+}
+
+static void matrix_mul_stat_tilde_row(t_matrix_mul_stat_tilde *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int col, nth_row, i;
+ t_float *matrix = x->x_matbuf;
+
+ if(argc<1)
+ {
+ post("matrix_mul_stat~ : bad row: <int> in_rows !");
+ return;
+ }
+
+ nth_row = atom_getint(argv) - 1;
+ argv++;
+ argc--;
+
+ if((nth_row < 0)||(nth_row >= x->x_n_out))
+ {
+ post("matrix_mul_stat~ : row dimensions do not match !!");
+ return;
+ }
+ col = x->x_n_in;
+ if(argc < col)
+ {
+ post("matrix_mul_stat~ : col dimensions do not match !!");
+ return;
+ }
+
+ matrix += nth_row * col;
+ for(i=0; i<col; i++)
+ {
+ *matrix++ = atom_getfloat(argv);
+ argv++;
+ }
+}
+
+static void matrix_mul_stat_tilde_col(t_matrix_mul_stat_tilde *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int row, col, nth_col, i;
+ t_float *matrix = x->x_matbuf;
+
+ if(argc<1)
+ {
+ post("matrix_mul_stat~ : bad col: <int> in_cols !");
+ return;
+ }
+
+ nth_col = atom_getint(argv) - 1;
+ argv++;
+ argc--;
+
+ col = x->x_n_in;
+ if((nth_col < 0)||(nth_col >= col))
+ {
+ post("matrix_mul_stat~ : col dimensions do not match !!");
+ return;
+ }
+ row = x->x_n_out;
+ if(argc < row)
+ {
+ post("matrix_mul_stat~ : row dimensions do not match !!");
+ return;
+ }
+
+ matrix += nth_col;
+ for(i=0; i<row; i++)
+ {
+ *matrix = atom_getfloat(argv);
+ argv++;
+ matrix += col;
+ }
+}
+
+/* the dsp thing */
+
+static t_int *matrix_mul_stat_tilde_perform(t_int *w)
+{
+ t_matrix_mul_stat_tilde *x = (t_matrix_mul_stat_tilde *)(w[1]);
+ int n = (int)(w[2]);
+
+ t_float **io = x->x_io;
+ t_float *outsum, *houtsum;
+ t_float *mat = x->x_matbuf;
+ int n_in = x->x_n_in; /* columns */
+ int n_out = x->x_n_out; /* rows */
+ t_float *in, *out, mul;
+ int r, c, i;
+
+ /* 1. output-vector-row */
+ in = io[0];
+ houtsum = x->x_outsumbuf;
+ outsum = houtsum;
+ mul = *mat++;
+ for(i=0; i<n; i++)/* 1. element of 1. row */
+ {
+ *outsum++ = *in++ * mul;
+ }
+ for(c=1; c<n_in; c++)/* c+1. element of 1. row */
+ {
+ in = io[c];
+ outsum = x->x_outsumbuf;
+ mul = *mat++;
+ for(i=0; i<n; i++)
+ {
+ *outsum++ += *in++ * mul;
+ }
+ }
+ for(r=1; r<n_out; r++)/* 2. .. n_out. output-vector-row */
+ {
+ in = io[0];
+ houtsum += n;
+ outsum = houtsum;
+ mul = *mat++;
+ for(i=0; i<n; i++)/* 1. element of r+1. row */
+ {
+ *outsum++ = *in++ * mul;
+ }
+ for(c=1; c<n_in; c++)/* c+1. element of r+1. row */
+ {
+ in = io[c];
+ outsum = houtsum;
+ mul = *mat++;
+ for(i=0; i<n; i++)
+ {
+ *outsum++ += *in++ * mul;
+ }
+ }
+ }
+ outsum = x->x_outsumbuf;
+ for(r=0; r<n_out; r++)/* output-vector-row */
+ {
+ out = io[n_in+r];
+ for(i=0; i<n; i++)
+ {
+ *out++ = *outsum++;
+ }
+ }
+ return (w+3);
+}
+
+static t_int *matrix_mul_stat_tilde_perf8(t_int *w)
+{
+ t_matrix_mul_stat_tilde *x = (t_matrix_mul_stat_tilde *)(w[1]);
+ int n = (int)(w[2]);
+
+ t_float **io = x->x_io;
+ t_float *outsum, *houtsum;
+ t_float *mat = x->x_matbuf;
+ int n_in = x->x_n_in; /* columns */
+ int n_out = x->x_n_out; /* rows */
+ t_float *in, *out, mul;
+ int r, c, i;
+
+ /* 1. output-vector-row */
+ houtsum = x->x_outsumbuf;
+ outsum = houtsum;
+ mul = *mat++;
+ if(mul == 0.0f)
+ {
+ for(i=n; i; i -= 8, outsum += 8)
+ {
+ outsum[0] = 0.0f;
+ outsum[1] = 0.0f;
+ outsum[2] = 0.0f;
+ outsum[3] = 0.0f;
+ outsum[4] = 0.0f;
+ outsum[5] = 0.0f;
+ outsum[6] = 0.0f;
+ outsum[7] = 0.0f;
+ }
+ }
+ else
+ {
+ in = io[0];
+ for(i=n; i; i -= 8, outsum += 8, in += 8)
+ {
+ outsum[0] = in[0] * mul;
+ outsum[1] = in[1] * mul;
+ outsum[2] = in[2] * mul;
+ outsum[3] = in[3] * mul;
+ outsum[4] = in[4] * mul;
+ outsum[5] = in[5] * mul;
+ outsum[6] = in[6] * mul;
+ outsum[7] = in[7] * mul;
+ }
+ }
+
+ for(c=1; c<n_in; c++)/* c+1. element of 1. row */
+ {
+ mul = *mat++;
+ if(mul != 0.0f)
+ {
+ in = io[c];
+ outsum = houtsum;
+ for(i=n; i; i -= 8, outsum += 8, in += 8)
+ {
+ outsum[0] += in[0] * mul;
+ outsum[1] += in[1] * mul;
+ outsum[2] += in[2] * mul;
+ outsum[3] += in[3] * mul;
+ outsum[4] += in[4] * mul;
+ outsum[5] += in[5] * mul;
+ outsum[6] += in[6] * mul;
+ outsum[7] += in[7] * mul;
+ }
+ }
+ }
+ for(r=1; r<n_out; r++)/* 2. .. n_out. output-vector-row */
+ {
+ houtsum += n;
+ outsum = houtsum;
+ mul = *mat++;
+ if(mul == 0.0f)
+ {
+ for(i=n; i; i -= 8, outsum += 8)
+ {
+ outsum[0] = 0.0f;
+ outsum[1] = 0.0f;
+ outsum[2] = 0.0f;
+ outsum[3] = 0.0f;
+ outsum[4] = 0.0f;
+ outsum[5] = 0.0f;
+ outsum[6] = 0.0f;
+ outsum[7] = 0.0f;
+ }
+ }
+ else
+ {
+ in = io[0];
+ for(i=n; i; i -= 8, outsum += 8, in += 8)
+ {
+ outsum[0] = in[0] * mul;
+ outsum[1] = in[1] * mul;
+ outsum[2] = in[2] * mul;
+ outsum[3] = in[3] * mul;
+ outsum[4] = in[4] * mul;
+ outsum[5] = in[5] * mul;
+ outsum[6] = in[6] * mul;
+ outsum[7] = in[7] * mul;
+ }
+ }
+ for(c=1; c<n_in; c++)/* c+1. element of r+1. row */
+ {
+ mul = *mat++;
+ if(mul != 0.0f)
+ {
+ in = io[c];
+ outsum = houtsum;
+ for(i=n; i; i -= 8, outsum += 8, in += 8)
+ {
+ outsum[0] += in[0] * mul;
+ outsum[1] += in[1] * mul;
+ outsum[2] += in[2] * mul;
+ outsum[3] += in[3] * mul;
+ outsum[4] += in[4] * mul;
+ outsum[5] += in[5] * mul;
+ outsum[6] += in[6] * mul;
+ outsum[7] += in[7] * mul;
+ }
+ }
+ }
+ }
+ outsum = x->x_outsumbuf;
+ for(r=0; r<n_out; r++)/* output-vector-row */
+ {
+ out = io[n_in+r];
+ for (i=n; i; i -= 8, out += 8, outsum += 8)
+ {
+ out[0] = outsum[0];
+ out[1] = outsum[1];
+ out[2] = outsum[2];
+ out[3] = outsum[3];
+ out[4] = outsum[4];
+ out[5] = outsum[5];
+ out[6] = outsum[6];
+ out[7] = outsum[7];
+ }
+ }
+ return (w+3);
+}
+
+static void matrix_mul_stat_tilde_dsp(t_matrix_mul_stat_tilde *x, t_signal **sp)
+{
+ int i, n=sp[0]->s_n*x->x_n_out;
+
+ if(!x->x_outsumbuf)
+ {
+ x->x_outsumbufsize = n;
+ x->x_outsumbuf = (t_float *)getbytes(x->x_outsumbufsize * sizeof(t_float));
+ }
+ else if(x->x_outsumbufsize != n)
+ {
+ x->x_outsumbuf = (t_float *)resizebytes(x->x_outsumbuf, x->x_outsumbufsize*sizeof(t_float), n*sizeof(t_float));
+ x->x_outsumbufsize = n;
+ }
+
+ n = x->x_n_in + x->x_n_out;
+ for(i=0; i<n; i++)
+ {
+ x->x_io[i] = sp[i]->s_vec;
+ /*post("iovec_addr = %d", (unsigned int)x->x_io[i]);*/
+ }
+
+ n = sp[0]->s_n;
+ if(n&7)
+ dsp_add(matrix_mul_stat_tilde_perform, 2, x, n);
+ else
+ dsp_add(matrix_mul_stat_tilde_perf8, 2, x, n);
+}
+
+
+/* setup/setdown things */
+
+static void matrix_mul_stat_tilde_free(t_matrix_mul_stat_tilde *x)
+{
+ freebytes(x->x_matbuf, x->x_n_in * x->x_n_out * sizeof(t_float));
+ freebytes(x->x_io, (x->x_n_in + x->x_n_out) * sizeof(t_float *));
+ if(x->x_outsumbuf)
+ freebytes(x->x_outsumbuf, x->x_outsumbufsize * sizeof(t_float));
+}
+
+static void *matrix_mul_stat_tilde_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_matrix_mul_stat_tilde *x = (t_matrix_mul_stat_tilde *)pd_new(matrix_mul_stat_tilde_class);
+ int i;
+
+ switch (argc)
+ {
+ case 0:
+ x->x_n_in = x->x_n_out = 1;
+ break;
+ case 1:
+ x->x_n_in = x->x_n_out = (int)atom_getint(argv);
+ break;
+ default:
+ x->x_n_in = (int)atom_getint(argv);
+ x->x_n_out = (int)atom_getint(argv+1);
+ break;
+ }
+
+ if(x->x_n_in < 1)
+ x->x_n_in = 1;
+ if(x->x_n_out < 1)
+ x->x_n_out = 1;
+ i = x->x_n_in - 1;
+ while(i--)
+ inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal);
+ i = x->x_n_out;
+ while(i--)
+ outlet_new(&x->x_obj, &s_signal);
+ x->x_msi = 0;
+ x->x_outsumbuf = (t_float *)0;
+ x->x_outsumbufsize = 0;
+ x->x_matbuf = (t_float *)getbytes(x->x_n_in * x->x_n_out * sizeof(t_float));
+ x->x_io = (t_float **)getbytes((x->x_n_in + x->x_n_out) * sizeof(t_float *));
+ return (x);
+}
+
+void matrix_mul_stat_tilde_setup(void)
+{
+ matrix_mul_stat_tilde_class = class_new(gensym("matrix_mul_stat~"), (t_newmethod)matrix_mul_stat_tilde_new, (t_method)matrix_mul_stat_tilde_free,
+ sizeof(t_matrix_mul_stat_tilde), 0, A_GIMME, 0);
+ CLASS_MAINSIGNALIN(matrix_mul_stat_tilde_class, t_matrix_mul_stat_tilde, x_msi);
+ class_addmethod(matrix_mul_stat_tilde_class, (t_method)matrix_mul_stat_tilde_dsp, gensym("dsp"), 0);
+ class_addmethod(matrix_mul_stat_tilde_class, (t_method)matrix_mul_stat_tilde_matrix, gensym("matrix"), A_GIMME, 0);
+ class_addmethod(matrix_mul_stat_tilde_class, (t_method)matrix_mul_stat_tilde_element, gensym("element"), A_GIMME, 0);
+ class_addmethod(matrix_mul_stat_tilde_class, (t_method)matrix_mul_stat_tilde_row, gensym("row"), A_GIMME, 0);
+ class_addmethod(matrix_mul_stat_tilde_class, (t_method)matrix_mul_stat_tilde_col, gensym("col"), A_GIMME, 0);
+ class_sethelpsymbol(matrix_mul_stat_tilde_class, gensym("iemhelp2/matrix_mul_stat~-help"));
+}
diff --git a/src/matrix_orthogonal.c b/src/matrix_orthogonal.c
new file mode 100644
index 0000000..42fb86d
--- /dev/null
+++ b/src/matrix_orthogonal.c
@@ -0,0 +1,161 @@
+/* For information on usage and redistribution, and for a DISCLAIMER OF ALL
+* WARRANTIES, see the file, "LICENSE.txt," in this distribution.
+
+iem_matrix written by Thomas Musil (c) IEM KUG Graz Austria 2002 - 2006 */
+
+
+/* -------------------------- matrix_orthogonal ------------------------------ */
+
+/*
+versucht, eine eingehende matrix (quadratisch) zu orthogonalisiern (Transponierte = Inverse)
+
+ und zwar wie folgt:
+
+ 1. zeile orthonarmalisieren (summe aller zeilen-elemente-quadrate = 1)
+ K = summe aller a_1i (1 <= i <= N)
+ fuer alle an_1i = a_1i / sqrt(K) (1 <= i <= N)
+
+ 2. zeile:
+ K = summe aller a_2i (2 <= i <= N) - an_12
+ an_21 = an_12
+ fuer alle an_2i = a_2i / sqrt(K) (2 <= i <= N)
+
+ 3. zeile:
+ K = summe aller a_3i (3 <= i <= N) - an_13 - an_23
+ an_31 = an_13
+ an_32 = an_23
+ fuer alle an_3i = a_3i / sqrt(K) (3 <= i <= N)
+
+ usw.
+
+*/
+
+typedef struct _matrix_orthogonal
+{
+ t_object x_obj;
+ int x_dim;
+ double *x_work;
+ t_atom *x_at;
+} t_matrix_orthogonal;
+
+static t_class *matrix_orthogonal_class;
+
+static void matrix_orthogonal_matrix(t_matrix_orthogonal *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int oldsize = x->x_dim;
+ int dim;
+ int i, j;
+ int r, c;
+ double sum1, sum2, el, *v, *u;
+ t_atom *at=x->x_at;
+
+ if(argc > 2)
+ {
+ r = (int)(atom_getint(argv++));
+ c = (int)(atom_getint(argv++));
+ if(r == c)
+ {
+ dim = r;
+ if(dim < 1)
+ dim = 1;
+ if(dim > oldsize)
+ {
+ if(oldsize)
+ {
+ x->x_work = (double *)resizebytes(x->x_work, oldsize * oldsize * sizeof(double), dim * dim * sizeof(double));
+ x->x_at = (t_atom *)resizebytes(x->x_at, (oldsize * oldsize + 2) * sizeof(t_atom), (dim * dim + 2) * sizeof(t_atom));
+ x->x_dim = dim;
+ }
+ else
+ {
+ x->x_work = (double *)getbytes(dim * dim * sizeof(double));
+ x->x_at = (t_atom *)getbytes((dim * dim + 2) * sizeof(t_atom));
+ x->x_dim = dim;
+ }
+ }
+ v = x->x_work;
+ for(i=0; i<dim; i++) /* init */
+ {
+ for(j=0; j<dim; j++)
+ {
+ *v++ = (double)(atom_getfloat(argv++));
+ }
+ }
+ for(i=0; i<dim; i++) /* jede zeile */
+ {
+ sum1 = 0.0;
+ v = x->x_work + i*dim + i;
+ for(j=i; j<dim; j++) /* rest der zeile ab hauptdiagonale quadratisch summieren */
+ {
+ el = *v++;
+ sum1 += el * el;
+ }
+ v = x->x_work + i;
+ u = x->x_work + i*dim;
+ sum2 = 1.0;
+ for(j=0; j<i; j++)
+ {
+ el = *v;
+ v += dim;
+ *u++ = el;
+ sum2 -= el * el;
+ }
+ if(sum1 == 0.0)
+ sum1 = 1.0;
+ if(sum2 <= 0.0)
+ el = 0.0;
+ else
+ el = sqrt(sum2 / sum1);
+ for(j=i; j<dim; j++)
+ {
+ *u *= el;
+ u++;
+ }
+ }
+ at = x->x_at;
+ SETFLOAT(at, (t_float)dim);
+ at++;
+ SETFLOAT(at, (t_float)dim);
+ at++;
+ v = x->x_work;
+ for(i=0; i<dim; i++)
+ {
+ for(j=0; j<dim; j++)
+ {
+ SETFLOAT(at, (t_float)(*v));
+ at++;
+ v++;
+ }
+ }
+ outlet_anything(x->x_obj.ob_outlet, gensym("matrix"), dim*dim+2, x->x_at);
+ }
+ }
+}
+
+static void matrix_orthogonal_free(t_matrix_orthogonal *x)
+{
+ if(x->x_dim)
+ {
+ freebytes(x->x_work, x->x_dim * x->x_dim * sizeof(double));
+ freebytes(x->x_at, (x->x_dim * x->x_dim + 2) * sizeof(t_atom));
+ }
+}
+
+static void *matrix_orthogonal_new(void)
+{
+ t_matrix_orthogonal *x = (t_matrix_orthogonal *)pd_new(matrix_orthogonal_class);
+
+ x->x_dim = 0;
+ x->x_work = (double *)0;
+ x->x_at = (t_atom *)0;
+ outlet_new(&x->x_obj, &s_list);
+ return (x);
+}
+
+static void matrix_orthogonal_setup(void)
+{
+ matrix_orthogonal_class = class_new(gensym("matrix_orthogonal"), (t_newmethod)matrix_orthogonal_new, (t_method)matrix_orthogonal_free,
+ sizeof(t_matrix_orthogonal), 0, 0);
+ class_addmethod(matrix_orthogonal_class, (t_method)matrix_orthogonal_matrix, gensym("matrix"), A_GIMME, 0);
+ class_sethelpsymbol(matrix_orthogonal_class, gensym("iemhelp/matrix_orthogonal-help"));
+}
diff --git a/src/matrix_pinv.c b/src/matrix_pinv.c
new file mode 100644
index 0000000..452df50
--- /dev/null
+++ b/src/matrix_pinv.c
@@ -0,0 +1,600 @@
+/* For information on usage and redistribution, and for a DISCLAIMER OF ALL
+* WARRANTIES, see the file, "LICENSE.txt," in this distribution.
+
+iem_matrix written by Thomas Musil (c) IEM KUG Graz Austria 2002 - 2006 */
+
+/* -------------------------- matrix_pinv ------------------------------ */
+
+typedef struct _matrix_pinv
+{
+ t_object x_obj;
+ int x_dim;
+ int x_size;
+ double *x_work2;
+ double *x_buf2;
+ t_atom *x_at;
+} t_matrix_pinv;
+
+static t_class *matrix_pinv_class;
+
+
+
+
+static void matrix_pinv_copy_row2buf(t_matrix_pinv *x, int row)
+{
+ int dim2 = 2*x->x_dim;
+ int i;
+ double *dw=x->x_work2;
+ double *db=x->x_buf2;
+
+ dw += row*dim2;
+ for(i=0; i<dim2; i++)
+ *db++ = *dw++;
+}
+
+static void matrix_pinv_copy_buf2row(t_matrix_pinv *x, int row)
+{
+ int dim2 = 2*x->x_dim;
+ int i;
+ double *dw=x->x_work2;
+ double *db=x->x_buf2;
+
+ dw += row*dim2;
+ for(i=0; i<dim2; i++)
+ *dw++ = *db++;
+}
+
+static void matrix_pinv_copy_row2row(t_matrix_pinv *x, int src_row, int dst_row)
+{
+ int dim2 = 2*x->x_dim;
+ int i;
+ double *dw_src=x->x_work2;
+ double *dw_dst=x->x_work2;
+
+ dw_src += src_row*dim2;
+ dw_dst += dst_row*dim2;
+ for(i=0; i<dim2; i++)
+ {
+ *dw_dst++ = *dw_src++;
+ }
+}
+
+static void matrix_pinv_xch_rows(t_matrix_pinv *x, int row1, int row2)
+{
+ matrix_pinv_copy_row2buf(x, row1);
+ matrix_pinv_copy_row2row(x, row2, row1);
+ matrix_pinv_copy_buf2row(x, row2);
+}
+
+static void matrix_pinv_mul_row(t_matrix_pinv *x, int row, double mul)
+{
+ int dim2 = 2*x->x_dim;
+ int i;
+ double *dw=x->x_work2;
+
+ dw += row*dim2;
+ for(i=0; i<dim2; i++)
+ (*dw++) *= mul;
+}
+
+static void matrix_pinv_mul_col(t_matrix_pinv *x, int col, double mul)
+{
+ int dim = x->x_dim;
+ int dim2 = 2*dim;
+ int i;
+ double *dw=x->x_work2;
+
+ dw += col;
+ for(i=0; i<dim; i++)
+ {
+ (*dw) *= mul;
+ dw += dim2;
+ }
+}
+
+static void matrix_pinv_mul_buf_and_add2row(t_matrix_pinv *x, int row, double mul)
+{
+ int dim2 = 2*x->x_dim;
+ int i;
+ double *dw=x->x_work2;
+ double *db=x->x_buf2;
+
+ dw += row*dim2;
+ for(i=0; i<dim2; i++)
+ *dw++ += (*db++)*mul;
+}
+
+static int matrix_pinv_eval_which_element_of_col_not_zero(t_matrix_pinv *x, int col, int start_row)
+{
+ int dim = x->x_dim;
+ int dim2 = 2*dim;
+ int i, j;
+ double *dw=x->x_work2;
+ int ret=-1;
+
+ dw += start_row*dim2 + col;
+ j = 0;
+ for(i=start_row; i<dim; i++)
+ {
+ if((*dw > 1.0e-10) || (*dw < -1.0e-10))
+ {
+ ret = i;
+ i = dim+1;
+ }
+ dw += dim2;
+ }
+ return(ret);
+}
+
+
+static void matrix_pinv_inverse(t_matrix_pinv *x)
+{
+ int n_ambi = x->x_n_ambi;
+ int n_ambi2 = 2*n_ambi;
+ int i, j, nz;
+ int r,c;
+ double *src=x->x_inv_work1;
+ double *db=x->x_inv_work2;
+ double *acw_vec=x->x_ambi_channel_weight;
+ double rcp, *dv;
+
+ dv = db;
+ for(i=0; i<n_ambi; i++) /* init */
+ {
+ for(j=0; j<n_ambi; j++)
+ {
+ *dv++ = *src++;
+ }
+ for(j=0; j<n_ambi; j++)
+ {
+ if(j == i)
+ *dv++ = 1.0;
+ else
+ *dv++ = 0.0;
+ }
+ }
+ /* make 1 in main-diagonale, and 0 below */
+ for(i=0; i<n_ambi; i++)
+ {
+ nz = matrix_pinv_eval_which_element_of_col_not_zero(x, i, i);
+ if(nz < 0)
+ {
+ post("matrix_pinv ERROR: matrix not regular !!!!");
+ return;
+ }
+ else
+ {
+ if(nz != i)
+ matrix_pinv_xch_rows(x, i, nz);
+ dv = db + i*n_ambi2 + i;
+ rcp = 1.0 /(*dv);
+ matrix_pinv_mul_row(x, i, rcp);
+ matrix_pinv_copy_row2buf(x, i);
+ for(j=i+1; j<n_ambi; j++)
+ {
+ dv += n_ambi2;
+ rcp = -(*dv);
+ matrix_pinv_mul_buf_and_add2row(x, j, rcp);
+ }
+ }
+ }
+ /* make 0 above the main diagonale */
+ for(i=n_ambi-1; i>=0; i--)
+ {
+ dv = db + i*n_ambi2 + i;
+ matrix_pinv_copy_row2buf(x, i);
+ for(j=i-1; j>=0; j--)
+ {
+ dv -= n_ambi2;
+ rcp = -(*dv);
+ matrix_pinv_mul_buf_and_add2row(x, j, rcp);
+ }
+ }
+
+ for(i=0; i<n_ambi; i++)
+ {
+ matrix_pinv_mul_col(x, i+n_ambi, acw_vec[i]);
+ }
+
+ post("matrix_inverse regular");
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+static void matrix_pinv_matrix(t_matrix_pinv *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int dim = x->x_dim;
+ int dim2 = 2*dim;
+ int i, j, nz;
+ int r,c;
+ double *db=x->x_work2;
+ double rcp, *dv=db;
+ t_atom *at=x->x_at;
+
+ if(argc != (dim*dim + 2))
+ {
+ post("matrix_pinv ERROR: wrong dimension of input-list");
+ return;
+
+
+ if(ac > x->x_size)
+ {
+ x->x_at = (t_atom *)resizebytes(x->x_at, x->x_size*sizeof(t_atom), ac*sizeof(t_atom));
+ x->x_size = ac;
+ }
+ x->x_ac = ac;
+ x->x_sym = &s_list;
+
+ }
+ r = (int)(atom_getint(argv++));
+ c = (int)(atom_getint(argv++));
+ if(r != dim)
+ {
+ post("matrix_pinv ERROR: wrong number of rows of input-list");
+ return;
+ }
+ if(c != dim)
+ {
+ post("matrix_pinv ERROR: wrong number of cols of input-list");
+ return;
+ }
+ for(i=0; i<dim; i++) /* init */
+ {
+ for(j=0; j<dim; j++)
+ {
+ *dv++ = (double)(atom_getfloat(argv++));
+ }
+ for(j=0; j<dim; j++)
+ {
+ if(j == i)
+ *dv++ = 1.0;
+ else
+ *dv++ = 0.0;
+ }
+ }
+
+ /* make 1 in main-diagonale, and 0 below */
+ for(i=0; i<dim; i++)
+ {
+ nz = matrix_pinv_eval_which_element_of_col_not_zero(x, i, i);
+ if(nz < 0)
+ {
+ post("matrix_pinv ERROR: matrix not regular");
+ return;
+ }
+ else
+ {
+ if(nz != i)
+ {
+ matrix_pinv_xch_rows(x, i, nz);
+ }
+ dv = db + i*dim2 + i;
+ rcp = 1.0 /(*dv);
+ matrix_pinv_mul_row(x, i, rcp);
+ matrix_pinv_copy_row2buf(x, i);
+ for(j=i+1; j<dim; j++)
+ {
+ dv += dim2;
+ rcp = -(*dv);
+ matrix_pinv_mul_buf_and_add2row(x, j, rcp);
+ }
+ }
+ }
+
+ /* make 0 above the main diagonale */
+ for(i=dim-1; i>=0; i--)
+ {
+ dv = db + i*dim2 + i;
+ matrix_pinv_copy_row2buf(x, i);
+ for(j=i-1; j>=0; j--)
+ {
+ dv -= dim2;
+ rcp = -(*dv);
+ matrix_pinv_mul_buf_and_add2row(x, j, rcp);
+ }
+ }
+
+
+ at = x->x_at;
+ SETFLOAT(at, (t_float)dim);
+ at++;
+ SETFLOAT(at, (t_float)dim);
+ at++;
+ dv = db;
+ dv += dim;
+ for(i=0; i<dim; i++) /* output left half of double-matrix */
+ {
+ for(j=0; j<dim; j++)
+ {
+ SETFLOAT(at, (t_float)(*dv++));
+ at++;
+ }
+ dv += dim;
+ }
+
+ outlet_anything(x->x_obj.ob_outlet, gensym("matrix"), argc, x->x_at);
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+static void matrix_pinv_mul1(t_matrix_pinv *x)
+{
+ double *vec1, *beg1=x->x_ls_encode;
+ double *vec2, *beg2=x->x_ls_encode;
+ double *inv=x->x_inv_work1;
+ double sum;
+ int n_ls=x->x_n_ls+x->x_n_phls;
+ int n_ambi=x->x_n_ambi;
+ int i, j, k;
+
+ for(k=0; k<n_ambi; k++)
+ {
+ beg2=x->x_ls_encode;
+ for(j=0; j<n_ambi; j++)
+ {
+ sum = 0.0;
+ vec1 = beg1;
+ vec2 = beg2;
+ for(i=0; i<n_ls; i++)
+ {
+ sum += *vec1++ * *vec2++;
+ }
+ beg2 += n_ls;
+ *inv++ = sum;
+ }
+ beg1 += n_ls;
+ }
+}
+
+static void matrix_pinv_mul2(t_matrix_pinv *x)
+{
+ int n_ls=x->x_n_ls+x->x_n_phls;
+ int n_ambi=x->x_n_ambi;
+ int n_ambi2=2*n_ambi;
+ int i, j, k;
+ double *vec1, *beg1=x->x_transp;
+ double *vec2, *beg2=x->x_inv_work2+n_ambi;
+ double *vec3=x->x_prod;
+ double *acw_vec=x->x_ambi_channel_weight;
+ double sum;
+
+ for(k=0; k<n_ls; k++)
+ {
+ beg2=x->x_inv_work2+n_ambi;
+ for(j=0; j<n_ambi; j++)
+ {
+ sum = 0.0;
+ vec1 = beg1;
+ vec2 = beg2;
+ for(i=0; i<n_ambi; i++)
+ {
+ sum += *vec1++ * *vec2;
+ vec2 += n_ambi2;
+ }
+ beg2++;
+ *vec3++ = sum * acw_vec[j];
+ }
+ beg1 += n_ambi;
+ }
+}
+
+static void matrix_pinv_transp_back(t_matrix_pinv *x)
+{
+ double *vec, *transp=x->x_transp;
+ double *straight=x->x_ls_encode;
+ int n_ls=x->x_n_ls+x->x_n_phls;
+ int n_ambi=x->x_n_ambi;
+ int i, j;
+
+ for(j=0; j<n_ambi; j++)
+ {
+ vec = transp;
+ for(i=0; i<n_ls; i++)
+ {
+ *straight++ = *vec;
+ vec += n_ambi;
+ }
+ transp++;
+ }
+}
+
+static void matrix_pinv_inverse(t_matrix_pinv *x)
+{
+ int n_ambi = x->x_n_ambi;
+ int n_ambi2 = 2*n_ambi;
+ int i, j, nz;
+ int r,c;
+ double *src=x->x_inv_work1;
+ double *db=x->x_inv_work2;
+ double rcp, *dv;
+
+ dv = db;
+ for(i=0; i<n_ambi; i++) /* init */
+ {
+ for(j=0; j<n_ambi; j++)
+ {
+ *dv++ = *src++;
+ }
+ for(j=0; j<n_ambi; j++)
+ {
+ if(j == i)
+ *dv++ = 1.0;
+ else
+ *dv++ = 0.0;
+ }
+ }
+
+ /* make 1 in main-diagonale, and 0 below */
+ for(i=0; i<n_ambi; i++)
+ {
+ nz = matrix_pinv_eval_which_element_of_col_not_zero(x, i, i);
+ if(nz < 0)
+ {
+ post("matrix_pinv ERROR: matrix not regular !!!!");
+ return;
+ }
+ else
+ {
+ if(nz != i)
+ matrix_pinv_xch_rows(x, i, nz);
+ dv = db + i*n_ambi2 + i;
+ rcp = 1.0 /(*dv);
+ matrix_pinv_mul_row(x, i, rcp);
+ matrix_pinv_copy_row2buf(x, i);
+ for(j=i+1; j<n_ambi; j++)
+ {
+ dv += n_ambi2;
+ rcp = -(*dv);
+ matrix_pinv_mul_buf_and_add2row(x, j, rcp);
+ }
+ }
+ }
+
+ /* make 0 above the main diagonale */
+ for(i=n_ambi-1; i>=0; i--)
+ {
+ dv = db + i*n_ambi2 + i;
+ matrix_pinv_copy_row2buf(x, i);
+ for(j=i-1; j>=0; j--)
+ {
+ dv -= n_ambi2;
+ rcp = -(*dv);
+ matrix_pinv_mul_buf_and_add2row(x, j, rcp);
+ }
+ }
+
+ post("matrix_inverse regular");
+}
+
+static void matrix_pinv_pinv(t_matrix_pinv *x)
+{
+ t_atom *at=x->x_at;
+
+ matrix_pinv_transp_back(x);
+ matrix_pinv_mul1(x);
+ matrix_pinv_inverse(x);
+ matrix_pinv_mul2(x);
+ if((x->x_mirrorsum_end > x->x_mirrorsum_beg)&&
+ (x->x_realsum_end > x->x_realsum_beg)&&
+ ((x->x_mirrorsum_end - x->x_mirrorsum_beg) == (x->x_realsum_end - x->x_realsum_beg)))
+ {
+ double *mir=x->x_prod+x->x_mirrorsum_beg*x->x_n_ambi;
+ double *real=x->x_prod+x->x_realsum_beg*x->x_n_ambi;
+ double mwght=x->x_mir_wght;
+ int i, n=(x->x_mirrorsum_end - x->x_mirrorsum_beg)*x->x_n_ambi;
+
+ // post("mirror");
+ for(i=0; i<n; i++)
+ real[i] += mir[i]*mwght;
+
+ n = x->x_mirrorsum_beg*x->x_n_ambi;
+ real=x->x_prod;
+ SETFLOAT(at, (t_float)x->x_n_ambi);
+ at++;
+ SETFLOAT(at, (t_float)x->x_mirrorsum_beg);
+ at++;
+ for(i=0; i<n; i++)
+ {
+ SETFLOAT(at, (t_float)(*real));
+ real++;
+ at++;
+ }
+ outlet_anything(x->x_obj.ob_outlet, x->x_s_matrix, n+2, x->x_at);
+ }
+ else
+ {
+ int i, n=x->x_n_ls*x->x_n_ambi;
+ double *dv=x->x_prod;
+
+ // post("real");
+ SETFLOAT(at, (t_float)x->x_n_ambi);
+ at++;
+ SETFLOAT(at, (t_float)x->x_n_ls);
+ at++;
+ for(i=0; i<n; i++)
+ {
+ SETFLOAT(at, (t_float)(*dv));
+ dv++;
+ at++;
+ }
+ outlet_anything(x->x_obj.ob_outlet, x->x_s_matrix, n+2, x->x_at);
+ }
+}
+
+static void matrix_pinv_free(t_matrix_pinv *x)
+{
+ freebytes(x->x_work2, 2 * x->x_dim * x->x_dim * sizeof(double));
+ freebytes(x->x_buf2, 2 * x->x_dim * sizeof(double));
+ freebytes(x->x_at, x->x_size * sizeof(t_atom));
+}
+
+static void *matrix_pinv_new(void)
+{
+ t_matrix_pinv *x = (t_matrix_pinv *)pd_new(matrix_pinv_class);
+
+ x->x_dim = 10;
+ x->x_size = 102;
+ x->x_work2 = (double *)getbytes(2 * x->x_dim * x->x_dim * sizeof(double));
+ x->x_buf2 = (double *)getbytes(2 * x->x_dim * sizeof(double));
+ x->x_at = (t_atom *)getbytes(x->x_size * sizeof(t_atom));
+ outlet_new(&x->x_obj, &s_list);
+ return (x);
+}
+
+void matrix_pinv_setup(void)
+{
+ matrix_pinv_class = class_new(gensym("matrix_pinv"), (t_newmethod)matrix_pinv_new, (t_method)matrix_pinv_free,
+ sizeof(t_matrix_pinv), 0, 0);
+ class_addmethod(matrix_pinv_class, (t_method)matrix_pinv_matrix, gensym("matrix"), A_GIMME, 0);
+ class_sethelpsymbol(matrix_pinv_class, gensym("iemhelp/matrix_pinv-help"));
+}
diff --git a/src/spherical_line.c b/src/spherical_line.c
new file mode 100644
index 0000000..b2c6927
--- /dev/null
+++ b/src/spherical_line.c
@@ -0,0 +1,264 @@
+/* For information on usage and redistribution, and for a DISCLAIMER OF ALL
+* WARRANTIES, see the file, "LICENSE.txt," in this distribution.
+
+iem_matrix written by Thomas Musil (c) IEM KUG Graz Austria 2002 - 2006 */
+
+/* -------------------------- spherical_line ------------------------------ */
+
+typedef struct _spherical_line
+{
+ t_object x_obj;
+ int x_dim;
+ double *x_work2;
+ double *x_buf2;
+ t_atom *x_at;
+} t_spherical_line;
+
+static t_class *spherical_line_class;
+
+static void spherical_line_rot_z(t_spherical_line *x, double *vec, double angle)
+{
+ int i;
+ double s=sin(angle);
+ double c=cos(angle);
+ double sum=0.0;
+
+ dw += row*dim2;
+ for(i=0; i<dim2; i++)
+ {
+ *db++ = *dw++;
+ }
+}
+
+static void spherical_line_copy_row2buf(t_spherical_line *x, int row)
+{
+ int dim2 = 2*x->x_dim;
+ int i;
+ double *dw=x->x_work2;
+ double *db=x->x_buf2;
+
+ dw += row*dim2;
+ for(i=0; i<dim2; i++)
+ {
+ *db++ = *dw++;
+ }
+}
+
+static void spherical_line_copy_buf2row(t_spherical_line *x, int row)
+{
+ int dim2 = 2*x->x_dim;
+ int i;
+ double *dw=x->x_work2;
+ double *db=x->x_buf2;
+
+ dw += row*dim2;
+ for(i=0; i<dim2; i++)
+ {
+ *dw++ = *db++;
+ }
+}
+
+static void spherical_line_copy_row2row(t_spherical_line *x, int src_row, int dst_row)
+{
+ int dim2 = 2*x->x_dim;
+ int i;
+ double *dw_src=x->x_work2;
+ double *dw_dst=x->x_work2;
+
+ dw_src += src_row*dim2;
+ dw_dst += dst_row*dim2;
+ for(i=0; i<dim2; i++)
+ {
+ *dw_dst++ = *dw_src++;
+ }
+}
+
+static void spherical_line_xch_rows(t_spherical_line *x, int row1, int row2)
+{
+ spherical_line_copy_row2buf(x, row1);
+ spherical_line_copy_row2row(x, row2, row1);
+ spherical_line_copy_buf2row(x, row2);
+}
+
+static void spherical_line_mul_row(t_spherical_line *x, int row, double mul)
+{
+ int dim2 = 2*x->x_dim;
+ int i;
+ double *dw=x->x_work2;
+
+ dw += row*dim2;
+ for(i=0; i<dim2; i++)
+ {
+ (*dw++) *= mul;
+ }
+}
+
+static void spherical_line_mul_buf_and_add2row(t_spherical_line *x, int row, double mul)
+{
+ int dim2 = 2*x->x_dim;
+ int i;
+ double *dw=x->x_work2;
+ double *db=x->x_buf2;
+
+ dw += row*dim2;
+ for(i=0; i<dim2; i++)
+ {
+ *dw++ += (*db++)*mul;
+ }
+}
+
+static int spherical_line_eval_which_element_of_col_not_zero(t_spherical_line *x, int col, int start_row)
+{
+ int dim = x->x_dim;
+ int dim2 = 2*dim;
+ int i, j;
+ double *dw=x->x_work2;
+ int ret=-1;
+
+ dw += start_row*dim2 + col;
+ j = 0;
+ for(i=start_row; i<dim; i++)
+ {
+ if( (*dw > 1.0e-10) || (*dw < -1.0e-10) )
+ {
+ ret = i;
+ i = dim+1;
+ }
+ dw += dim2;
+ }
+ return(ret);
+}
+
+static void spherical_line_matrix(t_spherical_line *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int dim = x->x_dim;
+ int dim2 = 2*dim;
+ int i, j, nz;
+ int r,c;
+ double *db=x->x_work2;
+ double rcp, *dv=db;
+ t_atom *at=x->x_at;
+
+ if(argc != (dim*dim + 2))
+ {
+ post("spherical_line ERROR: wrong dimension of input-list");
+ return;
+ }
+ r = (int)(atom_getint(argv++));
+ c = (int)(atom_getint(argv++));
+ if(r != dim)
+ {
+ post("spherical_line ERROR: wrong number of rows of input-list");
+ return;
+ }
+ if(c != dim)
+ {
+ post("spherical_line ERROR: wrong number of cols of input-list");
+ return;
+ }
+ for(i=0; i<dim; i++) /* init */
+ {
+ for(j=0; j<dim; j++)
+ {
+ *dv++ = (double)(atom_getfloat(argv++));
+ }
+ for(j=0; j<dim; j++)
+ {
+ if(j == i)
+ *dv++ = 1.0;
+ else
+ *dv++ = 0.0;
+ }
+ }
+
+ /* make 1 in main-diagonale, and 0 below */
+ for(i=0; i<dim; i++)
+ {
+ nz = spherical_line_eval_which_element_of_col_not_zero(x, i, i);
+ if(nz < 0)
+ {
+ post("spherical_line ERROR: matrix not regular");
+ return;
+ }
+ else
+ {
+ if(nz != i)
+ {
+ spherical_line_xch_rows(x, i, nz);
+ }
+ dv = db + i*dim2 + i;
+ rcp = 1.0 /(*dv);
+ spherical_line_mul_row(x, i, rcp);
+ spherical_line_copy_row2buf(x, i);
+ for(j=i+1; j<dim; j++)
+ {
+ dv += dim2;
+ rcp = -(*dv);
+ spherical_line_mul_buf_and_add2row(x, j, rcp);
+ }
+ }
+ }
+
+ /* make 0 above the main diagonale */
+ for(i=dim-1; i>=0; i--)
+ {
+ dv = db + i*dim2 + i;
+ spherical_line_copy_row2buf(x, i);
+ for(j=i-1; j>=0; j--)
+ {
+ dv -= dim2;
+ rcp = -(*dv);
+ spherical_line_mul_buf_and_add2row(x, j, rcp);
+ }
+ }
+
+
+ at = x->x_at;
+ SETFLOAT(at, (t_float)dim);
+ at++;
+ SETFLOAT(at, (t_float)dim);
+ at++;
+ dv = db;
+ dv += dim;
+ for(i=0; i<dim; i++) /* output left half of double-matrix */
+ {
+ for(j=0; j<dim; j++)
+ {
+ SETFLOAT(at, (t_float)(*dv++));
+ at++;
+ }
+ dv += dim;
+ }
+
+ outlet_anything(x->x_obj.ob_outlet, gensym("matrix"), argc, x->x_at);
+}
+
+static void spherical_line_free(t_spherical_line *x)
+{
+ freebytes(x->x_work2, 2 * x->x_dim * x->x_dim * sizeof(double));
+ freebytes(x->x_buf2, 2 * x->x_dim * sizeof(double));
+ freebytes(x->x_at, (x->x_dim * x->x_dim + 2) * sizeof(t_atom));
+}
+
+static void *spherical_line_new(t_floatarg fdim)
+{
+ t_spherical_line *x = (t_spherical_line *)pd_new(spherical_line_class);
+ int dim = (int)fdim;
+
+ if(dim < 1)
+ dim = 1;
+ x->x_dim = dim;
+ x->x_work2 = (double *)getbytes(2 * x->x_dim * x->x_dim * sizeof(double));
+ x->x_buf2 = (double *)getbytes(2 * x->x_dim * sizeof(double));
+ x->x_at = (t_atom *)getbytes((x->x_dim * x->x_dim + 2) * sizeof(t_atom));
+ outlet_new(&x->x_obj, &s_list);
+ return (x);
+}
+
+static void spherical_line_setup(void)
+{
+ spherical_line_class = class_new(gensym("spherical_line"), (t_newmethod)spherical_line_new, (t_method)spherical_line_free,
+ sizeof(t_spherical_line), 0, A_FLOAT, 0);
+ class_addmethod(spherical_line_class, (t_method)spherical_line_matrix, gensym("matrix"), A_GIMME, 0);
+ class_sethelpsymbol(spherical_line_class, gensym("iemhelp/spherical_line-help"));
+}