홍주원

최종파일

Showing 69 changed files with 848 additions and 0 deletions
1 +
2 +Microsoft Visual Studio Solution File, Format Version 12.00
3 +# Visual Studio 14
4 +VisualStudioVersion = 14.0.25420.1
5 +MinimumVisualStudioVersion = 10.0.40219.1
6 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "constellation", "constellation\constellation.vcxproj", "{6FF25C27-45BF-4502-A1F8-0EFB069E1515}"
7 +EndProject
8 +Global
9 + GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 + Debug|x64 = Debug|x64
11 + Debug|x86 = Debug|x86
12 + Release|x64 = Release|x64
13 + Release|x86 = Release|x86
14 + EndGlobalSection
15 + GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 + {6FF25C27-45BF-4502-A1F8-0EFB069E1515}.Debug|x64.ActiveCfg = Debug|x64
17 + {6FF25C27-45BF-4502-A1F8-0EFB069E1515}.Debug|x64.Build.0 = Debug|x64
18 + {6FF25C27-45BF-4502-A1F8-0EFB069E1515}.Debug|x86.ActiveCfg = Debug|Win32
19 + {6FF25C27-45BF-4502-A1F8-0EFB069E1515}.Debug|x86.Build.0 = Debug|Win32
20 + {6FF25C27-45BF-4502-A1F8-0EFB069E1515}.Release|x64.ActiveCfg = Release|x64
21 + {6FF25C27-45BF-4502-A1F8-0EFB069E1515}.Release|x64.Build.0 = Release|x64
22 + {6FF25C27-45BF-4502-A1F8-0EFB069E1515}.Release|x86.ActiveCfg = Release|Win32
23 + {6FF25C27-45BF-4502-A1F8-0EFB069E1515}.Release|x86.Build.0 = Release|Win32
24 + EndGlobalSection
25 + GlobalSection(SolutionProperties) = preSolution
26 + HideSolutionNode = FALSE
27 + EndGlobalSection
28 +EndGlobal
1 + sender.cpp
2 +c:\users\ghdwn\documents\hong joowon file\경희대\2019-1학기\소프트웨어 랩\과제 8\새 폴더\constellation\constellation\constellation\sender.cpp(42): warning C4244: '=': 'double'에서 'float'(으)로 변환하면서 데이터가 손실될 수 있습니다.
3 +c:\users\ghdwn\documents\hong joowon file\경희대\2019-1학기\소프트웨어 랩\과제 8\새 폴더\constellation\constellation\constellation\sender.cpp(43): warning C4244: '=': 'double'에서 'float'(으)로 변환하면서 데이터가 손실될 수 있습니다.
4 + constellation.vcxproj -> C:\Users\ghdwn\Documents\Hong joowon file\경희대\2019-1학기\소프트웨어 랩\과제 8\새 폴더\constellation\constellation\Debug\constellation.exe
1 +#TargetFrameworkVersion=v4.0:PlatformToolSet=v141:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=10.0.16299.0
2 +Debug|Win32|C:\Users\ghdwn\Documents\Hong joowon file\경희대\2019-1학기\소프트웨어 랩\과제 8\새 폴더\constellation\constellation\|
1 +#include"channel.h"
2 +#include<cstdlib>
3 +using namespace std;
4 +
5 +void Cchannel::AWGN() {
6 + ofstream myout;
7 + myout.open("channel.txt");
8 + //N = 8;
9 + default_random_engine generator;
10 + normal_distribution<double> dist(0.0, N);
11 +
12 +
13 + for (int k = 0; k < Nbits / Nbitspersymbol * Nsamplespersymbol; k++)
14 + n[k] = dist(generator);
15 +
16 + matrixadd(1, Nbits / Nbitspersymbol * Nsamplespersymbol, s, n, r);
17 +
18 + for (int i = 0; i < Nbits / Nbitspersymbol * Nsamplespersymbol; i++)
19 + {
20 +
21 + myout << r[i] << endl;
22 + }
23 +
24 + myout.close();
25 +}
...\ No newline at end of file ...\ No newline at end of file
1 +#ifndef __CHANNEL
2 +
3 +#define __CHANNEL
4 +#include <cmath>
5 +#include <random>
6 +#include "variables.h"
7 +class Cchannel {
8 +public:
9 + Cchannel() {};
10 + float N=8;
11 + float *s; // trasmitted signal
12 + float r[Nbits / Nbitspersymbol*Nsamplespersymbol]; // corrupted signal
13 + float n[Nbits / Nbitspersymbol * Nsamplespersymbol];
14 + void AWGN();
15 +};
16 +#endif
...\ No newline at end of file ...\ No newline at end of file
This diff is collapsed. Click to expand it.
1 +<?xml version="1.0" encoding="utf-8"?>
2 +<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3 + <ItemGroup Label="ProjectConfigurations">
4 + <ProjectConfiguration Include="Debug|Win32">
5 + <Configuration>Debug</Configuration>
6 + <Platform>Win32</Platform>
7 + </ProjectConfiguration>
8 + <ProjectConfiguration Include="Release|Win32">
9 + <Configuration>Release</Configuration>
10 + <Platform>Win32</Platform>
11 + </ProjectConfiguration>
12 + <ProjectConfiguration Include="Debug|x64">
13 + <Configuration>Debug</Configuration>
14 + <Platform>x64</Platform>
15 + </ProjectConfiguration>
16 + <ProjectConfiguration Include="Release|x64">
17 + <Configuration>Release</Configuration>
18 + <Platform>x64</Platform>
19 + </ProjectConfiguration>
20 + </ItemGroup>
21 + <PropertyGroup Label="Globals">
22 + <ProjectGuid>{6FF25C27-45BF-4502-A1F8-0EFB069E1515}</ProjectGuid>
23 + <RootNamespace>constellation</RootNamespace>
24 + <WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>
25 + </PropertyGroup>
26 + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
27 + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
28 + <ConfigurationType>Application</ConfigurationType>
29 + <UseDebugLibraries>true</UseDebugLibraries>
30 + <PlatformToolset>v141</PlatformToolset>
31 + <CharacterSet>MultiByte</CharacterSet>
32 + </PropertyGroup>
33 + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
34 + <ConfigurationType>Application</ConfigurationType>
35 + <UseDebugLibraries>false</UseDebugLibraries>
36 + <PlatformToolset>v141</PlatformToolset>
37 + <WholeProgramOptimization>true</WholeProgramOptimization>
38 + <CharacterSet>MultiByte</CharacterSet>
39 + </PropertyGroup>
40 + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
41 + <ConfigurationType>Application</ConfigurationType>
42 + <UseDebugLibraries>true</UseDebugLibraries>
43 + <PlatformToolset>v141</PlatformToolset>
44 + <CharacterSet>MultiByte</CharacterSet>
45 + </PropertyGroup>
46 + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
47 + <ConfigurationType>Application</ConfigurationType>
48 + <UseDebugLibraries>false</UseDebugLibraries>
49 + <PlatformToolset>v141</PlatformToolset>
50 + <WholeProgramOptimization>true</WholeProgramOptimization>
51 + <CharacterSet>MultiByte</CharacterSet>
52 + </PropertyGroup>
53 + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
54 + <ImportGroup Label="ExtensionSettings">
55 + </ImportGroup>
56 + <ImportGroup Label="Shared">
57 + </ImportGroup>
58 + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
59 + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
60 + </ImportGroup>
61 + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
62 + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
63 + </ImportGroup>
64 + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
65 + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
66 + </ImportGroup>
67 + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
68 + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
69 + </ImportGroup>
70 + <PropertyGroup Label="UserMacros" />
71 + <PropertyGroup />
72 + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
73 + <ClCompile>
74 + <WarningLevel>Level3</WarningLevel>
75 + <Optimization>Disabled</Optimization>
76 + <SDLCheck>true</SDLCheck>
77 + </ClCompile>
78 + </ItemDefinitionGroup>
79 + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
80 + <ClCompile>
81 + <WarningLevel>Level3</WarningLevel>
82 + <Optimization>Disabled</Optimization>
83 + <SDLCheck>true</SDLCheck>
84 + </ClCompile>
85 + </ItemDefinitionGroup>
86 + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
87 + <ClCompile>
88 + <WarningLevel>Level3</WarningLevel>
89 + <Optimization>MaxSpeed</Optimization>
90 + <FunctionLevelLinking>true</FunctionLevelLinking>
91 + <IntrinsicFunctions>true</IntrinsicFunctions>
92 + <SDLCheck>true</SDLCheck>
93 + </ClCompile>
94 + <Link>
95 + <EnableCOMDATFolding>true</EnableCOMDATFolding>
96 + <OptimizeReferences>true</OptimizeReferences>
97 + </Link>
98 + </ItemDefinitionGroup>
99 + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
100 + <ClCompile>
101 + <WarningLevel>Level3</WarningLevel>
102 + <Optimization>MaxSpeed</Optimization>
103 + <FunctionLevelLinking>true</FunctionLevelLinking>
104 + <IntrinsicFunctions>true</IntrinsicFunctions>
105 + <SDLCheck>true</SDLCheck>
106 + </ClCompile>
107 + <Link>
108 + <EnableCOMDATFolding>true</EnableCOMDATFolding>
109 + <OptimizeReferences>true</OptimizeReferences>
110 + </Link>
111 + </ItemDefinitionGroup>
112 + <ItemGroup>
113 + <ClCompile Include="channel.cpp" />
114 + <ClCompile Include="constellation_main.cpp" />
115 + <ClCompile Include="evaluate.cpp" />
116 + <ClCompile Include="myMatrix.cpp" />
117 + <ClCompile Include="receiver.cpp" />
118 + <ClCompile Include="sender.cpp" />
119 + </ItemGroup>
120 + <ItemGroup>
121 + <ClInclude Include="channel.h" />
122 + <ClInclude Include="evaluate.h" />
123 + <ClInclude Include="myMatrix.h" />
124 + <ClInclude Include="receiver.h" />
125 + <ClInclude Include="sender2.h" />
126 + <ClInclude Include="variables.h" />
127 + </ItemGroup>
128 + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
129 + <ImportGroup Label="ExtensionTargets">
130 + </ImportGroup>
131 +</Project>
...\ No newline at end of file ...\ No newline at end of file
1 +<?xml version="1.0" encoding="utf-8"?>
2 +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3 + <ItemGroup>
4 + <Filter Include="소스 파일">
5 + <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
6 + <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
7 + </Filter>
8 + <Filter Include="헤더 파일">
9 + <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
10 + <Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
11 + </Filter>
12 + <Filter Include="리소스 파일">
13 + <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
14 + <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
15 + </Filter>
16 + </ItemGroup>
17 + <ItemGroup>
18 + <ClCompile Include="constellation_main.cpp">
19 + <Filter>소스 파일</Filter>
20 + </ClCompile>
21 + <ClCompile Include="myMatrix.cpp">
22 + <Filter>소스 파일</Filter>
23 + </ClCompile>
24 + <ClCompile Include="sender.cpp">
25 + <Filter>소스 파일</Filter>
26 + </ClCompile>
27 + <ClCompile Include="channel.cpp">
28 + <Filter>소스 파일</Filter>
29 + </ClCompile>
30 + <ClCompile Include="receiver.cpp">
31 + <Filter>소스 파일</Filter>
32 + </ClCompile>
33 + <ClCompile Include="evaluate.cpp">
34 + <Filter>소스 파일</Filter>
35 + </ClCompile>
36 + </ItemGroup>
37 + <ItemGroup>
38 + <ClInclude Include="variables.h">
39 + <Filter>헤더 파일</Filter>
40 + </ClInclude>
41 + <ClInclude Include="channel.h">
42 + <Filter>헤더 파일</Filter>
43 + </ClInclude>
44 + <ClInclude Include="receiver.h">
45 + <Filter>헤더 파일</Filter>
46 + </ClInclude>
47 + <ClInclude Include="evaluate.h">
48 + <Filter>헤더 파일</Filter>
49 + </ClInclude>
50 + <ClInclude Include="myMatrix.h">
51 + <Filter>헤더 파일</Filter>
52 + </ClInclude>
53 + <ClInclude Include="sender2.h">
54 + <Filter>헤더 파일</Filter>
55 + </ClInclude>
56 + </ItemGroup>
57 +</Project>
...\ No newline at end of file ...\ No newline at end of file
1 +<?xml version="1.0" encoding="utf-8"?>
2 +<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3 + <PropertyGroup />
4 +</Project>
...\ No newline at end of file ...\ No newline at end of file
1 +#include <iostream>
2 +using namespace std;
3 +#include "sender2.h"
4 +#include "channel.h"
5 +#include "receiver.h"
6 +#include "evaluate.h"
7 +void main() {
8 + Csender mySender;
9 + Cchannel myChannel;
10 + Creceiver myReceiver;
11 + Cevaluate myEvaluator;
12 + ofstream myout;
13 + //myout.open("testSNR5.txt");
14 + //for (myChannel.N = 12.; 0<myChannel.N; myChannel.N = myChannel.N-0.1)
15 + //{
16 + cout << myChannel.N << endl;
17 + mySender.transmitData(); // generate data[ ], s[ ]
18 + myChannel.s = mySender.s;
19 + myChannel.AWGN(); // calculate r[ ]
20 +
21 + myReceiver.r = myChannel.r;
22 + myReceiver.c0 = mySender.c0;
23 + myReceiver.c1 = mySender.c1;
24 + myReceiver.demodulate(); // calculate constellation[ ], DecodedData[ ];
25 +
26 + myEvaluator.At = mySender.At;
27 + myEvaluator.Bt = mySender.Bt;
28 + myEvaluator.At_ = myReceiver.At_;
29 + myEvaluator.Bt_ = myReceiver.Bt_;
30 + myEvaluator.A = mySender.A;
31 + //myEvaluator.Data = mySender.data;
32 + myEvaluator.N = myChannel.N;
33 + //myEvaluator.DecodedData = myReceiver.DecodedData;
34 + myEvaluator.evaluate(); // compare the original and the decoded
35 +
36 + //myout << myEvaluator.SNR <<" "<< myEvaluator.errorrate<< " " << myEvaluator.SNR2 <<" "<< myEvaluator.errorrate << endl;
37 + //}
38 + myout.close();
39 + getchar();
40 +}
...\ No newline at end of file ...\ No newline at end of file
1 +#include <cstdlib>
2 +#include"evaluate.h"
3 +
4 +using namespace std;
5 +
6 +void Cevaluate::evaluate()
7 +{
8 + ofstream myout;
9 + //myout.open("testsnr.txt");
10 + float sum=0,sum2=0;
11 + //cout << "At\t" << "A`t\t" << "|At-A`t|" << "\t\t" << "Bt\t" << "B`t\t" << "|Bt-B`t|" << "\n\n";
12 + for (int i = 0; i < 500; i++)
13 + {
14 + sum += abs(At[i] - At_[i]) / abs(At[i]);
15 + sum2 += abs(Bt[i] - Bt_[i]) / abs(Bt[i]);
16 +
17 + //myout << At[i] << " " << Bt[i] << " " << At_[i] << " " << Bt_[i] << " " << abs(At[i] - At_[i])/At[i] << " " << abs(Bt[i] - Bt_[i])/Bt[i] << endl;
18 + }
19 + errorrate = ((sum / 500) + (sum2 / 500)) / 2;
20 + E=A*A/4;
21 + SNR = 10 * log10(E / N);
22 + SNR2 = E / N;
23 + cout << "에러율의 평균을 구해보자!" << endl;
24 + //for (float a = 0; 0.1 < No ; a += 0.1)
25 +
26 + cout << sum / 500 << "\t" << sum2 / 500 << "\t" << errorrate << "\t" << SNR <<"\t"<< SNR2 << endl;
27 + //myout << ((sum / 500) + (sum2 / 500)) / 2 << " " << SNR2 << " " << SNR << endl;
28 +
29 + //myout.close();
30 +}
...\ No newline at end of file ...\ No newline at end of file
1 +#ifndef __EVALUATE
2 +
3 +#define __EVALUATE
4 +#include <cmath>
5 +#include "variables.h"
6 +class Cevaluate {
7 +public:
8 + Cevaluate() {};
9 + char *DecodedData; // from the receiver
10 + char *Data; // from the sender
11 + float A;
12 + float *At, *Bt, *At_, *Bt_;
13 + float N;
14 +
15 + float E ;
16 + float SNR ;
17 + float SNR2;
18 + float errorrate;
19 + void evaluate();
20 +};
21 +#endif
This diff is collapsed. Click to expand it.
1 +#include <iostream>
2 +#include "myMatrix.h"
3 +using namespace std;
4 +void scalarmult(int n, int m, float a, float *b, float *c){
5 + int N = n*m;
6 + for(int i=0;i<N;i++) c[i] = a*b[i];
7 +}
8 +void matrixadd(int n, int m, float *a, float *b, float *c){
9 + int N = n*m;
10 + for (int i = 0; i<N; i++) c[i] = a[i]+b[i];
11 +}
12 +// (N by K) C X (K by M) D = (N by M) E
13 +void matrixmult(int N, int K, int M, float*C, float*D, float*E) {
14 + int n, k, m;
15 + for (n = 0; n < N; n++)
16 + for (m = 0; m < M; m++) {
17 + float sum = 0;
18 + for (k = 0; k < K; k++) sum += C[n*K + k] * D[k*M + m];
19 + E[n*M + m] = sum;
20 + }
21 +}
22 +// Solve equation Av = b
23 +// return 0 when solution exists,
24 +// -1 when solution does not exist.
25 +// A ==> indentity matrix
26 +// b ==> v (the solution)
27 +int GaussElimination(int N, float *a, float *b)
28 +{
29 + float temp, aii, aji;
30 + int i, j, k;
31 + //showequation(N, a, b);
32 + for (i = 0; i<N; i++) {
33 + aii = a[i*N + i];
34 + if (aii == 0.0) return -1; // 부정/불능 여기 더 할 일 있음
35 + // i-th row를 aii로 모두 나누기
36 + for (k = i; k<N; k++) a[i*N + k] /= aii;
37 + b[i] /= aii;
38 + // 다른 row들의 i번째 항을 모두 0으로 만들기
39 + for (j = 0; j<N; j++) {
40 + if (i != j) {
41 + aji = a[j*N + i];
42 + for (k = i; k<N; k++) a[j*N + k] -= a[i*N + k] * aji;
43 + b[j] -= b[i] * aji;
44 + }// if(i!=j)
45 + } // other rows
46 + //showequation(N, a, b);
47 + }
48 + return 0;
49 +}
50 +void showMatrix(int n, int m, float* F) {
51 + int i, j;
52 + for (i = 0; i < n; i++) {
53 + for (j = 0; j < m; j++) cout << F[i*m + j] << "\t";
54 + cout << "\n";
55 +
56 + }
57 +}
58 +void showMatrix(char*name, int n, int m, float* F) {
59 + cout << name << endl;
60 + showMatrix(n, m, F);
61 +}
62 +// show N X N matrix
63 +void showequation(int N, float *a, float *b)
64 +{
65 + int i, j;
66 + for (i = 0; i<N; i++)
67 + {
68 + for (j = 0; j<N; j++) cout << a[i*N + j] << "\t";
69 + cout << b[i];
70 + }
71 + cout << "\n";
72 +}
...\ No newline at end of file ...\ No newline at end of file
1 +void scalarmult(int n, int m, float a, float *b, float *c);
2 +void matrixadd(int n, int m, float *a, float *b, float *c);
3 +void matrixmult(int N, int K, int M, float*C, float*D, float*E);
4 +int GaussElimination(int, float*, float*);
5 +void showMatrix(int n, int m, float* F);
6 +void showMatrix(char*name, int n, int m, float* F);
7 +void showequation(int N, float *a, float *b);
...\ No newline at end of file ...\ No newline at end of file
1 +#include"receiver.h"
2 +#include<cstdlib>
3 +using namespace std;
4 +
5 +void Creceiver::demodulate()
6 +{
7 + int num = 0;
8 + for (int i = 0; i < 500; i++) {
9 + for (int k = 0; k < 20; k++) {
10 + Temp[k]=r[i * 20 + k] ;
11 + num++;
12 + }
13 + matrixmult(1, 20, 1, Temp, c0, receiver);
14 + At_[i] = receiver[0];
15 +
16 + matrixmult(1, 20, 1, Temp, c1, receiver);
17 + Bt_[i] = receiver[0] ;
18 +
19 + }
20 +
21 +
22 +
23 +
24 +}
...\ No newline at end of file ...\ No newline at end of file
1 +#ifndef __RECEIVER
2 +
3 +#define __RECEIVER
4 +#include <cmath>
5 +#include "variables.h"
6 +class Creceiver {
7 +public:
8 + Creceiver() {};
9 + float *r; // corrupted signal = received signal
10 + float *c0;
11 + float *c1;
12 + float At_[500];
13 + float Bt_[500];
14 + float dum1[Nbits / Nbitspersymbol];
15 +
16 + float receiver[1];
17 + float Temp[20];
18 +
19 +
20 + float constellation[Nbits];
21 + char DecodedData[Nbits];
22 + void demodulate();
23 +};
24 +#endif
1 +#include"sender2.h"
2 +#include<cstdlib>
3 +using namespace std;
4 +
5 +void Csender::transmitData() {
6 + srand((unsigned)time(NULL));
7 +
8 + for (int i = 0; i < Nbits; i++)
9 + {
10 +
11 + int random = rand() % 2;
12 +
13 + data[i] = random;
14 + }
15 +
16 +
17 +
18 + for (int k = 0; k < Nbits; k = k + 2)
19 + {
20 + if (data[k] == 0 && data[k + 1] == 0) {
21 + At[k / 2] = A * 1;
22 + Bt[k / 2] = A * 1;
23 + }
24 + else if (data[k] == 0 && data[k + 1] == 1) {
25 + At[k / 2] = A * 1;
26 + Bt[k / 2] = A * -1;
27 + }
28 + else if (data[k] == 1 && data[k + 1] == 0) {
29 + At[k / 2] = A * -1;
30 + Bt[k / 2] = A * 1;
31 + }
32 + else if (data[k] == 1 && data[k + 1] == 1) {
33 + At[k / 2] = A * -1;
34 + Bt[k / 2] = A * -1;
35 + }
36 +
37 + }
38 + double t;
39 + int k = 0;
40 + for (t = 0; t < T; t += dt)
41 + {
42 + c0[k] = sqrt(2. / T)*cos(2 * PI*t / T);
43 + c1[k] = sqrt(2. / T)*sin(2 * PI*t / T);
44 + k++;
45 + }
46 + /*
47 + for (int i = 0; i < 20; i++) {
48 + cout <<"|" <<c0[i] << "\t" <<"|"<< "\t" << "|" << c1[i] << "\t" << "|"<<endl;
49 + }
50 +
51 + cout << "\n"<<"matrix c0xc1" << "\n";
52 + matrixmult(1, 20, 1, c0, c1, sender);
53 + cout << sender[0] << endl;
54 +
55 + cout << "\n" << "matrix c0xc0" << "\n";
56 + matrixmult(1, 20, 1, c0, c0, sender);
57 + cout << sender[0] << endl;
58 +
59 + cout << "\n" << "matrix c1xc1" << "\n";
60 + matrixmult(1, 20, 1, c1, c1, sender);
61 + cout << sender[0] << endl;
62 +
63 + */
64 +
65 + for (int i = 0; i < Nbits / Nbitspersymbol; i++) {
66 + for (int k = 0; k < Nsamplespersymbol; k++)
67 + {
68 + s[i * Nsamplespersymbol + k] = ((At[i] * c0[k]) + (Bt[i] * c1[k]));
69 + }
70 + }
71 +
72 +
73 + for (int i = 0; i < 500; i++) {
74 + for (int k = 0; k < 20; k++) {
75 + Temp[k] = s[i * 20 + k];
76 + }
77 +
78 + matrixmult(1, 20, 1, Temp, c0, sender);
79 +
80 +
81 + }
82 +
83 +}
...\ No newline at end of file ...\ No newline at end of file
1 +#pragma once
2 +#ifndef __SENDER2
3 +#define __SENDER2
4 +#include <cmath>
5 +#include "variables.h"
6 +class Csender {
7 +public:
8 + Csender() {};
9 + int data[Nbits];
10 + float s[Nbits / Nbitspersymbol * Nsamplespersymbol]; // trasmitted signal
11 + void transmitData();
12 + float At[Nbits / Nbitspersymbol], Bt[Nbits / Nbitspersymbol];
13 + float c0[Nsamplespersymbol],c1[Nsamplespersymbol],sender[1];
14 + float A = 10.;
15 + float Temp[20];
16 + double T=20./1.,dt=1./1.;
17 +
18 +};
19 +#endif
...\ No newline at end of file ...\ No newline at end of file
1 +0.63702 4.9485 3.125
2 +0.629057 5.00313 3.16456
3 +0.621095 5.05845 3.20513
4 +0.613132 5.11449 3.24675
5 +0.605169 5.17126 3.28947
6 +0.597206 5.22879 3.33333
7 +0.589244 5.28708 3.37838
8 +0.581281 5.34617 3.42466
9 +0.573318 5.40607 3.47222
10 +0.565356 5.46682 3.52113
11 +0.557393 5.52842 3.57143
12 +0.54943 5.59091 3.62319
13 +0.541467 5.65431 3.67647
14 +0.533504 5.71865 3.73134
15 +0.525542 5.78396 3.78788
16 +0.517579 5.85027 3.84615
17 +0.509617 5.9176 3.90625
18 +0.501654 5.98599 3.96825
19 +0.493691 6.05548 4.03226
20 +0.485728 6.1261 4.09836
21 +0.477766 6.19789 4.16667
22 +0.469803 6.27088 4.23729
23 +0.46184 6.34512 4.31034
24 +0.453877 6.42065 4.38596
25 +0.445914 6.49752 4.46428
26 +0.437952 6.57577 4.54545
27 +0.429989 6.65546 4.62963
28 +0.422026 6.73664 4.71698
29 +0.414063 6.81936 4.80769
30 +0.406101 6.9037 4.90196
31 +0.398138 6.9897 5
32 +0.390175 7.07744 5.10204
33 +0.382213 7.16699 5.20833
34 +0.37425 7.25842 5.31915
35 +0.366287 7.35182 5.43478
36 +0.358324 7.44727 5.55555
37 +0.350361 7.54487 5.68181
38 +0.342399 7.64471 5.81395
39 +0.334436 7.7469 5.95238
40 +0.326473 7.85156 6.09756
41 +0.31851 7.9588 6.24999
42 +0.310548 8.06875 6.41025
43 +0.302585 8.18156 6.57894
44 +0.294622 8.29738 6.75675
45 +0.286659 8.41637 6.94444
46 +0.278697 8.53871 7.14285
47 +0.270734 8.66461 7.35293
48 +0.262771 8.79425 7.57575
49 +0.254809 8.92789 7.81249
50 +0.246846 9.06578 8.0645
51 +0.238883 9.20818 8.33332
52 +0.23092 9.35541 8.62068
53 +0.222958 9.50781 8.92856
54 +0.214995 9.66575 9.25924
55 +0.207032 9.82966 9.61537
56 +0.199069 9.99999 9.99998
57 +0.191107 10.1773 10.4166
58 +0.183144 10.3621 10.8695
59 +0.175181 10.5552 11.3636
60 +0.167218 10.7572 11.9047
61 +0.159256 10.9691 12.5
62 +0.151293 11.1919 13.1579
63 +0.14333 11.4267 13.8888
64 +0.135367 11.6749 14.7058
65 +0.127405 11.9382 15.6249
66 +0.119442 12.2185 16.6666
67 +0.111479 12.5181 17.8571
68 +0.103516 12.8399 19.2307
69 +0.0955535 13.1876 20.8332
70 +0.0875907 13.5655 22.7272
71 +0.079628 13.9794 24.9999
72 +0.0716652 14.4369 27.7776
73 +0.0637025 14.9485 31.2498
74 +0.0557397 15.5284 35.714
75 +0.047777 16.1978 41.6663
76 +0.0398142 16.9897 49.9995
77 +0.0318514 17.9587 62.4992
78 +0.0238887 19.2081 83.3318
79 +0.0159259 20.969 124.997
80 +0.00796318 23.9792 249.987
This diff is collapsed. Click to expand it.
1 +0.955531 5.22879 3.33333
2 +0.931642 5.33874 3.4188
3 +0.907754 5.45155 3.50877
4 +0.883866 5.56737 3.6036
5 +0.859977 5.68636 3.7037
6 +0.836089 5.80871 3.80952
7 +0.812201 5.9346 3.92157
8 +0.788313 6.06425 4.0404
9 +0.764424 6.19789 4.16667
10 +0.740536 6.33577 4.30108
11 +0.716648 6.47818 4.44445
12 +0.692759 6.62541 4.5977
13 +0.668871 6.77781 4.76191
14 +0.644983 6.93575 4.93827
15 +0.621095 7.09966 5.12821
16 +0.597206 7.26999 5.33334
17 +0.573318 7.44728 5.55556
18 +0.54943 7.63211 5.7971
19 +0.525542 7.82516 6.06061
20 +0.501653 8.0272 6.34921
21 +0.477765 8.23909 6.66667
22 +0.453877 8.46185 7.01755
23 +0.429988 8.69667 7.40741
24 +0.4061 8.9449 7.84314
25 +0.382212 9.20819 8.33334
26 +0.358324 9.48848 8.8889
27 +0.334435 9.78811 9.52382
28 +0.310547 10.11 10.2564
29 +0.286659 10.4576 11.1111
30 +0.262771 10.8355 12.1212
31 +0.238882 11.2494 13.3334
32 +0.214994 11.707 14.8148
33 +0.191106 12.2185 16.6667
34 +0.167217 12.7984 19.0477
35 +0.143329 13.4679 22.2223
36 +0.119441 14.2597 26.6667
37 +0.0955527 15.2288 33.3335
38 +0.0716644 16.4782 44.4447
39 +0.0477762 18.2391 66.6672
40 +0.0238879 21.2495 133.335
1 +3.18759 0.955531 2.08333 0.955531
2 +3.22393 0.947567 2.10084 0.947567
3 +3.26058 0.939605 2.11864 0.939605
4 +3.29754 0.931642 2.13675 0.931642
5 +3.33482 0.923679 2.15517 0.923679
6 +3.37242 0.915716 2.17391 0.915716
7 +3.41035 0.907754 2.19298 0.907754
8 +3.44862 0.899791 2.21239 0.899791
9 +3.48722 0.891828 2.23214 0.891828
10 +3.52617 0.883865 2.25225 0.883865
11 +3.56547 0.875903 2.27273 0.875903
12 +3.60514 0.867939 2.29358 0.867939
13 +3.64516 0.859977 2.31482 0.859977
14 +3.68556 0.852014 2.33645 0.852014
15 +3.72634 0.844051 2.35849 0.844051
16 +3.76751 0.836089 2.38095 0.836089
17 +3.80907 0.828126 2.40385 0.828126
18 +3.85103 0.820163 2.42719 0.820163
19 +3.8934 0.8122 2.45098 0.8122
20 +3.93619 0.804237 2.47525 0.804237
21 +3.9794 0.796275 2.5 0.796275
22 +4.02305 0.788312 2.52525 0.788312
23 +4.06714 0.780349 2.55102 0.780349
24 +4.11169 0.772386 2.57732 0.772386
25 +4.15669 0.764424 2.60417 0.764424
26 +4.20217 0.756461 2.63158 0.756461
27 +4.24813 0.748498 2.65958 0.748498
28 +4.29458 0.740535 2.68817 0.740535
29 +4.34153 0.732572 2.71739 0.732572
30 +4.38899 0.72461 2.74726 0.72461
31 +4.43698 0.716647 2.77778 0.716647
32 +4.48551 0.708684 2.80899 0.708684
33 +4.53458 0.700721 2.84091 0.700721
34 +4.58421 0.692759 2.87357 0.692759
35 +4.63442 0.684796 2.90698 0.684796
36 +4.68522 0.676833 2.94118 0.676833
37 +4.73661 0.66887 2.9762 0.66887
38 +4.78863 0.660907 3.01205 0.660907
39 +4.84127 0.652945 3.04879 0.652945
40 +4.89456 0.644982 3.08643 0.644982
41 +4.94851 0.637019 3.12501 0.637019
42 +5.00314 0.629056 3.16456 0.629056
43 +5.05846 0.621094 3.20513 0.621094
44 +5.1145 0.613131 3.24676 0.613131
45 +5.17127 0.605168 3.28948 0.605168
46 +5.2288 0.597205 3.33334 0.597205
47 +5.28709 0.589243 3.37838 0.589243
48 +5.34618 0.58128 3.42466 0.58128
49 +5.40608 0.573317 3.47223 0.573317
50 +5.46683 0.565355 3.52113 0.565355
51 +5.52843 0.557392 3.57144 0.557392
52 +5.59092 0.549429 3.6232 0.549429
53 +5.65432 0.541466 3.67648 0.541466
54 +5.71866 0.533503 3.73135 0.533503
55 +5.78397 0.525541 3.78789 0.525541
56 +5.85028 0.517578 3.84616 0.517578
57 +5.91761 0.509615 3.90626 0.509615
58 +5.986 0.501652 3.96826 0.501652
59 +6.05549 0.49369 4.03227 0.49369
60 +6.12611 0.485727 4.09837 0.485727
61 +6.1979 0.477764 4.16668 0.477764
62 +6.27089 0.469802 4.2373 0.469802
63 +6.34513 0.461839 4.31035 0.461839
64 +6.42066 0.453876 4.38597 0.453876
65 +6.49753 0.445913 4.4643 0.445913
66 +6.57578 0.43795 4.54546 0.43795
67 +6.65547 0.429987 4.62964 0.429987
68 +6.73665 0.422025 4.71699 0.422025
69 +6.81938 0.414062 4.8077 0.414062
70 +6.90371 0.406099 4.90197 0.406099
71 +6.98971 0.398137 5.00001 0.398137
72 +7.07745 0.390174 5.10205 0.390174
73 +7.167 0.382211 5.20835 0.382211
74 +7.25843 0.374248 5.31916 0.374248
75 +7.35183 0.366286 5.4348 0.366286
76 +7.44729 0.358323 5.55557 0.358323
77 +7.54488 0.35036 5.68183 0.35036
78 +7.64473 0.342398 5.81397 0.342398
79 +7.74692 0.334435 5.9524 0.334435
80 +7.85157 0.326472 6.09758 0.326472
81 +7.95881 0.318509 6.25002 0.318509
82 +8.06877 0.310546 6.41027 0.310546
83 +8.18158 0.302584 6.57897 0.302584
84 +8.2974 0.294621 6.75678 0.294621
85 +8.41639 0.286658 6.94446 0.286658
86 +8.53873 0.278696 7.14288 0.278696
87 +8.66462 0.270733 7.35296 0.270733
88 +8.79427 0.26277 7.57578 0.26277
89 +8.92791 0.254807 7.81252 0.254807
90 +9.0658 0.246845 8.06454 0.246845
91 +9.2082 0.238882 8.33336 0.238882
92 +9.35543 0.230919 8.62072 0.230919
93 +9.50784 0.222956 8.9286 0.222956
94 +9.66578 0.214993 9.25929 0.214993
95 +9.82968 0.207031 9.61542 0.207031
96 +10 0.199068 10 0.199068
97 +10.1773 0.191105 10.4167 0.191105
98 +10.3621 0.183143 10.8696 0.183143
99 +10.5552 0.17518 11.3637 0.17518
100 +10.7572 0.167217 11.9048 0.167217
101 +10.9691 0.159254 12.5001 0.159254
102 +11.1919 0.151292 13.158 0.151292
103 +11.4267 0.143329 13.889 0.143329
104 +11.6749 0.135366 14.706 0.135366
105 +11.9382 0.127403 15.6251 0.127403
106 +12.2185 0.119441 16.6668 0.119441
107 +12.5181 0.111478 17.8573 0.111478
108 +12.84 0.103515 19.2309 0.103515
109 +13.1876 0.0955523 20.8335 0.0955523
110 +13.5655 0.0875895 22.7275 0.0875895
111 +13.9794 0.0796268 25.0002 0.0796268
112 +14.437 0.0716641 27.7781 0.0716641
113 +14.9486 0.0637013 31.2504 0.0637013
114 +15.5285 0.0557385 35.7148 0.0557385
115 +16.198 0.0477758 41.6673 0.0477758
116 +16.9898 0.039813 50.0009 0.039813
117 +17.9589 0.0318502 62.5015 0.0318502
118 +19.2083 0.0238875 83.336 0.0238875
119 +20.9693 0.0159247 125.006 0.0159247
120 +23.9798 0.00796198 250.024 0.00796198
1 +#ifndef __VARIABLES
2 +#define __VARIABLES
3 +#define Nbits 1000 // number of transmitted bits
4 +#define Nsamplespersymbol 20
5 +#define Nbitspersymbol 2 // QPSK
6 +#define Eb 40 // fixed ;
7 +#define No 4 // at SNR = 20dB, variable
8 +#define PI 3.141592
9 +//#define A 5;
10 +
11 +#include"myMatrix.h"
12 +#include<fstream>
13 +#include<iterator>
14 +#include<random>
15 +#include <iostream>
16 +#include<cstdlib>
17 +#include<ctime>
18 +#include<time.h>
19 +#include<stdlib.h>
20 +#include<math.h>
21 +#endif