*
*/
-#include <matrix.h>
+#ifdef _MATRIX_H
template <typename TYPE>
matrix<TYPE>::matrix(void)
{
-
+ m_mat = NULL;
}
template <typename TYPE>
matrix<TYPE>::matrix(const int rows, const int cols)
{
+ m_rows = rows;
+ m_cols = cols;
+ m_mat = NULL;
+ m_mat = new TYPE *[m_rows];
+ for (int i = 0; i < m_rows; i++)
+ m_mat[i] = new TYPE [m_cols];
}
template <typename TYPE>
-matrix<TYPE>::matrix(const int rows, const int cols, TYPE **mat_data)
+matrix<TYPE>::matrix(const matrix<TYPE>& m)
{
+ m_rows = m.m_rows;
+ m_cols = m.m_cols;
+ m_mat = NULL;
+ m_mat = new TYPE *[m_rows];
+
+ for (int i = 0; i < m_rows; i++)
+ m_mat[i] = new TYPE [m_cols];
+ for (int p = 0; p < m_rows; p++)
+ for (int q = 0; q < m_cols; q++)
+ m_mat[p][q] = m.m_mat[p][q];
}
template <typename TYPE>
-matrix<TYPE>::matrix(const matrix<TYPE>& m)
+matrix<TYPE>::matrix(const int rows, const int cols, TYPE *mat_data)
{
+ m_rows = rows;
+ m_cols = cols;
+ m_mat = NULL;
+ m_mat = new TYPE *[m_rows];
+
+ for (int i = 0; i < m_rows; i++)
+ m_mat[i] = new TYPE [m_cols];
+ for (int i = 0; i < m_rows; i++)
+ for (int j = 0; j < m_cols; j++)
+ m_mat[i][j] = *mat_data++;
}
template <typename TYPE>
matrix<TYPE>::~matrix()
{
-
+ for (int i = 0; i < m_rows; i++)
+ delete[] m_mat[i];
+ delete[] m_mat;
}
template <typename TYPE>
matrix<TYPE> matrix<TYPE>::operator =(const matrix<TYPE>& m)
{
+ if (this == &m)
+ {
+ return *this;
+ }
+
+ for (int i = 0; i < m_rows; i++)
+ delete[] m_mat[i];
+ delete[] m_mat;
+
+ m_rows = m.m_rows;
+ m_cols = m.m_cols;
+ m_mat = new TYPE *[m_rows];
+
+ for (int i = 0; i < m_rows; i++)
+ m_mat[i] = new TYPE [m_cols];
+ for (int p = 0; p < m_rows; p++)
+ for (int q = 0; q < m_cols; q++)
+ m_mat[p][q] = m.m_mat[p][q];
+
+ return *this;
}
-template <typename TYPE>
-matrix<TYPE> operator +(const matrix<TYPE> m1, const matrix<TYPE> m2)
+template <typename T>
+ostream& operator <<(ostream& dout, matrix<T>& m)
{
-
+ for (int i = 0; i < m.m_rows; i++)
+ {
+ for (int j = 0; j < m.m_cols; j++)
+ {
+ dout << m.m_mat[i][j] << "\t";
+ }
+ dout << endl;
+ }
+ return dout;
}
-template <typename TYPE>
-matrix<TYPE> operator +(const matrix<TYPE> m, const TYPE val)
+template <typename T>
+matrix<T> operator +(const matrix<T> m1, const matrix<T> m2)
{
+ assert(m1.m_rows == m2.m_rows);
+ assert(m1.m_cols == m2.m_cols);
+
+ matrix<T> m3(m1.m_rows, m1.m_cols);
+ for (int i = 0; i < m1.m_rows; i++)
+ for (int j = 0; j < m1.m_cols; j++)
+ m3.m_mat[i][j] = m1.m_mat[i][j] + m2.m_mat[i][j];
+
+ return m3;
}
-template <typename TYPE>
-matrix<TYPE> operator -(const matrix<TYPE> m1, const matrix<TYPE> m2)
+template <typename T>
+matrix<T> operator +(const matrix<T> m, const T val)
{
+ matrix<T> m1(m.m_rows, m.m_cols);
+ for (int i = 0; i < m.m_rows; i++)
+ for (int j = 0; j < m.m_cols; j++)
+ m1.m_mat[i][j] = m.m_mat[i][j] + val;
+
+ return m1;
}
-template <typename TYPE>
-matrix<TYPE> operator -(const matrix<TYPE> m, const TYPE val)
+template <typename T>
+matrix<T> operator -(const matrix<T> m1, const matrix<T> m2)
{
+ assert(m1.m_rows == m2.m_rows);
+ assert(m1.m_cols == m2.m_cols);
+ matrix<T> m3(m1.m_rows, m1.m_cols);
+
+ for (int i = 0; i < m1.m_rows; i++)
+ for (int j = 0; j < m1.m_cols; j++)
+ m3.m_mat[i][j] = m1.m_mat[i][j] - m2.m_mat[i][j];
+
+ return m3;
}
-template <typename TYPE>
-matrix<TYPE> operator *(const matrix<TYPE> m1, const matrix<TYPE> m2)
+template <typename T>
+matrix<T> operator -(const matrix<T> m, const T val)
{
+ matrix<T> m1(m.m_rows, m.m_cols);
+ for (int i = 0; i < m.m_rows; i++)
+ for (int j = 0; j < m.m_cols; j++)
+ m1.m_mat[i][j] = m.m_mat[i][j] - val;
+
+ return m1;
}
-template <typename TYPE>
-matrix<TYPE> operator *(const matrix<TYPE> m, const TYPE val)
+template <typename T>
+matrix<T> operator *(const matrix<T> m1, const matrix<T> m2)
{
+ assert(m1.m_rows == m2.m_cols);
+ assert(m1.m_cols == m2.m_rows);
+ matrix<T> m3(m1.m_rows, m2.m_cols);
+
+ for (int i = 0; i < m1.m_rows; i++)
+ {
+ for (int j = 0; j < m2.m_cols; j++)
+ {
+ m3.m_mat[i][j] = 0;
+ for (int k = 0; k < m2.m_rows; k++)
+ m3.m_mat[i][j] += m1.m_mat[i][k] * m2.m_mat[k][j];
+ }
+ }
+
+ return m3;
}
-template <typename TYPE>
-matrix<TYPE> operator /(const matrix<TYPE> m1, const matrix<TYPE> m2)
+template <typename T>
+matrix<T> operator *(const matrix<T> m, const T val)
{
+ matrix<T> m1(m.m_rows, m.m_cols);
+
+ for (int i = 0; i < m.m_rows; i++)
+ for (int j = 0; j < m.m_cols; j++)
+ m1.m_mat[i][j] = m.m_mat[i][j] * val;
+ return m1;
}
-template <typename TYPE>
-bool operator ==(const matrix<TYPE> m1, const matrix<TYPE> m2)
+template <typename T>
+matrix<T> operator /(const matrix<T> m1, const T val)
{
+ matrix<T> m3(m1.m_rows, m1.m_cols);
+
+ for (int i = 0; i < m1.m_rows; i++)
+ for (int j = 0; j < m1.m_cols; j++)
+ m3.m_mat[i][j] = m1.m_mat[i][j] / val;
+ return m3;
}
-template <typename TYPE>
-bool operator !=(const matrix<TYPE> m1, const matrix<TYPE> m2)
+template <typename T>
+bool operator ==(const matrix<T> m1, const matrix<T> m2)
{
+ if ((m1.m_rows == m2.m_rows) && (m1.m_cols == m2.m_cols))
+ {
+ for (int i = 0; i < m1.m_rows; i++)
+ for (int j = 0; j < m2.m_cols; j++)
+ if (m1.m_mat[i][j] != m2.m_mat[i][j])
+ return false;
+ }
+ else
+ return false;
+ return true;
}
+template <typename T>
+bool operator !=(const matrix<T> m1, const matrix<T> m2)
+{
+ return (!(m1 == m2));
+}
-template <typename TYPE>
-matrix<TYPE> matrix<TYPE>::transpose(const matrix<TYPE> m)
+template <typename T>
+matrix<T> transpose(const matrix<T> m)
{
+ matrix<T> m1(m.m_cols, m.m_rows);
+ for (int i = 0; i < m.m_rows; i++)
+ for (int j = 0; j < m.m_cols; j++)
+ m1.m_mat[j][i] = m.m_mat[i][j];
+
+ return m1;
}
+
+#endif //_MATRIX_H
#ifndef _MATRIX_H
#define _MATRIX_H
+#include <assert.h>
+#include <iostream>
+using namespace std;
+
template <typename TYPE>
class matrix {
public:
matrix(void);
matrix(const int rows, const int cols);
- matrix(const int rows, const int cols, TYPE **mat_data);
+ matrix(const int rows, const int cols, TYPE *mat_data);
matrix(const matrix<TYPE>& m);
~matrix();
matrix<TYPE> operator =(const matrix<TYPE>& m);
- friend matrix<TYPE> operator +(const matrix<TYPE> m1, const matrix<TYPE> m2);
- friend matrix<TYPE> operator +(const matrix<TYPE> m, const TYPE val);
- friend matrix<TYPE> operator -(const matrix<TYPE> m1, const matrix<TYPE> m2);
- friend matrix<TYPE> operator -(const matrix<TYPE> m, const TYPE val);
- friend matrix<TYPE> operator *(const matrix<TYPE> m1, const matrix<TYPE> m2);
- friend matrix<TYPE> operator *(const matrix<TYPE> m, const TYPE val);
- friend matrix<TYPE> operator /(const matrix<TYPE> m1, const matrix<TYPE> m2);
- friend bool operator ==(const matrix<TYPE> m1, const matrix<TYPE> m2);
- friend bool operator !=(const matrix<TYPE> m1, const matrix<TYPE> m2);
-
- friend matrix<TYPE> transpose(const matrix<TYPE> m);
+ template<typename T> friend ostream& operator << (ostream& dout,
+ matrix<T>& m);
+ template<typename T> friend matrix<T> operator +(const matrix<T> m1,
+ const matrix<T> m2);
+ template<typename T> friend matrix<T> operator +(const matrix<T> m,
+ const T val);
+ template<typename T> friend matrix<T> operator -(const matrix<T> m1,
+ const matrix<T> m2);
+ template<typename T> friend matrix<T> operator -(const matrix<T> m,
+ const T val);
+ template<typename T> friend matrix<T> operator *(const matrix<T> m1,
+ const matrix<T> m2);
+ template<typename T> friend matrix<T> operator *(const matrix<T> m,
+ const T val);
+ template<typename T> friend matrix<T> operator /(const matrix<T> m1,
+ const T val);
+ template<typename T> friend bool operator ==(const matrix<T> m1,
+ const matrix<T> m2);
+ template<typename T> friend bool operator !=(const matrix<T> m1,
+ const matrix<T> m2);
+ template<typename T> friend matrix<T> transpose(const matrix<T> m);
};
+#include "matrix.cpp"
+
#endif //_MATRIX_H
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
+ <storageModule moduleId="org.eclipse.cdt.core.settings">
+ <cconfiguration id="cdt.managedbuild.config.gnu.exe.debug.1947039627">
+ <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.exe.debug.1947039627" moduleId="org.eclipse.cdt.core.settings" name="Debug">
+ <externalSettings/>
+ <extensions>
+ <extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
+ <extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ </extensions>
+ </storageModule>
+ <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+ <configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.exe.debug.1947039627" name="Debug" parent="cdt.managedbuild.config.gnu.exe.debug">
+ <folderInfo id="cdt.managedbuild.config.gnu.exe.debug.1947039627." name="/" resourcePath="">
+ <toolChain id="cdt.managedbuild.toolchain.gnu.exe.debug.1585712654" name="Linux GCC" superClass="cdt.managedbuild.toolchain.gnu.exe.debug">
+ <targetPlatform id="cdt.managedbuild.target.gnu.platform.exe.debug.1937923355" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.exe.debug"/>
+ <builder buildPath="${workspace_loc:/matrix_test/Debug}" id="cdt.managedbuild.target.gnu.builder.exe.debug.2097960191" managedBuildOn="true" name="Gnu Make Builder.Debug" superClass="cdt.managedbuild.target.gnu.builder.exe.debug"/>
+ <tool id="cdt.managedbuild.tool.gnu.archiver.base.1401658236" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/>
+ <tool id="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug.2032678345" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug">
+ <option id="gnu.cpp.compiler.exe.debug.option.optimization.level.39436864" superClass="gnu.cpp.compiler.exe.debug.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
+ <option id="gnu.cpp.compiler.exe.debug.option.debugging.level.572942560" superClass="gnu.cpp.compiler.exe.debug.option.debugging.level" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/>
+ <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.166865979" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
+ </tool>
+ <tool id="cdt.managedbuild.tool.gnu.c.compiler.exe.debug.1525120259" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.exe.debug">
+ <option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.exe.debug.option.optimization.level.1484500606" superClass="gnu.c.compiler.exe.debug.option.optimization.level" valueType="enumerated"/>
+ <option id="gnu.c.compiler.exe.debug.option.debugging.level.1854921709" superClass="gnu.c.compiler.exe.debug.option.debugging.level" value="gnu.c.debugging.level.max" valueType="enumerated"/>
+ <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1789010595" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
+ </tool>
+ <tool id="cdt.managedbuild.tool.gnu.c.linker.exe.debug.391331500" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.exe.debug"/>
+ <tool id="cdt.managedbuild.tool.gnu.cpp.linker.exe.debug.1946566542" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.exe.debug">
+ <inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.402153074" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
+ <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
+ <additionalInput kind="additionalinput" paths="$(LIBS)"/>
+ </inputType>
+ </tool>
+ <tool id="cdt.managedbuild.tool.gnu.assembler.exe.debug.2008886955" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.exe.debug">
+ <inputType id="cdt.managedbuild.tool.gnu.assembler.input.1719697565" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
+ </tool>
+ </toolChain>
+ </folderInfo>
+ </configuration>
+ </storageModule>
+ <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
+ </cconfiguration>
+ <cconfiguration id="cdt.managedbuild.config.gnu.exe.release.42230887">
+ <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.exe.release.42230887" moduleId="org.eclipse.cdt.core.settings" name="Release">
+ <externalSettings/>
+ <extensions>
+ <extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
+ <extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ </extensions>
+ </storageModule>
+ <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+ <configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.exe.release.42230887" name="Release" parent="cdt.managedbuild.config.gnu.exe.release">
+ <folderInfo id="cdt.managedbuild.config.gnu.exe.release.42230887." name="/" resourcePath="">
+ <toolChain id="cdt.managedbuild.toolchain.gnu.exe.release.21073504" name="Linux GCC" superClass="cdt.managedbuild.toolchain.gnu.exe.release">
+ <targetPlatform id="cdt.managedbuild.target.gnu.platform.exe.release.86369109" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.exe.release"/>
+ <builder buildPath="${workspace_loc:/matrix_test/Release}" id="cdt.managedbuild.target.gnu.builder.exe.release.1619759257" managedBuildOn="true" name="Gnu Make Builder.Release" superClass="cdt.managedbuild.target.gnu.builder.exe.release"/>
+ <tool id="cdt.managedbuild.tool.gnu.archiver.base.1842989527" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/>
+ <tool id="cdt.managedbuild.tool.gnu.cpp.compiler.exe.release.1437975361" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.exe.release">
+ <option id="gnu.cpp.compiler.exe.release.option.optimization.level.2064028922" superClass="gnu.cpp.compiler.exe.release.option.optimization.level" value="gnu.cpp.compiler.optimization.level.most" valueType="enumerated"/>
+ <option id="gnu.cpp.compiler.exe.release.option.debugging.level.63959039" superClass="gnu.cpp.compiler.exe.release.option.debugging.level" value="gnu.cpp.compiler.debugging.level.none" valueType="enumerated"/>
+ <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1222094860" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
+ </tool>
+ <tool id="cdt.managedbuild.tool.gnu.c.compiler.exe.release.127727371" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.exe.release">
+ <option defaultValue="gnu.c.optimization.level.most" id="gnu.c.compiler.exe.release.option.optimization.level.1754258748" superClass="gnu.c.compiler.exe.release.option.optimization.level" valueType="enumerated"/>
+ <option id="gnu.c.compiler.exe.release.option.debugging.level.482297656" superClass="gnu.c.compiler.exe.release.option.debugging.level" value="gnu.c.debugging.level.none" valueType="enumerated"/>
+ <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1250093439" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
+ </tool>
+ <tool id="cdt.managedbuild.tool.gnu.c.linker.exe.release.1943137192" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.exe.release"/>
+ <tool id="cdt.managedbuild.tool.gnu.cpp.linker.exe.release.1903612163" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.exe.release">
+ <inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.727299943" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
+ <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
+ <additionalInput kind="additionalinput" paths="$(LIBS)"/>
+ </inputType>
+ </tool>
+ <tool id="cdt.managedbuild.tool.gnu.assembler.exe.release.286417437" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.exe.release">
+ <inputType id="cdt.managedbuild.tool.gnu.assembler.input.2147194562" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
+ </tool>
+ </toolChain>
+ </folderInfo>
+ </configuration>
+ </storageModule>
+ </cconfiguration>
+ </storageModule>
+ <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+ <project id="matrix_test.cdt.managedbuild.target.gnu.exe.1630385542" name="Executable" projectType="cdt.managedbuild.target.gnu.exe"/>
+ </storageModule>
+ <storageModule moduleId="scannerConfiguration">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+ <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.release.42230887;cdt.managedbuild.config.gnu.exe.release.42230887.;cdt.managedbuild.tool.gnu.c.compiler.exe.release.127727371;cdt.managedbuild.tool.gnu.c.compiler.input.1250093439">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
+ </scannerConfigBuildInfo>
+ <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.debug.1947039627;cdt.managedbuild.config.gnu.exe.debug.1947039627.;cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug.2032678345;cdt.managedbuild.tool.gnu.cpp.compiler.input.166865979">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/>
+ </scannerConfigBuildInfo>
+ <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.release.42230887;cdt.managedbuild.config.gnu.exe.release.42230887.;cdt.managedbuild.tool.gnu.cpp.compiler.exe.release.1437975361;cdt.managedbuild.tool.gnu.cpp.compiler.input.1222094860">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/>
+ </scannerConfigBuildInfo>
+ <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.debug.1947039627;cdt.managedbuild.config.gnu.exe.debug.1947039627.;cdt.managedbuild.tool.gnu.c.compiler.exe.debug.1525120259;cdt.managedbuild.tool.gnu.c.compiler.input.1789010595">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
+ </scannerConfigBuildInfo>
+ </storageModule>
+</cproject>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>matrix_test</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
+ <triggers>clean,full,incremental,</triggers>
+ <arguments>
+ <dictionary>
+ <key>?name?</key>
+ <value></value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.append_environment</key>
+ <value>true</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.autoBuildTarget</key>
+ <value>all</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.buildArguments</key>
+ <value></value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.buildCommand</key>
+ <value>make</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.buildLocation</key>
+ <value>${workspace_loc:/matrix_test/Debug}</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.cleanBuildTarget</key>
+ <value>clean</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.contents</key>
+ <value>org.eclipse.cdt.make.core.activeConfigSettings</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.enableAutoBuild</key>
+ <value>false</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.enableCleanBuild</key>
+ <value>true</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.enableFullBuild</key>
+ <value>true</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.fullBuildTarget</key>
+ <value>all</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.stopOnError</key>
+ <value>true</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
+ <value>true</value>
+ </dictionary>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
+ <triggers>full,incremental,</triggers>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.tizen.nativecpp.apichecker.core.builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.cdt.core.cnature</nature>
+ <nature>org.eclipse.cdt.core.ccnature</nature>
+ <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
+ <nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
+ <nature>org.tizen.nativecpp.apichecker.core.tizenCppNature</nature>
+ </natures>
+</projectDescription>
--- /dev/null
+/*
+ * sensord
+ *
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "../../matrix.h"
+
+int main()
+{
+ float arr0[2][2] = {{-2.243, 2.57},{3.56, -3.02}};
+ float arr1[2][2] = {{2.2, 2.5},{3.5, 3.0}};
+ float arr5[3][2] = {{0.22, 4.56}, {3.652, 5.86}, {1.430, 0.45}};
+ float arr11[1][3] = {{2.0, 3.0, 4.0}};
+ float arr12[3][1] = {{2.0}, {1.0}, {3.0}};
+ float arr15[2][3] = {{20.0, -40.0, 10.0}, {36.0, 52.0, -55.0}};
+ float arr3[3][3] = {{20.2, 40.5, 10.0}, {3.6, 52.0, 5.5}, {1.0, 45.5, 66.6}};
+ float arr4[3][3] = {{2.24, 0.5, 0.023}, {3.675, 5.32, 0.556}, {1.023, 45.75, 621.6}};
+ float arr8[3][3] = {{4.75, 0.65, 0.123}, {0.075, 5.302, 0.56}, {1.113, 0.475, 2.362}};
+
+ matrix<float> m1(2, 2, (float *) arr0);
+ matrix<float> m2(2, 2, (float *) arr1);
+ matrix<float> m3(2, 2);
+ matrix<float> m10(3, 3, (float *) arr3);
+ matrix<float> m11(3, 2, (float *) arr5);
+ matrix<float> m6(3, 3);
+ matrix<float> m13(3, 2);
+ matrix<float> m12(3, 3, (float *) arr4);
+ matrix<float> m15(3, 3, (float *) arr8);
+ matrix<float> m20(1, 3, (float *) arr11);
+ matrix<float> m21(3, 1, (float *) arr12);
+ matrix<float> m22(2, 3, (float *) arr15);
+
+ cout<<"Addition\n";
+ m6 = m10 + m15;
+ m13 = m11 + m11;
+ cout<< "\n" << m10 <<"\n"<< m15;
+ cout<< "\nSum:\n" << m6 << endl;
+ cout<< "\n" << m11 << "\n"<< m11;
+ cout<< "\nSum:\n" << m13 << endl;
+
+ cout<< "\n\n\nSubtraction\n";
+ m6 = m10 - m12;
+ cout<< "\n" << m10 << "\n" << m12;
+ cout<< "\nDifference:\n" << m6 << endl;
+
+ cout<< "\n\n\nMultiplication\n";
+ m6 = m10 * m12;
+ m3 = m1 * m2;
+ matrix<float> m7(m20.m_rows, m21.m_cols);
+ m7 = m20 * m21;
+ cout<< "\n" << m10 << "\n" << m12;
+ cout<< "\nProduct:\n" << m6 << endl;
+ cout<< "\n" << m1 << "\n" << m2;
+ cout<< "\nProduct:\n" << m3 << endl;
+ cout<< "\n" << m20 << "\n" << m21;
+ cout<< "\nProduct:\n" << m7 << endl;
+
+ cout<< "\n\n\nDivision\n";
+ m3 = m1 / (float)2.5;
+ cout<< "\n" << m1 << "\n" << "2.5";
+ cout<< "\nResult:\n" << m3 << endl;
+ m6 = m12 / (float)0.125;
+ cout<< "\n" << m12 << "\n" << ".125";
+ cout<< "\nResult:\n" << m6 << endl;
+
+ float num = 5.5650;
+ float num1 = -2.32;
+ cout<< "\n\n\nScalar addition\n";
+ m3 = m2 + num;
+ m6 = m10 + num1;
+ cout<< "\nNumber added:" << num;
+ cout<< "\n\n" << m2;
+ cout<< "\nResult:\n\n" << m3;
+ cout<< "\nNumber added:" << num1;
+ cout<< "\n\n" << m10;
+ cout<< "\nResult:\n\n" << m6;
+
+ float x = 4.0;
+ float x1 = -2.5;
+ cout<< "\n\n\nScalar subtraction\n";
+ m3 = m11 - x;
+ m6 = m10 - x1;
+ cout<< "\nNumber Subtracted:" << x;
+ cout<< "\n\n" << m11;
+ cout<< "\nResult:\n\n" << m3;
+ cout<< "\nNumber Subtracted:" << x1;
+ cout<< "\n\n" << m10;
+ cout<< "\nResult:\n\n" << m6;
+
+ float z = 3.50;
+ float z1 = -5.567;
+ cout<< "\n\n\nScalar multiplication\n";
+ m3 = m1 * z;
+ m6 = m12 * z1;
+ cout<< "\nNumber Multiplied:"<< z;
+ cout<< "\n\n" << m1;
+ cout<< "\nResult:\n\n" << m3;
+ cout<< "\nNumber Multiplied:" << z1;
+ cout<< "\n\n" << m12;
+ cout<< "\nResult:\n\n" << m6;
+
+ m6 = transpose(m15);
+ cout<< "\n\n\nTranspose:";
+ cout << "\n\n" << m15;
+ cout << "\nResult:\n\n" << m6;
+
+ cout << "\n\nm1:\n\n" << m1;
+ cout << "\n\nm2:\n\n" << m2;
+ cout << "\n\n\nm1 == m2 :";
+ cout << (m1 == m2);
+
+ cout << "\n\nm2:\n\n" << m2;
+ cout << "\n\nm2:\n\n" << m2;
+ cout << "\n\n\nm2 == m2 :";
+ cout << (m2 == m2);
+
+ cout << "\n\nm6:\n\n" << m6;
+ cout << "\n\nm6:\n\n" << m6;
+ cout << "\n\n\nm6 != m6 :";
+ cout << (m6 != m6);
+
+ cout << "\n\nm6:\n\n" << m6;
+ cout << "\n\nm1:\n\n" << m1;
+ cout << "\n\n\nm6 != m1 :";
+ cout << (m6 != m1);
+}