Skip to content

Commit

Permalink
upd
Browse files Browse the repository at this point in the history
  • Loading branch information
progof committed Nov 13, 2024
1 parent be3fdcd commit e3a51e3
Show file tree
Hide file tree
Showing 45 changed files with 458 additions and 158 deletions.
19 changes: 19 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"configurations": [
{
"name": "Mac",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"macFrameworkPath": [
"/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks"
],
"compilerPath": "/usr/bin/clang",
"cStandard": "c17",
"cppStandard": "c++17",
"intelliSenseMode": "macos-clang-x64"
}
],
"version": 4
}
22 changes: 22 additions & 0 deletions computational-methods-and-simulation/lab-5/task-1/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Nazwa pliku wykonywalnego
EXEC = rectangle_integration

# Flagi kompilacji
CFLAGS = -Wall -lm

# Pliki źródłowe
SRC = rectangle_integration.c

# Reguła główna
all: $(EXEC)

# Kompilacja programu
$(EXEC): $(SRC)
$(CC) $(CFLAGS) -o $(EXEC) $(SRC)

# Czyszczenie plików wykonywalnych
clean:
rm -f $(EXEC)

run: $(EXEC)
./$(EXEC)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
107 changes: 107 additions & 0 deletions computational-methods-and-simulation/lab-5/task-1/diagram/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# import matplotlib.pyplot as plt
# import numpy as np

# # Dane do wykresu
# functions = [
# {
# "name": "f1(x) = x^2 + x + 1",
# "exact_value": 1.6666666667,
# "approx_values": [1.8333314260, 1.8333314260, 1.8333314260, 1.8333314260],
# "errors": [0.1666647593, 0.1666647593, 0.1666647593, 0.1666647593],
# "subintervals": [1048576, 1048576, 1048576, 1048576]
# },
# {
# "name": "f2(x) = sqrt(1 - x^2)",
# "exact_value": 0.7853981634,
# "approx_values": [0.7863493507, 0.7854588020, 0.7854057753, 0.7853991163],
# "errors": [0.0009511873, 0.0000606386, 0.0000076119, 0.0000009529],
# "subintervals": [512, 8192, 65536, 524288]
# },
# {
# "name": "f3(x) = 1/sqrt(x)",
# "exact_value": 2.0000000000,
# "approx_values": [1.9800945559, 1.9800945559, 1.9800945559, 1.9800945559],
# "errors": [0.0199054441, 0.0199054441, 0.0199054441, 0.0199054441],
# "subintervals": [1048576, 1048576, 1048576, 1048576]
# }
# ]

# # Ustawienia wykresów
# fig, axs = plt.subplots(3, 2, figsize=(14, 10))
# fig.suptitle("Wyniki przybliżonej całki dla różnych funkcji", fontsize=16)

# # Generowanie wykresów
# for i, func in enumerate(functions):
# # Podprzedziały vs Przybliżona całka
# axs[i, 0].plot(func["subintervals"], func["approx_values"], marker='o', color='b', label="Przybliżona całka")
# axs[i, 0].axhline(y=func["exact_value"], color='r', linestyle='--', label="Dokładna wartość")
# axs[i, 0].set_xscale("log")
# axs[i, 0].set_xlabel("Podprzedziały (log scale)")
# axs[i, 0].set_ylabel("Wartość całki")
# axs[i, 0].set_title(f"{func['name']}")
# axs[i, 0].legend()

# # Podprzedziały vs Błąd
# axs[i, 1].plot(func["subintervals"], func["errors"], marker='o', color='g', label="Błąd")
# axs[i, 1].set_xscale("log")
# axs[i, 1].set_yscale("log")
# axs[i, 1].set_xlabel("Podprzedziały (log scale)")
# axs[i, 1].set_ylabel("Błąd (log scale)")
# axs[i, 1].set_title(f"Błąd dla {func['name']}")
# axs[i, 1].legend()

