Skip to content
This repository
Browse code

created eclipse project for linux editing.

added rubbish makefile.
  • Loading branch information...
commit e9130f6fc6f9e2dde28123cff7876d786f31ce9a 1 parent a4d6e66
eagle2com authored February 22, 2012
43  LaplaceInverse/src/.cproject
... ...
@@ -0,0 +1,43 @@
  1
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
  2
+<?fileVersion 4.0.0?>
  3
+
  4
+<cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
  5
+	<storageModule moduleId="org.eclipse.cdt.core.settings">
  6
+		<cconfiguration id="cdt.managedbuild.toolchain.gnu.base.1199017521">
  7
+			<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.toolchain.gnu.base.1199017521" moduleId="org.eclipse.cdt.core.settings" name="Default">
  8
+				<externalSettings/>
  9
+				<extensions>
  10
+					<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
  11
+					<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
  12
+					<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
  13
+					<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
  14
+					<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
  15
+					<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
  16
+				</extensions>
  17
+			</storageModule>
  18
+			<storageModule moduleId="cdtBuildSystem" version="4.0.0">
  19
+				<configuration buildProperties="" id="cdt.managedbuild.toolchain.gnu.base.1199017521" name="Default" parent="org.eclipse.cdt.build.core.emptycfg">
  20
+					<folderInfo id="cdt.managedbuild.toolchain.gnu.base.1199017521.89176298" name="/" resourcePath="">
  21
+						<toolChain id="cdt.managedbuild.toolchain.gnu.base.951409654" name="cdt.managedbuild.toolchain.gnu.base" superClass="cdt.managedbuild.toolchain.gnu.base">
  22
+							<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="cdt.managedbuild.target.gnu.platform.base.899118860" name="Debug Platform" osList="linux,hpux,aix,qnx" superClass="cdt.managedbuild.target.gnu.platform.base"/>
  23
+							<builder id="cdt.managedbuild.target.gnu.builder.base.1406296717" managedBuildOn="false" name="Gnu Make Builder.Default" superClass="cdt.managedbuild.target.gnu.builder.base"/>
  24
+							<tool id="cdt.managedbuild.tool.gnu.archiver.base.999869069" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/>
  25
+							<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.base.2112753375" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.base"/>
  26
+							<tool id="cdt.managedbuild.tool.gnu.c.compiler.base.682725869" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.base"/>
  27
+							<tool id="cdt.managedbuild.tool.gnu.c.linker.base.1458799066" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.base"/>
  28
+							<tool id="cdt.managedbuild.tool.gnu.cpp.linker.base.1514450264" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.base"/>
  29
+							<tool id="cdt.managedbuild.tool.gnu.assembler.base.676567158" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.base"/>
  30
+						</toolChain>
  31
+					</folderInfo>
  32
+				</configuration>
  33
+			</storageModule>
  34
+			<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
  35
+		</cconfiguration>
  36
+	</storageModule>
  37
+	<storageModule moduleId="cdtBuildSystem" version="4.0.0">
  38
+		<project id="src.null.1399486196" name="src"/>
  39
+	</storageModule>
  40
+	<storageModule moduleId="scannerConfiguration">
  41
+		<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
  42
+	</storageModule>
  43
+</cproject>
2  LaplaceInverse/src/.gitignore
... ...
@@ -0,0 +1,2 @@
  1
