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

Commits vergleichen

..

Keine gemeinsamen Commits. "9c8551dc5aa7d8f3b62dcce3dc00ff8a49a85212" und "511ce04f0b72a003a8fb429510bb62bd04ebf013" haben vollständig unterschiedliche Historien.

2 geänderte Dateien mit 33 neuen und 32 gelöschten Zeilen

Datei anzeigen

@ -1,5 +1,4 @@
#include <stdint.h>
#include <stddef.h>
int32_t isMatching(
const int32_t *schem_data,
@ -38,28 +37,28 @@ int32_t isMatching(
void is_matching_all(
const int32_t *schem_data,
const int32_t *pattern_data,
int32_t schem_width,
int32_t schem_height,
int32_t schem_length,
int32_t pattern_width,
int32_t pattern_height,
int32_t pattern_length,
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 *result
) {
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) {
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) {
int32_t pv = pattern_data[px + py * pattern_width + pz * pattern_width * pattern_height];
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) {
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) {
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: i32,
schem_height: i32,
schem_length: i32,
pattern_width: i32,
pattern_height: i32,
pattern_length: i32,
schem_width: usize,
schem_height: usize,
schem_length: usize,
pattern_width: usize,
pattern_height: usize,
pattern_length: usize,
result: *mut i32
);
}
@ -149,16 +149,18 @@ pub fn search(
is_matching_all(
schem_data,
pattern_data,
schem_width as i32,
schem_height as i32,
schem_length as i32,
pattern_width as i32,
pattern_height as i32,
pattern_length as i32,
schem_width,
schem_height,
schem_length,
pattern_width,
pattern_height,
pattern_length,
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;