1
0
Mirror von https://github.com/Chaoscaot/schemsearch synchronisiert 2024-11-19 10:20:08 +01:00

Commits vergleichen

..

3 Commits

Autor SHA1 Nachricht Datum
9c8551dc5a Move to i32 2023-12-27 20:49:21 +01:00
abb2084029 Move to i32 2023-12-27 20:44:37 +01:00
3eba89b119 Move to i32 2023-12-27 20:43:50 +01:00
2 geänderte Dateien mit 32 neuen und 33 gelöschten Zeilen

Datei anzeigen

@ -1,4 +1,5 @@
#include <stdint.h>
#include <stddef.h>
int32_t isMatching(
const int32_t *schem_data,
@ -37,28 +38,28 @@ int32_t isMatching(
void is_matching_all(
const int32_t *schem_data,
const int32_t *pattern_data,
size_t schem_width,
size_t schem_height,
size_t schem_length,
size_t pattern_width,
size_t pattern_height,
size_t pattern_length,
int32_t schem_width,
int32_t schem_height,
int32_t schem_length,
int32_t pattern_width,
int32_t pattern_height,
int32_t pattern_length,
int32_t *result
) {
for (size_t pz = 0; pz < pattern_length; ++pz) {
size_t maxZ = schem_length - pattern_length + pz + 1;
for (size_t py = 0; py < pattern_height; ++py) {
size_t maxY = schem_height - pattern_height + py + 1;
for (size_t px = 0; px < pattern_width; ++px) {
for (int32_t pz = 0; pz < pattern_length; ++pz) {
int32_t maxZ = schem_length - pattern_length + pz + 1;
for (int32_t py = 0; py < pattern_height; ++py) {
int32_t maxY = schem_height - pattern_height + py + 1;
for (int32_t px = 0; px < pattern_width; ++px) {
int32_t pv = pattern_data[px + py * pattern_width + pz * pattern_width * pattern_height];
size_t maxX = schem_width - pattern_width + px + 1;
for (size_t z = pz; z < maxZ; ++z) {
size_t sourceOffsetZ = z * schem_width * schem_height;
size_t resultOffsetZ = (z - pz) * schem_width * schem_height - py * schem_width;
for (size_t y = py; y < maxY; ++y) {
size_t sourceOffsetY = sourceOffsetZ + y * schem_width;
size_t resultOffsetY = resultOffsetZ + y * schem_width - px;
for (size_t x = px; x < maxX; ++x) {
int32_t maxX = schem_width - pattern_width + px + 1;
for (int32_t z = pz; z < maxZ; ++z) {
int32_t sourceOffsetZ = z * schem_width * schem_height;
int32_t resultOffsetZ = (z - pz) * schem_width * schem_height - py * schem_width;
for (int32_t y = py; y < maxY; ++y) {
int32_t sourceOffsetY = sourceOffsetZ + y * schem_width;
int32_t resultOffsetY = resultOffsetZ + y * schem_width - px;
for (int32_t x = px; x < maxX; ++x) {
result[resultOffsetY + x] += schem_data[sourceOffsetY + x] == pv;
}
}

Datei anzeigen

@ -53,12 +53,12 @@ extern "C" {
pub fn is_matching_all(
schem_data: *const i32,
pattern_data: *const i32,
schem_width: usize,
schem_height: usize,
schem_length: usize,
pattern_width: usize,
pattern_height: usize,
pattern_length: usize,
schem_width: i32,
schem_height: i32,
schem_length: i32,
pattern_width: i32,
pattern_height: i32,
pattern_length: i32,
result: *mut i32
);
}
@ -149,18 +149,16 @@ pub fn search(
is_matching_all(
schem_data,
pattern_data,
schem_width,
schem_height,
schem_length,
pattern_width,
pattern_height,
pattern_length,
schem_width as i32,
schem_height as i32,
schem_length as i32,
pattern_width as i32,
pattern_height as i32,
pattern_length as i32,
result.as_mut_ptr()
);
}
dbg!(result.clone());
result.into_iter().enumerate().filter(|(_, matching_count)| *matching_count >= i_pattern_blocks - skip_amount).for_each(|(i, matching_count)| {
let percent = matching_count as f32 / pattern_blocks;
let x = i % schem_width;