From 6142e72914eb2d0b94a0cf9fef554cd3a6760c3f Mon Sep 17 00:00:00 2001 From: jofret Date: Thu, 19 Jun 2008 14:45:46 +0000 Subject: Reorganize and separate operations --- src/matrixOperations/multiplication/Makefile.am | 37 ++ src/matrixOperations/multiplication/Makefile.in | 623 +++++++++++++++++++++ .../multiplication/matrixMultiplication.c | 221 ++++++++ .../testDoubleMatrixMultiplication.c | 211 +++++++ .../multiplication/testFloatMatrixMultiplication.c | 206 +++++++ 5 files changed, 1298 insertions(+) create mode 100644 src/matrixOperations/multiplication/Makefile.am create mode 100644 src/matrixOperations/multiplication/Makefile.in create mode 100644 src/matrixOperations/multiplication/matrixMultiplication.c create mode 100644 src/matrixOperations/multiplication/testDoubleMatrixMultiplication.c create mode 100644 src/matrixOperations/multiplication/testFloatMatrixMultiplication.c (limited to 'src/matrixOperations/multiplication') diff --git a/src/matrixOperations/multiplication/Makefile.am b/src/matrixOperations/multiplication/Makefile.am new file mode 100644 index 00000000..2d7dbee3 --- /dev/null +++ b/src/matrixOperations/multiplication/Makefile.am @@ -0,0 +1,37 @@ +## +## Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +## Copyright (C) 2006-2008 - INRIA - Bruno JOFRET +## +## This file must be used under the terms of the CeCILL. +## This source file is licensed as described in the file COPYING, which +## you should have received as part of this distribution. The terms +## are also available at +## http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt +## +## + +libMatrixMultiplication_la_CFLAGS = -I $(top_builddir)/type \ + -I $(top_builddir)/matrixOperations/includes + +instdir = $(top_builddir)/lib + +pkglib_LTLIBRARIES = libMatrixMultiplication.la + +libMatrixMultiplication_la_SOURCES = matrixMultiplication.c + +check_PROGRAMS = testMatrixMultiplication + +check_LDADD = $(top_builddir)/type/libDoubleComplex.la \ + $(top_builddir)/type/libFloatComplex.la \ + $(top_builddir)/lib/blas/libsciblas.la \ + libMatrixMultiplication.la + +check_INCLUDES = -I $(top_builddir)/type \ + -I $(top_builddir)/matrixOperations/includes + +testMatrixMultiplication_SOURCES = testFloatMatrixMultiplication.c \ + testDoubleMatrixMultiplication.c +testMatrixMultiplication_LDADD = $(check_LDADD) +testMatrixMultiplication_CFLAGS = $(check_INCLUDES) + +TESTS = testMatrixMultiplication \ No newline at end of file diff --git a/src/matrixOperations/multiplication/Makefile.in b/src/matrixOperations/multiplication/Makefile.in new file mode 100644 index 00000000..7983fe53 --- /dev/null +++ b/src/matrixOperations/multiplication/Makefile.in @@ -0,0 +1,623 @@ +# Makefile.in generated by automake 1.10.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +check_PROGRAMS = testMatrixMultiplication$(EXEEXT) +TESTS = testMatrixMultiplication$(EXEEXT) +subdir = matrixOperations/multiplication +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/includes/machine.h +CONFIG_CLEAN_FILES = +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; +am__installdirs = "$(DESTDIR)$(pkglibdir)" +pkglibLTLIBRARIES_INSTALL = $(INSTALL) +LTLIBRARIES = $(pkglib_LTLIBRARIES) +libMatrixMultiplication_la_LIBADD = +am_libMatrixMultiplication_la_OBJECTS = \ + libMatrixMultiplication_la-matrixMultiplication.lo +libMatrixMultiplication_la_OBJECTS = \ + $(am_libMatrixMultiplication_la_OBJECTS) +libMatrixMultiplication_la_LINK = $(LIBTOOL) --tag=CC \ + $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ + $(libMatrixMultiplication_la_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +am_testMatrixMultiplication_OBJECTS = testMatrixMultiplication-testFloatMatrixMultiplication.$(OBJEXT) \ + testMatrixMultiplication-testDoubleMatrixMultiplication.$(OBJEXT) +testMatrixMultiplication_OBJECTS = \ + $(am_testMatrixMultiplication_OBJECTS) +testMatrixMultiplication_DEPENDENCIES = $(check_LDADD) +testMatrixMultiplication_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) \ + $(testMatrixMultiplication_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/includes +depcomp = $(SHELL) $(top_srcdir)/config/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(libMatrixMultiplication_la_SOURCES) \ + $(testMatrixMultiplication_SOURCES) +DIST_SOURCES = $(libMatrixMultiplication_la_SOURCES) \ + $(testMatrixMultiplication_SOURCES) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DSYMUTIL = @DSYMUTIL@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +GREP = @GREP@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LDFLAGS = @LDFLAGS@ +LIBMATH = @LIBMATH@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +NMEDIT = @NMEDIT@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +libMatrixMultiplication_la_CFLAGS = -I $(top_builddir)/type \ + -I $(top_builddir)/matrixOperations/includes + +instdir = $(top_builddir)/lib +pkglib_LTLIBRARIES = libMatrixMultiplication.la +libMatrixMultiplication_la_SOURCES = matrixMultiplication.c +check_LDADD = $(top_builddir)/type/libDoubleComplex.la \ + $(top_builddir)/type/libFloatComplex.la \ + $(top_builddir)/lib/blas/libsciblas.la \ + libMatrixMultiplication.la + +check_INCLUDES = -I $(top_builddir)/type \ + -I $(top_builddir)/matrixOperations/includes + +testMatrixMultiplication_SOURCES = testFloatMatrixMultiplication.c \ + testDoubleMatrixMultiplication.c + +testMatrixMultiplication_LDADD = $(check_LDADD) +testMatrixMultiplication_CFLAGS = $(check_INCLUDES) +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign matrixOperations/multiplication/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign matrixOperations/multiplication/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES) + @$(NORMAL_INSTALL) + test -z "$(pkglibdir)" || $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" + @list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \ + if test -f $$p; then \ + f=$(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \ + else :; fi; \ + done + +uninstall-pkglibLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \ + p=$(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \ + done + +clean-pkglibLTLIBRARIES: + -test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES) + @list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +libMatrixMultiplication.la: $(libMatrixMultiplication_la_OBJECTS) $(libMatrixMultiplication_la_DEPENDENCIES) + $(libMatrixMultiplication_la_LINK) -rpath $(pkglibdir) $(libMatrixMultiplication_la_OBJECTS) $(libMatrixMultiplication_la_LIBADD) $(LIBS) + +clean-checkPROGRAMS: + @list='$(check_PROGRAMS)'; for p in $$list; do \ + f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f $$p $$f"; \ + rm -f $$p $$f ; \ + done +testMatrixMultiplication$(EXEEXT): $(testMatrixMultiplication_OBJECTS) $(testMatrixMultiplication_DEPENDENCIES) + @rm -f testMatrixMultiplication$(EXEEXT) + $(testMatrixMultiplication_LINK) $(testMatrixMultiplication_OBJECTS) $(testMatrixMultiplication_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libMatrixMultiplication_la-matrixMultiplication.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testMatrixMultiplication-testDoubleMatrixMultiplication.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testMatrixMultiplication-testFloatMatrixMultiplication.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +libMatrixMultiplication_la-matrixMultiplication.lo: matrixMultiplication.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libMatrixMultiplication_la_CFLAGS) $(CFLAGS) -MT libMatrixMultiplication_la-matrixMultiplication.lo -MD -MP -MF $(DEPDIR)/libMatrixMultiplication_la-matrixMultiplication.Tpo -c -o libMatrixMultiplication_la-matrixMultiplication.lo `test -f 'matrixMultiplication.c' || echo '$(srcdir)/'`matrixMultiplication.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libMatrixMultiplication_la-matrixMultiplication.Tpo $(DEPDIR)/libMatrixMultiplication_la-matrixMultiplication.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='matrixMultiplication.c' object='libMatrixMultiplication_la-matrixMultiplication.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libMatrixMultiplication_la_CFLAGS) $(CFLAGS) -c -o libMatrixMultiplication_la-matrixMultiplication.lo `test -f 'matrixMultiplication.c' || echo '$(srcdir)/'`matrixMultiplication.c + +testMatrixMultiplication-testFloatMatrixMultiplication.o: testFloatMatrixMultiplication.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testMatrixMultiplication_CFLAGS) $(CFLAGS) -MT testMatrixMultiplication-testFloatMatrixMultiplication.o -MD -MP -MF $(DEPDIR)/testMatrixMultiplication-testFloatMatrixMultiplication.Tpo -c -o testMatrixMultiplication-testFloatMatrixMultiplication.o `test -f 'testFloatMatrixMultiplication.c' || echo '$(srcdir)/'`testFloatMatrixMultiplication.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/testMatrixMultiplication-testFloatMatrixMultiplication.Tpo $(DEPDIR)/testMatrixMultiplication-testFloatMatrixMultiplication.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='testFloatMatrixMultiplication.c' object='testMatrixMultiplication-testFloatMatrixMultiplication.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testMatrixMultiplication_CFLAGS) $(CFLAGS) -c -o testMatrixMultiplication-testFloatMatrixMultiplication.o `test -f 'testFloatMatrixMultiplication.c' || echo '$(srcdir)/'`testFloatMatrixMultiplication.c + +testMatrixMultiplication-testFloatMatrixMultiplication.obj: testFloatMatrixMultiplication.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testMatrixMultiplication_CFLAGS) $(CFLAGS) -MT testMatrixMultiplication-testFloatMatrixMultiplication.obj -MD -MP -MF $(DEPDIR)/testMatrixMultiplication-testFloatMatrixMultiplication.Tpo -c -o testMatrixMultiplication-testFloatMatrixMultiplication.obj `if test -f 'testFloatMatrixMultiplication.c'; then $(CYGPATH_W) 'testFloatMatrixMultiplication.c'; else $(CYGPATH_W) '$(srcdir)/testFloatMatrixMultiplication.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/testMatrixMultiplication-testFloatMatrixMultiplication.Tpo $(DEPDIR)/testMatrixMultiplication-testFloatMatrixMultiplication.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='testFloatMatrixMultiplication.c' object='testMatrixMultiplication-testFloatMatrixMultiplication.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testMatrixMultiplication_CFLAGS) $(CFLAGS) -c -o testMatrixMultiplication-testFloatMatrixMultiplication.obj `if test -f 'testFloatMatrixMultiplication.c'; then $(CYGPATH_W) 'testFloatMatrixMultiplication.c'; else $(CYGPATH_W) '$(srcdir)/testFloatMatrixMultiplication.c'; fi` + +testMatrixMultiplication-testDoubleMatrixMultiplication.o: testDoubleMatrixMultiplication.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testMatrixMultiplication_CFLAGS) $(CFLAGS) -MT testMatrixMultiplication-testDoubleMatrixMultiplication.o -MD -MP -MF $(DEPDIR)/testMatrixMultiplication-testDoubleMatrixMultiplication.Tpo -c -o testMatrixMultiplication-testDoubleMatrixMultiplication.o `test -f 'testDoubleMatrixMultiplication.c' || echo '$(srcdir)/'`testDoubleMatrixMultiplication.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/testMatrixMultiplication-testDoubleMatrixMultiplication.Tpo $(DEPDIR)/testMatrixMultiplication-testDoubleMatrixMultiplication.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='testDoubleMatrixMultiplication.c' object='testMatrixMultiplication-testDoubleMatrixMultiplication.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testMatrixMultiplication_CFLAGS) $(CFLAGS) -c -o testMatrixMultiplication-testDoubleMatrixMultiplication.o `test -f 'testDoubleMatrixMultiplication.c' || echo '$(srcdir)/'`testDoubleMatrixMultiplication.c + +testMatrixMultiplication-testDoubleMatrixMultiplication.obj: testDoubleMatrixMultiplication.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testMatrixMultiplication_CFLAGS) $(CFLAGS) -MT testMatrixMultiplication-testDoubleMatrixMultiplication.obj -MD -MP -MF $(DEPDIR)/testMatrixMultiplication-testDoubleMatrixMultiplication.Tpo -c -o testMatrixMultiplication-testDoubleMatrixMultiplication.obj `if test -f 'testDoubleMatrixMultiplication.c'; then $(CYGPATH_W) 'testDoubleMatrixMultiplication.c'; else $(CYGPATH_W) '$(srcdir)/testDoubleMatrixMultiplication.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/testMatrixMultiplication-testDoubleMatrixMultiplication.Tpo $(DEPDIR)/testMatrixMultiplication-testDoubleMatrixMultiplication.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='testDoubleMatrixMultiplication.c' object='testMatrixMultiplication-testDoubleMatrixMultiplication.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testMatrixMultiplication_CFLAGS) $(CFLAGS) -c -o testMatrixMultiplication-testDoubleMatrixMultiplication.obj `if test -f 'testDoubleMatrixMultiplication.c'; then $(CYGPATH_W) 'testDoubleMatrixMultiplication.c'; else $(CYGPATH_W) '$(srcdir)/testDoubleMatrixMultiplication.c'; fi` + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +check-TESTS: $(TESTS) + @failed=0; all=0; xfail=0; xpass=0; skip=0; ws='[ ]'; \ + srcdir=$(srcdir); export srcdir; \ + list=' $(TESTS) '; \ + if test -n "$$list"; then \ + for tst in $$list; do \ + if test -f ./$$tst; then dir=./; \ + elif test -f $$tst; then dir=; \ + else dir="$(srcdir)/"; fi; \ + if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *$$ws$$tst$$ws*) \ + xpass=`expr $$xpass + 1`; \ + failed=`expr $$failed + 1`; \ + echo "XPASS: $$tst"; \ + ;; \ + *) \ + echo "PASS: $$tst"; \ + ;; \ + esac; \ + elif test $$? -ne 77; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *$$ws$$tst$$ws*) \ + xfail=`expr $$xfail + 1`; \ + echo "XFAIL: $$tst"; \ + ;; \ + *) \ + failed=`expr $$failed + 1`; \ + echo "FAIL: $$tst"; \ + ;; \ + esac; \ + else \ + skip=`expr $$skip + 1`; \ + echo "SKIP: $$tst"; \ + fi; \ + done; \ + if test "$$failed" -eq 0; then \ + if test "$$xfail" -eq 0; then \ + banner="All $$all tests passed"; \ + else \ + banner="All $$all tests behaved as expected ($$xfail expected failures)"; \ + fi; \ + else \ + if test "$$xpass" -eq 0; then \ + banner="$$failed of $$all tests failed"; \ + else \ + banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \ + fi; \ + fi; \ + dashes="$$banner"; \ + skipped=""; \ + if test "$$skip" -ne 0; then \ + skipped="($$skip tests were not run)"; \ + test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \ + dashes="$$skipped"; \ + fi; \ + report=""; \ + if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \ + report="Please report to $(PACKAGE_BUGREPORT)"; \ + test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \ + dashes="$$report"; \ + fi; \ + dashes=`echo "$$dashes" | sed s/./=/g`; \ + echo "$$dashes"; \ + echo "$$banner"; \ + test -z "$$skipped" || echo "$$skipped"; \ + test -z "$$report" || echo "$$report"; \ + echo "$$dashes"; \ + test "$$failed" -eq 0; \ + else :; fi + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) + $(MAKE) $(AM_MAKEFLAGS) check-TESTS +check: check-am +all-am: Makefile $(LTLIBRARIES) +installdirs: + for dir in "$(DESTDIR)$(pkglibdir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-checkPROGRAMS clean-generic clean-libtool \ + clean-pkglibLTLIBRARIES mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-exec-am: install-pkglibLTLIBRARIES + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-pkglibLTLIBRARIES + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-TESTS check-am clean \ + clean-checkPROGRAMS clean-generic clean-libtool \ + clean-pkglibLTLIBRARIES ctags distclean distclean-compile \ + distclean-generic distclean-libtool distclean-tags distdir dvi \ + dvi-am html html-am info info-am install install-am \ + install-data install-data-am install-dvi install-dvi-am \ + install-exec install-exec-am install-html install-html-am \ + install-info install-info-am install-man install-pdf \ + install-pdf-am install-pkglibLTLIBRARIES install-ps \ + install-ps-am install-strip installcheck installcheck-am \ + installdirs maintainer-clean maintainer-clean-generic \ + mostlyclean mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \ + uninstall-am uninstall-pkglibLTLIBRARIES + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/src/matrixOperations/multiplication/matrixMultiplication.c b/src/matrixOperations/multiplication/matrixMultiplication.c new file mode 100644 index 00000000..dbed4330 --- /dev/null +++ b/src/matrixOperations/multiplication/matrixMultiplication.c @@ -0,0 +1,221 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2008-2008 - INRIA - Bruno JOFRET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + * + */ + +#ifndef WITHOUT_BLAS +#include "blas.h" +#endif +#include "matrixMultiplication.h" + +/* +** \brief Compute a multiplication for floats matrixes. +** \param in1 : input matrix. +** \param lines1 : lines of in1 matrix. +** \param columns1 : columns of in1 matrix. +** \param in2 : input arry. +** \param lines2 : lines of in2 matrix. +** \param columns2 : columns of in2 matrix. +** \param out : Matrix that contains the multiplication in1 * in2. +*/ +void smulma(float *in1, int lines1, int columns1, + float *in2, int lines2, int columns2, + float *out) +{ + int i = 0; + int k = 0; + float accu = 0; + + /* + ** How to convert 2 index matrixes to one. + ** #define in1(a, b) in1[a+b*lines1] + ** #define in2(c, d) in2[c+d*lines2] + */ + + for (i = 0 ; i < lines1 * columns2 ; ++i) + { + accu = 0; + for (k = 0; k < columns1 ; ++k) + { + accu += in1[i % lines1 + k * lines1] + * in2[k + (i / lines1) * lines2]; + } + out[i] = accu; + } + +} + +/* +** \brief Compute a multiplication for doubles matrixes. +** \param in1 : input matrix. +** \param lines1 : lines of in1 matrix. +** \param columns1 : columns of in1 matrix. +** \param in2 : input arry. +** \param lines2 : lines of in2 matrix. +** \param columns2 : columns of in2 matrix. +** \param out : Matrix that contains the multiplication in1 * in2. +*/ +void dmulma(double *in1, int lines1, int columns1, + double *in2, int lines2, int columns2, + double *out) +{ +#ifndef WITHOUT_BLAS + /* + ** USES BLAS DGEMM FUNCTION. + */ + double One = 1; + double Zero = 0; + + /* Cr <- 1*Ar*Br + 0*Cr */ + dgemm_("N","N", &columns2, &columns2, &columns1, &One, + in1 , &lines1, in2, &lines2, &Zero, out, &columns2); +#else + /* + ** DO NOT USE ANY BLAS FUNCTION. + */ + int i = 0; + int k = 0; + double accu = 0; + + /* + ** How to convert 2 index matrixes to one. + ** #define in1(a, b) in1[a+b*lines1] + ** #define in2(c, d) in2[c+d*lines2] + */ + + for (i = 0 ; i < lines1 * columns2 ; ++i) + { + accu = 0; + for (k = 0; k < columns1 ; ++k) + { + accu += in1[i % lines1 + k * lines1] + * in2[k + (i / lines1) * lines2]; + } + out[i] = accu; + } +#endif +} + +/* +** \brief Compute a multiplication for floats complex matrixes. +** \param in1 : input matrix. +** \param lines1 : lines of in1 matrix. +** \param columns1 : columns of in1 matrix. +** \param in2 : input arry. +** \param lines2 : lines of in2 matrix. +** \param columns2 : columns of in2 matrix. +** \param out : Matrix that contains the multiplication in1 * in2. +*/ +void cmulma(floatComplex *in1, int lines1, int columns1, + floatComplex *in2, int lines2, int columns2, + floatComplex *out) +{ + int i = 0; + int k = 0; + floatComplex accu = FloatComplex(0, 0); + + for (i = 0 ; i < lines1 * columns2 ; ++i) + { + accu = FloatComplex(0,0); + for (k = 0; k < columns1 ; ++k) + { + accu = cadds(accu, + ctimess(in1[i % lines1 + k *lines1] , + in2[k + (i / lines1) *lines2] )); + } + out[i] = accu; + } +} + +/* +** \brief Compute a multiplication for doubles matrixes. +** \param in1 : input matrix. +** \param lines1 : lines of in1 matrix. +** \param columns1 : columns of in1 matrix. +** \param in2 : input arry. +** \param lines2 : lines of in2 matrix. +** \param columns2 : columns of in2 matrix. +** \param out : Matrix that contains the multiplication in1 * in2. +*/ +void zmulma(doubleComplex *in1, int lines1, int columns1, + doubleComplex *in2, int lines2, int columns2, + doubleComplex *out) +{ +#ifndef WITHOUT_BLAS + /* + ** USES BLAS DGEMM FUNCTION. + */ + int i = 0; + double One = 1; + double MinusOne = -1; + double Zero = 0; + + double *in1Real = malloc((uint) lines1 * (uint) columns1 * sizeof(double)); + double *in1Imag = malloc((uint) lines1 * (uint) columns1 * sizeof(double)); + double *in2Real = malloc((uint) lines2 * (uint) columns2 * sizeof(double)); + double *in2Imag = malloc((uint) lines2 * (uint) columns2 * sizeof(double)); + + double *RealOut = malloc((uint) lines1 * (uint) columns2 * sizeof(double)); + double *ImagOut = malloc((uint) lines1 * (uint) columns2 * sizeof(double)); + + zreala(in1, lines1 * columns1, in1Real); + zreala(in2, lines2 * columns2, in2Real); + zimaga(in1, lines1 * columns1, in1Imag); + zimaga(in2, lines2 * columns2, in2Imag); + + /* Cr <- 1*Ar*Br + 0*Cr */ + dgemm_("N","N", &lines1, &columns2, &columns1, &One, + in1Real, &lines1, in2Real, &lines2, &Zero, RealOut, &lines1); + + /* Cr <- -1*Ai*Bi + 1*Cr */ + dgemm_("N","N", &lines1, &columns2, &columns1, &MinusOne, + in1Imag, &lines1, in2Imag, &lines2, &One, RealOut, &lines1); + + /* Ci <- 1*Ar*Bi + 0*Ci */ + dgemm_("N","N", &lines1, &columns2, &columns1, &One, + in1Real, &lines1, in2Imag, &lines2, &Zero, ImagOut, &lines1); + + /* Ci <- 1*Ai*Br + 1*Ci */ + dgemm_("N","N", &lines1, &columns2, &columns1, &One, + in1Imag, &lines1, in2Real, &lines2, &One, ImagOut, &lines1); + + /* Now fill output matrix */ + for(i = 0 ; i < lines1 * columns2 ; ++i) + { + out[i] = DoubleComplex(RealOut[i], ImagOut[i]); + } + /* FREE allocated variables */ + free(in1Real); + free(in2Real); + free(in1Imag); + free(in2Imag); + free(RealOut); + free(ImagOut); +#else + /* + ** DO NOT USE ANY BLAS FUNCTION. + */ + int i = 0; + int k = 0; + doubleComplex accu = DoubleComplex(0, 0); + + for (i = 0 ; i < lines1 * columns2 ; ++i) + { + accu = DoubleComplex(0,0); + for (k = 0; k < columns1 ; ++k) + { + accu = zadds(accu, + ztimess(in1[i % lines1 + k *lines1] , + in2[k + (i / lines1) *lines2] )); + } + out[i] = accu; + } +#endif +} diff --git a/src/matrixOperations/multiplication/testDoubleMatrixMultiplication.c b/src/matrixOperations/multiplication/testDoubleMatrixMultiplication.c new file mode 100644 index 00000000..e9b71a87 --- /dev/null +++ b/src/matrixOperations/multiplication/testDoubleMatrixMultiplication.c @@ -0,0 +1,211 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2008-2008 - INRIA - Bruno JOFRET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + * + */ + +#include +#include +#include +#include +#include "matrixMultiplication.h" + +int testFloatMultiplication(void); + +static void zmulmaTest(void) { + double realM1[4] = {1.0, 2.0, 3.0, 4.0}; + double imagM1[4] = {1.0, 2.0, 3.0, 4.0}; + double realM3[6] = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0}; + double imagM3[6] = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0}; + + doubleComplex *M1; + doubleComplex *M2; + doubleComplex M1_mul_M2[4]; + doubleComplex *M3; + doubleComplex *M4; + doubleComplex M3_mul_M4[4]; + doubleComplex miscM3_mul_M4[9]; + + int i = 0; + + printf("\n>>>> Matrix Complex Double Multiplication Tests\n"); + + M1 = DoubleComplexMatrix(realM1, imagM1, 4); + M2 = DoubleComplexMatrix(realM1, imagM1, 4); + + /* + [ 1+1.%i 3+3.%i] * [ 1+1.%i 3+3.%i] = [ 14.%i 30.%i ] + [ 2+2.%i 4+4.%i] [ 2+2.%i 4+4.%i] [ 20.%i 44.%i ] + */ + zmulma(M1, 2, 2, M2, 2, 2, M1_mul_M2); + for (i = 0; i < 4; ++i) + { + printf("M1_mul_M2[%d] = %e + %e i\n", i, zreals(M1_mul_M2[i]), zimags(M1_mul_M2[i])); + } + for (i = 0; i < 4; ++i) + { + assert(zreals(M1_mul_M2[i]) == 0.0); + } + assert(zimags(M1_mul_M2[0]) == 14.0); + assert(zimags(M1_mul_M2[1]) == 20.0); + assert(zimags(M1_mul_M2[2]) == 30.0); + assert(zimags(M1_mul_M2[3]) == 44.0); + + M3 = DoubleComplexMatrix(realM3, imagM3, 6); + M4 = DoubleComplexMatrix(realM3, imagM3, 6); + + /* + [ 1+1.%i 3+3.%i 5+5.%i ] * [ 1+1.%i 4+4.%i ] = [ 44.%i 98.%i ] + [ 2+2.%i 4+4.%i 6+6.%i ] [ 2+2.%i 5+5.%i ] [ 56.%i 128.%i ] + [ 3+3.%i 6+6.%i ] + */ + zmulma(M3, 2, 3, M4, 3, 2, M3_mul_M4); + for (i = 0; i < 4; ++i) + { + printf("M3_mul_M4[%d] = %e + %e i\n", i, zreals(M3_mul_M4[i]), zimags(M3_mul_M4[i])); + } + for (i = 0; i < 4; ++i) + { + assert(zreals(M3_mul_M4[i]) == 0.0); + } + assert(zimags(M3_mul_M4[0]) == 44.0); + assert(zimags(M3_mul_M4[1]) == 56.0); + assert(zimags(M3_mul_M4[2]) == 98.0); + assert(zimags(M3_mul_M4[3]) == 128.0); + + /* + [ 1+1.%i 4+4.%i ] * [ 1+1.%i 3+3.%i 5+5.%i ] = [ 18.%i 38.%i 58.%i ] + [ 2+2.%i 5+5.%i ] [ 2+2.%i 4+4.%i 6+6.%i ] [ 24.%i 52.%i 80.%i ] + [ 3+3.%i 6+6.%i ] [ 30.%i 66.%i 102.%i ] + */ + zmulma(M3, 3, 2, M4, 2, 3, miscM3_mul_M4); + for (i = 0; i < 9; ++i) + { + printf("miscM3_mul_M4[%d] = %e + %e i\n", i, zreals(miscM3_mul_M4[i]), zimags(miscM3_mul_M4[i])); + } + for (i = 0; i < 9; ++i) + { + assert(zreals(miscM3_mul_M4[i]) == 0.0); + } + assert(zimags(miscM3_mul_M4[0]) == 18.0); + assert(zimags(miscM3_mul_M4[1]) == 24.0); + assert(zimags(miscM3_mul_M4[2]) == 30.0); + assert(zimags(miscM3_mul_M4[3]) == 38.0); + assert(zimags(miscM3_mul_M4[4]) == 52.0); + assert(zimags(miscM3_mul_M4[5]) == 66.0); + assert(zimags(miscM3_mul_M4[6]) == 58.0); + assert(zimags(miscM3_mul_M4[7]) == 80.0); + assert(zimags(miscM3_mul_M4[8]) == 102.0); +} + +static void dmulmaTest(void) { + double M1[4] = {1.0, 2.0, 3.0, 4.0}; + double M2[4] = {1.0, 2.0, 3.0, 4.0}; + double M1_by_M2[4]; + double M3[4] = {1.0, 0.0, 1.0, 0.0}; + double M4[4] = {0.0, 1.0, 0.0, 1.0}; + double M3_by_M4[4]; + double M5[4] = {1.0, 0.0, 0.0, 1.0}; + double M6[4] = {42.0, 51.0, 69.0, 1664.0}; + double M5_by_M6[4]; + double M7[6] = {1.0, 4.0, 2.0, 5.0, 3.0, 6.0}; + double M8[6] = {1.0, 3.0, 5.0, 2.0, 4.0, 6.0}; + double M7_by_M8[4]; + double miscM7_by_M8[9]; + + int i = 0; + + printf("\n>>>> Matrix Real Double Multiplication Tests\n"); + /* + [ 1 3 ] * [ 1 3 ] = [ 7 15 ] + [ 2 4 ] [ 2 4 ] [10 22 ] + */ + dmulma(M1, 2, 2, M2, 2, 2, M1_by_M2); + for (i = 0; i < 4; ++i) { + printf("M1_by_M2[%d] = %e\n", i, M1_by_M2[i]); + } + assert(M1_by_M2[0] == 7.0); + assert(M1_by_M2[1] == 10.0); + assert(M1_by_M2[2] == 15.0); + assert(M1_by_M2[3] == 22.0); + /* + [ 1 1 ] * [ 0 0 ] = [ 1 1 ] + [ 0 0 ] [ 1 1 ] [ 0 0 ] + */ + dmulma(M3, 2, 2, M4, 2, 2, M3_by_M4); + for (i = 0; i < 4; ++i) { + printf("M3_by_M4[%d] = %e\n", i, M3_by_M4[i]); + } + assert(M3_by_M4[0] == 1.0); + assert(M3_by_M4[1] == 0.0); + assert(M3_by_M4[2] == 1.0); + assert(M3_by_M4[3] == 0.0); + + /* + [ 1 0 ] * [ 42 69 ] = [ 42 69 ] + [ 0 1 ] [ 51 1664 ] [ 51 1664 ] + */ + dmulma(M5, 2, 2, M6, 2, 2, M5_by_M6); + for (i = 0; i < 4; ++i) { + printf("M5_by_M6[%d] = %e\n", i, M5_by_M6[i]); + } + assert(M5_by_M6[0] == 42.0); + assert(M5_by_M6[1] == 51.0); + assert(M5_by_M6[2] == 69.0); + assert(M5_by_M6[3] == 1664.0); + + /* + [ 1 2 3 ] * [ 1 2 ] = [ 22 28 ] + [ 4 5 6 ] [ 3 4 ] [ 49 64 ] + [ 5 6 ] + */ + dmulma(M7, 2, 3, M8, 3, 2, M7_by_M8); + for (i = 0; i < 4; ++i) { + printf("M7_by_M8[%d] = %e\n", i, M7_by_M8[i]); + } + assert(M7_by_M8[0] == 22.0); + assert(M7_by_M8[1] == 49.0); + assert(M7_by_M8[2] == 28.0); + assert(M7_by_M8[3] == 64.0); + + /* + [ 1 5 ] * [ 1 5 4 ] = [ 16 15 34 ] + [ 4 3 ] [ 3 2 6 ] [ 13 26 34 ] + [ 2 6 ] [ 20 22 44 ] + */ + dmulma(M7, 3, 2, M8, 2, 3, miscM7_by_M8); + for (i = 0; i < 9; ++i) { + printf("miscM7_by_M8[%d] = %e\n", i, miscM7_by_M8[i]); + } + assert(miscM7_by_M8[0] == 16.0); + assert(miscM7_by_M8[1] == 13.0); + assert(miscM7_by_M8[2] == 20.0); + assert(miscM7_by_M8[3] == 15.0); + assert(miscM7_by_M8[4] == 26.0); + assert(miscM7_by_M8[5] == 22.0); + assert(miscM7_by_M8[6] == 34.0); + assert(miscM7_by_M8[7] == 34.0); + assert(miscM7_by_M8[8] == 44.0); +} + +static int testDoubleMultiplication(void) { + + printf("\n>>>> Matrix Double Multiplication Tests\n"); + dmulmaTest(); + zmulmaTest(); + return 0; +} + + + +int main(void) { + assert(testFloatMultiplication() == 0); + assert(testDoubleMultiplication() == 0); + return 0; +} diff --git a/src/matrixOperations/multiplication/testFloatMatrixMultiplication.c b/src/matrixOperations/multiplication/testFloatMatrixMultiplication.c new file mode 100644 index 00000000..6091fc66 --- /dev/null +++ b/src/matrixOperations/multiplication/testFloatMatrixMultiplication.c @@ -0,0 +1,206 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2008-2008 - INRIA - Bruno JOFRET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + * + */ + +#include +#include +#include +#include +#include "matrixMultiplication.h" + +int testFloatMultiplication(void); + +static void cmulmaTest(void) { + float realM1[4] = {1.0f, 2.0f, 3.0f, 4.0f}; + float imagM1[4] = {1.0f, 2.0f, 3.0f, 4.0f}; + float realM3[6] = {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f}; + float imagM3[6] = {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f}; + + floatComplex *M1; + floatComplex *M2; + floatComplex M1_mul_M2[4]; + floatComplex *M3; + floatComplex *M4; + floatComplex M3_mul_M4[4]; + floatComplex miscM3_mul_M4[9]; + + int i = 0; + + printf("\n>>>> Matrix Complex Float Multiplication Tests\n"); + + M1 = FloatComplexMatrix(realM1, imagM1, 4); + M2 = FloatComplexMatrix(realM1, imagM1, 4); + + /* + [ 1+1.%i 3+3.%i] * [ 1+1.%i 3+3.%i] = [ 14.%i 30.%i ] + [ 2+2.%i 3+3.%i] [ 2+2.%i 3+3.%i] [ 20.%i 44.%i ] + */ + cmulma(M1, 2, 2, M2, 2, 2, M1_mul_M2); + for (i = 0; i < 4; ++i) + { + printf("M1_mul_M2[%d] = %e + %e i\n", i, creals(M1_mul_M2[i]), cimags(M1_mul_M2[i])); + } + for (i = 0; i < 4; ++i) + { + assert(creals(M1_mul_M2[i]) == 0.0f); + } + assert(cimags(M1_mul_M2[0]) == 14.0f); + assert(cimags(M1_mul_M2[1]) == 20.0f); + assert(cimags(M1_mul_M2[2]) == 30.0f); + assert(cimags(M1_mul_M2[3]) == 44.0f); + + M3 = FloatComplexMatrix(realM3, imagM3, 6); + M4 = FloatComplexMatrix(realM3, imagM3, 6); + + /* + [ 1+1.%i 3+3.%i 5+5.%i ] * [ 1+1.%i 4+4.%i ] = [ 44.%i 98.%i ] + [ 2+2.%i 4+4.%i 6+6.%i ] [ 2+2.%i 5+5.%i ] [ 56.%i 128.%i ] + [ 3+3.%i 6+6.%i ] + */ + cmulma(M3, 2, 3, M4, 3, 2, M3_mul_M4); + for (i = 0; i < 4; ++i) + { + printf("M3_mul_M4[%d] = %e + %e i\n", i, creals(M3_mul_M4[i]), cimags(M3_mul_M4[i])); + } + for (i = 0; i < 4; ++i) + { + assert(creals(M3_mul_M4[i]) == 0.0f); + } + assert(cimags(M3_mul_M4[0]) == 44.0f); + assert(cimags(M3_mul_M4[1]) == 56.0f); + assert(cimags(M3_mul_M4[2]) == 98.0f); + assert(cimags(M3_mul_M4[3]) == 128.0f); + + /* + [ 1+1.%i 4+4.%i ] * [ 1+1.%i 3+3.%i 5+5.%i ] = [ 18.%i 38.%i 58.%i ] + [ 2+2.%i 5+5.%i ] [ 2+2.%i 4+4.%i 6+6.%i ] [ 24.%i 52.%i 80.%i ] + [ 3+3.%i 6+6.%i ] [ 30.%i 66.%i 102.%i ] + */ + cmulma(M3, 3, 2, M4, 2, 3, miscM3_mul_M4); + for (i = 0; i < 9; ++i) + { + printf("miscM3_mul_M4[%d] = %e + %e i\n", i, creals(miscM3_mul_M4[i]), cimags(miscM3_mul_M4[i])); + } + for (i = 0; i < 9; ++i) + { + assert(creals(miscM3_mul_M4[i]) == 0.0); + } + assert(cimags(miscM3_mul_M4[0]) == 18.0); + assert(cimags(miscM3_mul_M4[1]) == 24.0); + assert(cimags(miscM3_mul_M4[2]) == 30.0); + assert(cimags(miscM3_mul_M4[3]) == 38.0); + assert(cimags(miscM3_mul_M4[4]) == 52.0); + assert(cimags(miscM3_mul_M4[5]) == 66.0); + assert(cimags(miscM3_mul_M4[6]) == 58.0); + assert(cimags(miscM3_mul_M4[7]) == 80.0); + assert(cimags(miscM3_mul_M4[8]) == 102.0); + +} + +static void smulmaTest(void) { + float M1[4] = {1.0f, 2.0f, 3.0f, 4.0f}; + float M2[4] = {1.0f, 2.0f, 3.0f, 4.0f}; + float M1_by_M2[4]; + float M3[4] = {1.0f, 0.0f, 1.0f, 0.0f}; + float M4[4] = {0.0f, 1.0f, 0.0f, 1.0f}; + float M3_by_M4[4]; + float M5[4] = {1.0f, 0.0f, 0.0f, 1.0f}; + float M6[4] = {42.0f, 51.0f, 69.0f, 1664.0f}; + float M5_by_M6[4]; + float M7[6] = {1.0f, 4.0f, 2.0f, 5.0f, 3.0f, 6.0f}; + float M8[6] = {1.0f, 3.0f, 5.0f, 2.0f, 4.0f, 6.0f}; + float M7_by_M8[4]; + float miscM7_by_M8[9]; + + int i = 0; + + printf("\n>>>> Matrix Float Multiplication Tests\n"); + /* + [ 1 3 ] * [ 1 3 ] = [ 7 15 ] + [ 2 4 ] [ 2 4 ] [10 22 ] + */ + smulma(M1, 2, 2, M2, 2, 2, M1_by_M2); + for (i = 0; i < 4; ++i) { + printf("M1_by_M2[%d] = %e\n", i, M1_by_M2[i]); + } + assert(M1_by_M2[0] == 7.0f); + assert(M1_by_M2[1] == 10.0f); + assert(M1_by_M2[2] == 15.0f); + assert(M1_by_M2[3] == 22.0f); + /* + [ 1 1 ] * [ 0 0 ] = [ 1 1 ] + [ 0 0 ] [ 1 1 ] [ 0 0 ] + */ + smulma(M3, 2, 2, M4, 2, 2, M3_by_M4); + for (i = 0; i < 4; ++i) { + printf("M3_by_M4[%d] = %e\n", i, M3_by_M4[i]); + } + assert(M3_by_M4[0] == 1.0f); + assert(M3_by_M4[1] == 0.0f); + assert(M3_by_M4[2] == 1.0f); + assert(M3_by_M4[3] == 0.0f); + + /* + [ 1 0 ] * [ 42 69 ] = [ 42 69 ] + [ 0 1 ] [ 51 1664 ] [ 51 1664 ] + */ + smulma(M5, 2, 2, M6, 2, 2, M5_by_M6); + for (i = 0; i < 4; ++i) { + printf("M5_by_M6[%d] = %e\n", i, M5_by_M6[i]); + } + assert(M5_by_M6[0] == 42.0f); + assert(M5_by_M6[1] == 51.0f); + assert(M5_by_M6[2] == 69.0f); + assert(M5_by_M6[3] == 1664.0f); + + /* + [ 1 2 3 ] * [ 1 2 ] = [ 22 28 ] + [ 4 5 6 ] [ 3 4 ] [ 49 64 ] + [ 5 6 ] + */ + smulma(M7, 2, 3, M8, 3, 2, M7_by_M8); + for (i = 0; i < 4; ++i) { + printf("M7_by_M8[%d] = %e\n", i, M7_by_M8[i]); + } + assert(M7_by_M8[0] == 22.0f); + assert(M7_by_M8[1] == 49.0f); + assert(M7_by_M8[2] == 28.0f); + assert(M7_by_M8[3] == 64.0f); + + /* + [ 1 5 ] * [ 1 5 4 ] = [ 16 15 34 ] + [ 4 3 ] [ 3 2 6 ] [ 13 26 34 ] + [ 2 6 ] [ 20 22 44 ] + */ + smulma(M7, 3, 2, M8, 2, 3, miscM7_by_M8); + for (i = 0; i < 9; ++i) { + printf("miscM7_by_M8[%d] = %e\n", i, miscM7_by_M8[i]); + } + assert(miscM7_by_M8[0] == 16.0f); + assert(miscM7_by_M8[1] == 13.0f); + assert(miscM7_by_M8[2] == 20.0f); + assert(miscM7_by_M8[3] == 15.0f); + assert(miscM7_by_M8[4] == 26.0f); + assert(miscM7_by_M8[5] == 22.0f); + assert(miscM7_by_M8[6] == 34.0f); + assert(miscM7_by_M8[7] == 34.0f); + assert(miscM7_by_M8[8] == 44.0f); + +} + +int testFloatMultiplication(void) { + + printf("\n>>>> Matrix Multiplication Tests\n"); + smulmaTest(); + cmulmaTest(); + + return 0; +} -- cgit