+/*.o
  2
+/*.out
79  LaplaceInverse/src/.project
... ...
@@ -0,0 +1,79 @@
  1
+<?xml version="1.0" encoding="UTF-8"?>
  2
+<projectDescription>
  3
+	<name>src</name>
  4
+	<comment></comment>
  5
+	<projects>
  6
+	</projects>
  7
+	<buildSpec>
  8
+		<buildCommand>
  9
+			<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
  10
+			<triggers>clean,full,incremental,</triggers>
  11
+			<arguments>
  12
+				<dictionary>
  13
+					<key>?name?</key>
  14
+					<value></value>
  15
+				</dictionary>
  16
+				<dictionary>
  17
+					<key>org.eclipse.cdt.make.core.append_environment</key>
  18
+					<value>true</value>
  19
+				</dictionary>
  20
+				<dictionary>
  21
+					<key>org.eclipse.cdt.make.core.autoBuildTarget</key>
  22
+					<value>all</value>
  23
+				</dictionary>
  24
+				<dictionary>
  25
+					<key>org.eclipse.cdt.make.core.buildArguments</key>
  26
+					<value></value>
  27
+				</dictionary>
  28
+				<dictionary>
  29
+					<key>org.eclipse.cdt.make.core.buildCommand</key>
  30
+					<value>make</value>
  31
+				</dictionary>
  32
+				<dictionary>
  33
+					<key>org.eclipse.cdt.make.core.cleanBuildTarget</key>
  34
+					<value>clean</value>
  35
+				</dictionary>
  36
+				<dictionary>
  37
+					<key>org.eclipse.cdt.make.core.contents</key>
  38
+					<value>org.eclipse.cdt.make.core.activeConfigSettings</value>
  39
+				</dictionary>
  40
+				<dictionary>
  41
+					<key>org.eclipse.cdt.make.core.enableAutoBuild</key>
  42
+					<value>false</value>
  43
+				</dictionary>
  44
+				<dictionary>
  45
+					<key>org.eclipse.cdt.make.core.enableCleanBuild</key>
  46
+					<value>true</value>
  47
+				</dictionary>
  48
+				<dictionary>
  49
+					<key>org.eclipse.cdt.make.core.enableFullBuild</key>
  50
+					<value>true</value>
  51
+				</dictionary>
  52
+				<dictionary>
  53
+					<key>org.eclipse.cdt.make.core.fullBuildTarget</key>
  54
+					<value>all</value>
  55
+				</dictionary>
  56
+				<dictionary>
  57
+					<key>org.eclipse.cdt.make.core.stopOnError</key>
  58
+					<value>true</value>
  59
+				</dictionary>
  60
+				<dictionary>
  61
+					<key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
  62
+					<value>true</value>
  63
+				</dictionary>
  64
+			</arguments>
  65
+		</buildCommand>
  66
+		<buildCommand>
  67
+			<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
  68
+			<triggers>full,incremental,</triggers>
  69
+			<arguments>
  70
+			</arguments>
  71
+		</buildCommand>
  72
+	</buildSpec>
  73
+	<natures>
  74
+		<nature>org.eclipse.cdt.core.cnature</nature>
  75
+		<nature>org.eclipse.cdt.core.ccnature</nature>
  76
+		<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
  77
+		<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
  78
+	</natures>
  79
+</projectDescription>
2  LaplaceInverse/src/LinearSystem.cpp
... ...
@@ -1,5 +1,7 @@
1 1
 #include "LinearSystem.h"
2 2
 #include <iostream>
  3
+#include <cstdlib>
  4
+#include <cstring>
3 5
 using namespace std;
4 6
 
5 7
 LinearSystem::LinearSystem(int size):m_size(size),m_null_coefs(0)
3  LaplaceInverse/src/Makefile
... ...
@@ -0,0 +1,3 @@
  1
+
  2
+all:
  3
+	g++ Literal.cpp LiteralElement.cpp LinearSystem.cpp TransferFunction.cpp main.cpp
18  LaplaceInverse/src/Makefile~
... ...
@@ -0,0 +1,18 @@
  1
+
  2
+all: main.o TransferFunction.o
  3
+	g++ main.o LiteralElement.o Literal.o LinearSystem.o TransferFunction.o -o main.x
  4
+	
  5
+main.o: main.cpp
  6
+	g++ -c main.cpp -o main.o
  7
+
  8
+Literal.o: Literal.cpp Literal.h
  9
+	g++ Literal.cpp -o Literal.o
  10
+	
  11
+LiteralElement.o: LiteralElement.cpp LiteralElement.h Literal.o
  12
+	g++ -c LiteralElement.cpp -o LiteralElement.o
  13
+	
  14
+LinearSystem.o: LinearSystem.cpp LinearSystem.h LiteralElement.o Literal.o
  15
+	g++ -c LinearSystem.cpp -o LinearSystem.o
  16
+	
  17
+TransferFunction.o: TransferFunction.cpp TransferFunction.h LiteralElement.o Literal.o LinearSystem.o
  18
+	g++ -c TransferFunction.cpp -o TransferFunction.o
11  LaplaceInverse/src/TransferFunction.cpp
... ...
@@ -1,6 +1,8 @@
1 1
 #include "TransferFunction.h"
2  
-#include <iostream>
3 2
 #include <fstream>
  3
+#include <ios>
  4
+#include <iostream>
  5
+#include <cstdlib>
4 6
 #include "LinearSystem.h"
5 7
 using namespace std;
6 8
 
@@ -32,11 +34,12 @@ void TransferFunction::Clean(void)
32 34
 void TransferFunction::LoadFromFile(string filename)
33 35
 {
34 36
 	Clean();
35  
-	ifstream in_stream(filename);
  37
+	ifstream in_stream(filename.c_str());
  38
+
36 39
 	if(!in_stream)
37 40
 	{
38 41
 		cout << "Could not open: "<<filename<<endl;
39  
-		return ;
  42
+		exit(1) ;
40 43
 	}
41 44
 	cout << "Opened "<<filename<<endl;
42 45
 	int n_num, n_denom,max_power;
@@ -221,4 +224,4 @@ void TransferFunction::FindFactors(void)
221 224
 		correct_factors[i*2] = factors[index*2 - 2];
222 225
 	}
223 226
 
224  
-}
  227
+}
224  LaplaceInverse/src/TransferFunction.cpp~
... ...
@@ -0,0 +1,224 @@
  1
+#include "TransferFunction.h"
  2
+#include <iostream>
  3
+#include <fstream>
  4
+#include "LinearSystem.h"
  5
+using namespace std;
  6
+
  7
+TransferFunction::TransferFunction(void):factors(NULL),correct_factors(NULL)
  8
+{
  9
+	
  10
+}
  11
+
  12
+void TransferFunction::AddNum(void)
  13
+{
  14
+	cout << "Adding numerator"<<endl;
  15
+	numerator.push_back(new LiteralElement(true));
  16
+	numerator.back()->Print();
  17
+	cout<<endl;
  18
+}
  19
+
  20
+void TransferFunction::Clean(void)
  21
+{
  22
+	for(int i = 0; i < numerator.size();i++)
  23
+	{
  24
+		delete numerator[i];
  25
+	}
  26
+	for(int i = 0; i < denominator.size();i++)
  27
+	{
  28
+		delete denominator[i];
  29
+	}
  30
+}
  31
+
  32
+void TransferFunction::LoadFromFile(string filename)
  33
+{
  34
+	Clean();
  35
+	ifstream in_stream(filename,ios::read);
  36
+	if(!in_stream)
  37
+	{
  38
+		cout << "Could not open: "<<filename<<endl;
  39
+		return ;
  40
+	}
  41
+	cout << "Opened "<<filename<<endl;
  42
+	int n_num, n_denom,max_power;
  43
+	long double coef;
  44
+	in_stream >> n_num;
  45
+	cout << "Found "<<n_num<<" numerator factors"<<endl;
  46
+	for(int num = 0; num < n_num; num++)
  47
+	{
  48
+		LiteralElement* new_num = new LiteralElement();
  49
+		in_stream >> max_power;
  50
+		for(int pow = max_power;pow >= 0;pow--)
  51
+		{
  52
+			in_stream >> coef;
  53
+			new_num->Add(new Literal(coef,pow));
  54
+		}
  55
+		numerator.push_back(new_num);
  56
+	}
  57
+
  58
+	in_stream >> n_num;
  59
+	cout << "Found "<<n_num<<" denominator factors"<<endl;
  60
+	for(int num = 0; num < n_num; num++)
  61
+	{
  62
+		LiteralElement* new_num = new LiteralElement();
  63
+		in_stream >> max_power;
  64
+		for(int pow = max_power;pow >= 0;pow--)
  65
+		{
  66
+			in_stream >> coef;
  67
+			new_num->Add(new Literal(coef,pow));
  68
+		}
  69
+		denominator.push_back(new_num);
  70
+	}
  71
+	in_stream.close();
  72
+}
  73
+
  74
+void TransferFunction::Interactive(void)
  75
+{
  76
+	int num,denom;
  77
+	cout << "number of numerator factors: ";
  78
+	cin >> num;
  79
+	for(int i = 0; i < num; i++)
  80
+	{
  81
+		AddNum();
  82
+	}
  83
+
  84
+	cout << "number of denominator factors: ";
  85
+	cin >> denom;
  86
+	for(int i = 0; i < denom; i++)
  87
+	{
  88
+		AddDenom();
  89
+	}
  90
+}
  91
+
  92
+void TransferFunction::AddDenom(void)
  93
+{
  94
+	cout << "Adding denominator"<<endl;
  95
+	denominator.push_back(new LiteralElement(true));
  96
+	denominator.back()->Print();
  97
+	cout<<endl;
  98
+}
  99
+
  100
+
  101
+void TransferFunction::PrintFactors(void)
  102
+{
  103
+	cout << "[ ";
  104
+	for(int i = 0; i < denominator.size()*2-1; i++)
  105
+	{
  106
+		cout << correct_factors[i] << " | ";
  107
+	}
  108
+
  109
+	cout << correct_factors[denominator.size()*2-1]<<" ]";
  110
+}
  111
+
  112
+void TransferFunction::NicePrintFactors(void)
  113
+{
  114
+	cout << endl;
  115
+	for(int i = 0; i < denominator.size(); i++)
  116
+	{
  117
+		LiteralElement e;
  118
+		int index = denominator.size() - i;
  119
+		e.Add(new Literal(factors[index*2 - 1],0));
  120
+		e.Add(new Literal(factors[index*2 - 2],1));
  121
+		e.Print();cout<<"/";denominator[i]->Print();cout <<" + ";
  122
+	}
  123
+	cout << endl;
  124
+}
  125
+
  126
+
  127
+TransferFunction::~TransferFunction(void)
  128
+{
  129
+	Clean();
  130
+}
  131
+
  132
+void TransferFunction::FindFactors(void)
  133
+{
  134
+	LiteralElement* final_numerator = new LiteralElement();
  135
+	final_numerator->Add(new Literal(1,0));
  136
+	for(int i = 0; i < numerator.size();i++)
  137
+	{
  138
+		final_numerator = final_numerator->Multiply(numerator[i]);
  139
+	}
  140
+
  141
+	//cout << "Expanded numerator: ";final_numerator->Print(); cout << endl;
  142
+	cout << "Numerator: ";
  143
+	for(int i = 0; i < numerator.size(); i++)
  144
+		numerator[i]->Print();
  145
+	cout << endl;
  146
+	cout << "Denominator: ";
  147
+	for(int i = 0; i < denominator.size(); i++)
  148
+		denominator[i]->Print();
  149
+	cout << endl;
  150
+	//cout << "We will need "<<denominator.size()<<" coefficients"<<endl;
  151
+	LinearSystem linear_system(denominator.size()*2);
  152
+
  153
+	
  154
+	ElementVec elems(denominator.size());
  155
+	for(int i = 0 ; i < elems.size() ; i++)
  156
+	{
  157
+		elems[i] = new LiteralElement();
  158
+		elems[i]->Add(new Literal(1,0));
  159
+	}
  160
+
  161
+	for(int current_factor = 0; current_factor < denominator.size(); current_factor++)
  162
+	{
  163
+		for(int i = 0; i < denominator.size();i++) // create the expanded factor for a "As + B" coef
  164
+		{
  165
+			if(i == current_factor) // we want to exclude the current factor, obviously
  166
+				continue;
  167
+			elems[i] = elems[i]->Multiply(denominator[i]);
  168
+		}
  169
+	}
  170
+
  171
+	Literal* temp = NULL;
  172
+	for(int i = 0; i < denominator.size(); i++) // we loop through every expanded factor
  173
+	{
  174
+		for(int pow = 0; pow < denominator.size()*2;pow++)
  175
+		{
  176
+			temp = elems[i]->Get(pow);
  177
+			if(!temp)
  178
+				continue;
  179
+			
  180
+			linear_system.Add(pow+1,i*2,temp->coef); //factor multiplied by As, power increases by 1
  181
+			linear_system.Add(pow,i*2+1,temp->coef); // factor multiplied by B
  182
+		}
  183
+		if(denominator[i]->GetMaxPower() < 2)
  184
+			linear_system.SetNullCoefs(i*2);
  185
+	}
  186
+
  187
+	for(int i = 0; i <= final_numerator->GetMaxPower(); i++)
  188
+	{
  189
+		Literal* b_elem = final_numerator->Get(i);
  190
+		if(b_elem)
  191
+		{
  192
+			//cout << "Setting b_coef "<<b_elem->coef<<endl;
  193
+			linear_system.Set(i,denominator.size()*2,b_elem->coef);
  194
+		}
  195
+	}
  196
+	
  197
+	cout << "Before solving:"<<endl;
  198
+	linear_system.Print();
  199
+	linear_system.Solve();
  200
+	cout << "After solving:"<<endl;
  201
+	linear_system.Print();
  202
+	
  203
+	if(correct_factors)
  204
+		delete[] correct_factors;
  205
+
  206
+	if(factors)
  207
+		delete[] factors;
  208
+
  209
+	correct_factors = new long double[denominator.size()*2];
  210
+	factors = new long double[denominator.size()*2];
  211
+	for(int i = 0; i < denominator.size()*2;i++)
  212
+	{
  213
+		factors[i] = linear_system.GetCoef(i);
  214
+	}
  215
+
  216
+
  217
+	for(int i = 0; i < denominator.size(); i++)
  218
+	{
  219
+		int index = denominator.size() - i;
  220
+		correct_factors[i*2+1] = factors[index*2 - 1];
  221
+		correct_factors[i*2] = factors[index*2 - 2];
  222
+	}
  223
+
  224
+}
1  LaplaceInverse/src/test.txt
... ...
@@ -0,0 +1 @@
  1
+1 0 2 2 1 1 1 1 1 4
11  Makefile
... ...
@@ -0,0 +1,11 @@
  1
+
  2
+all: main.o
  3
+
  4
+Literal.o: Literal.cpp Literal.h
  5
+	g++ Literal.cpp -o Literal.o
  6
+	
  7
+LiteralElement.o: LiteralElement.cpp LiteralElement.h Literal.o
  8
+	g++ LiteralElement.cpp Literal.o -o LiteralElement.o
  9
+	
  10
+LinearSystem.o: LinearSystem.cpp LinearSystem.h LiteralElement.o Literal.o
  11
+	g++ LinearSystem.cpp LiteralElement.o Literal.o -o LinearSystem.o
10  Makefile~
... ...
@@ -0,0 +1,10 @@
  1
+
  2
+all: main.o
  3
+
  4
+Literal.o: Literal.cpp Literal.h
  5
+	g++ Literal.cpp -o Literal.o
  6
+	
  7
+LiteralElement.o: LiteralElement.cpp LiteralElement.h Literal.o
  8
+	g++ LiteralElement.cpp Literal.o -o LiteralElement.o
  9
+	
  10
+LinearSystem.o: LinearSystem.cpp LinearSystem.h LiteralElement.o Literal.o

0 notes on commit e9130f6

Please sign in to comment.
Something went wrong with that request. Please try again.