This commit is contained in:
Markus Schmidt 2025-11-25 22:32:27 +01:00
commit 65a23d88d6
67 changed files with 14385 additions and 0 deletions

16
sheet4/B/.vscode/c_cpp_properties.json vendored Normal file
View file

@ -0,0 +1,16 @@
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "c17",
"cppStandard": "gnu++17",
"intelliSenseMode": "linux-gcc-x64"
}
],
"version": 4
}

6
sheet4/B/.vscode/settings.json vendored Normal file
View file

@ -0,0 +1,6 @@
{
"files.associations": {
"ostream": "cpp",
"iostream": "cpp"
}
}

View file

View file

BIN
sheet4/B/B.pdf Normal file

Binary file not shown.

2563
sheet4/B/Doxyfile Normal file

File diff suppressed because it is too large Load diff

32
sheet4/B/Makefile Normal file
View file

@ -0,0 +1,32 @@
#
# use GNU-Compiler tools
COMPILER=GCC_
# alternatively from the shell
# export COMPILER=GCC_
# or, alternatively from the shell
# make COMPILER=GCC_
# use Intel compilers
#COMPILER=ICC_
# use PGI compilers
# COMPILER=PGI_
SOURCES = main.cpp
OBJECTS = $(SOURCES:.cpp=.o)
PROGRAM = main.${COMPILER}
# uncomment the next to lines for debugging and detailed performance analysis
CXXFLAGS += -g
LINKFLAGS += -g
# do not use -pg with PGI compilers
ifndef COMPILER
COMPILER=GCC_
endif
include ../${COMPILER}default.mk
$(PROGRAM): $(OBJECTS)
$(CXX) $(CXXFLAGS) $(OBJECTS) -llapacke -lopenblas -o $(PROGRAM)

86
sheet4/B/main.cpp Normal file
View file

@ -0,0 +1,86 @@
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <lapacke.h>
using namespace std;
int n = 10;
double threshold = 1.0/sqrt(2);
double lambda(double x)
{
if(x < threshold)
{
return 1;
}
return 10;
}
double fillOffDiagonal(unsigned int i)
{
double x_l = i/double(n);
double x_u = (i+1)/double(n);
if(x_l < threshold && x_u > threshold)
{
return -n*n*(threshold-x_l+10*(x_u-threshold));
}
return -n*lambda(x_l);
}
double fillDiagonal(int i)
{
double x_l = (i-1)/double(n);
double x_u = (i+1)/double(n);
if(x_l < threshold && x_u > threshold)
{
return n*n*(threshold-x_l+10*(x_u-threshold));
}
return 2*n*lambda(x_l);
}
int main()
{
//Ignored the first Row of K cause we now that u(0)=0
int rhs = 1;
unsigned int nodes = n+1;
//Lapacke overwrites upper/lower diagonal so store twice
vector<double> upperdiagonal(n,0.0);
vector<double> lowerdiagonal(n,0.0);
vector<double> diagonal(nodes,1.0);
vector<double> F(nodes,0.0);
for(int i=0; i < n; i++)
{
upperdiagonal[i] = fillOffDiagonal(i);
lowerdiagonal[i] = fillOffDiagonal(i);
diagonal[i+1] = fillDiagonal(i+1);
}
upperdiagonal[0]=0.0;
lowerdiagonal[n-1]=0.0;
diagonal[n] = 1.0;
F[n] = 1.0;
//Tridiagonal
LAPACKE_dgtsv(LAPACK_COL_MAJOR,nodes,rhs,lowerdiagonal.data(),diagonal.data(),upperdiagonal.data(),F.data(),nodes);
cout << "Solution u_h at nodes x_0..x_" << n << ":\n";
for (unsigned int i = 0; i < nodes; ++i) {
double xi = double(i) /double(n);
cout << "u_h(" << xi << ") = " << F[i] << "\n";
// F will be overwritten with sol
}
return 0;
}

BIN
sheet4/B/plot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

1826
sheet4/B/small_Doxyfile Normal file

File diff suppressed because it is too large Load diff