# plt.tight_layout(rect=[0, 0, 1, 0.96])
# plt.show()


import matplotlib.pyplot as plt
import numpy as np

# Dane do wykresu
functions = [
{
"name": "f1(x) = x^2 + x + 1",
"exact_value": 1.6666666667,
"approx_values": [1.8333314260, 1.8333314260, 1.8333314260, 1.8333314260],
"errors": [0.1666647593, 0.1666647593, 0.1666647593, 0.1666647593],
"subintervals": [1048576, 1048576, 1048576, 1048576]
},
{
"name": "f2(x) = sqrt(1 - x^2)",
"exact_value": 0.7853981634,
"approx_values": [0.7863493507, 0.7854588020, 0.7854057753, 0.7853991163],
"errors": [0.0009511873, 0.0000606386, 0.0000076119, 0.0000009529],
"subintervals": [512, 8192, 65536, 524288]
},
{
"name": "f3(x) = 1/sqrt(x)",
"exact_value": 2.0000000000,
"approx_values": [1.9800945559, 1.9800945559, 1.9800945559, 1.9800945559],
"errors": [0.0199054441, 0.0199054441, 0.0199054441, 0.0199054441],
"subintervals": [1048576, 1048576, 1048576, 1048576]
}
]

# Generowanie oddzielnych wykresów
for func in functions:
# Wykres Przybliżonej całki
plt.figure()
plt.plot(func["subintervals"], func["approx_values"], marker='o', color='b', label="Przybliżona całka")
plt.axhline(y=func["exact_value"], color='r', linestyle='--', label="Dokładna wartość")
plt.xscale("log")
plt.xlabel("Podprzedziały (log scale)")
plt.ylabel("Wartość całki")
plt.title(f"{func['name']}")
plt.legend()
plt.show()

# Wykres Błędu
plt.figure()
plt.plot(func["subintervals"], func["errors"], marker='o', color='g', label="Błąd")
plt.xscale("log")
plt.yscale("log")
plt.xlabel("Podprzedziały (log scale)")
plt.ylabel("Błąd (log scale)")
plt.title(f"Błąd dla {func['name']}")
plt.legend()
plt.show()
Binary file not shown.
23 changes: 23 additions & 0 deletions computational-methods-and-simulation/lab-5/task-2/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Nazwa pliku wykonywalnego
EXEC = calculate_integrals_gsl

# Flagi kompilacji
CFLAGS = -Wall
LDFLAGS = -lgsl -lgslcblas -lm

# Pliki źródłowe
SRC = calculate_integrals_gsl.c

# Reguła główna
all: $(EXEC)

# Kompilacja programu
$(EXEC): $(SRC)
$(CC) $(CFLAGS) -o $(EXEC) $(SRC) $(LDFLAGS)

# Czyszczenie plików wykonywalnych
clean:
rm -f $(EXEC)

run: $(EXEC)
./$(EXEC)
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 40 additions & 0 deletions computational-methods-and-simulation/lab-5/task-2/diagram/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import numpy as np
import matplotlib.pyplot as plt

# Dane wejściowe
epsrel_values = [1e-3, 1e-4, 1e-5, 1e-6]
functions = {
"f3: sin(x)": {
"GSL": [2.0, 2.0, 2.0, 2.0],
"Rectangular": [2.0002008117, 2.0000125499, 2.0000031375, 2.0000001961]
},
"f4: tan(x)": {
"GSL": [13.8155086985, 13.8155105592, 13.8155105579, 13.8155105579],
"Rectangular": [13.8154192810, 13.8154877322, 13.8155091312, 13.8155104688]
},
"f5: log(x + x^2)": {
"GSL": [6.2060726455, 6.2060726455, 6.2060726455, 6.2060726455],
"Rectangular": [6.2061687630, 6.2060966773, 6.2060741476, 6.2060727394]
}
}

# Generowanie wykresów pojedynczo dla każdej funkcji
for func_name, results in functions.items():
plt.figure(figsize=(8, 5))

# Wykres wyników GSL
plt.plot(epsrel_values, results["GSL"], marker='o', color='b', label='GSL')

# Wykres wyników Metody Prostokątów
plt.plot(epsrel_values, results["Rectangular"], marker='x', color='r', label='Rectangular')

# Konfiguracja wykresu
plt.xscale("log")
plt.xlabel("epsrel (Dokładność)")
plt.ylabel("Wynik całki")
plt.title(f"Wyniki dla {func_name}")
plt.legend()
plt.grid(True, which="both", linestyle="--", linewidth=0.5)

# Wyświetlanie wykresu
plt.show()
1 change: 1 addition & 0 deletions java-advance/18.10.2024-car-rent-maven
Submodule 18.10.2024-car-rent-maven added at 1f3e1c
7 changes: 7 additions & 0 deletions java-advance/rent-car-maven/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@
<artifactId>commons-codec</artifactId>
<version>1.17.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.34</version>
<scope>provided</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package pl.edu.wszib.car.rent;

import pl.edu.wszib.car.rent.core.Core;
import pl.edu.wszib.car.rent.db.CarRepository;
import pl.edu.wszib.car.rent.core.impl.Core;

public class App {
public static void main(String[] args) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,5 @@
import pl.edu.wszib.car.rent.model.User;

public interface IAuthenticator {

boolean authenticate(User user);

static IAuthenticator getInstance() {
return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package pl.edu.wszib.car.rent.authentication.impl;

import org.apache.commons.codec.digest.DigestUtils;
import pl.edu.wszib.car.rent.authentication.IAuthenticator;
import pl.edu.wszib.car.rent.db.impl.UserRepository;
import pl.edu.wszib.car.rent.model.User;

public class Authenticator implements IAuthenticator {
private static Authenticator instance = new Authenticator();
private UserRepository userRepository = UserRepository.getInstance();
private String seed = "sy2eL273fTUxQoH3Zlm7wM4ZzK3bR4Gh";

private Authenticator() {
}

@Override
public boolean authenticate(User user) {
User userFromDb = this.userRepository.getUser(user.getLogin());
return userFromDb != null &&
userFromDb.getPassword()
.equals(DigestUtils.md5Hex(user.getPassword()+seed));
}

public static Authenticator getInstance() {
return instance;
}
}
Original file line number Diff line number Diff line change
@@ -1,23 +1,30 @@
package pl.edu.wszib.car.rent.core;
package pl.edu.wszib.car.rent.core.impl;

import pl.edu.wszib.car.rent.db.CarRepository;
import pl.edu.wszib.car.rent.authentication.impl.Authenticator;
import pl.edu.wszib.car.rent.authentication.IAuthenticator;
import pl.edu.wszib.car.rent.core.ICore;
import pl.edu.wszib.car.rent.db.ICarRepository;
import pl.edu.wszib.car.rent.db.impl.CarRepository;
import pl.edu.wszib.car.rent.gui.impl.GUI;
import pl.edu.wszib.car.rent.gui.IGUI;
import pl.edu.wszib.car.rent.gui.GUI;
import pl.edu.wszib.car.rent.authentication.Authenticator;

public class Core implements ICore {
private ICarRepository carRepository = CarRepository.getInstance();
private IGUI gui = GUI.getInstance();
private Authenticator authenticator = Authenticator.getInstance();
private IAuthenticator authenticator = Authenticator.getInstance();
private static final Core instance = new Core();

private Core() {
}

@Override
public void run() {

boolean running = this.authenticator.authenticate(this.gui.askForCredentials());
boolean running = false;
int trys = 0;
while(!running && trys < 3) {
running = this.authenticator.authenticate(this.gui.aksForCredentials());
trys++;
}
while (running) {
switch (this.gui.showMenuAndReadChoice()) {
case "1":
Expand Down

This file was deleted.

Loading

0 comments on commit e3a51e3

Please sign in to comment.