summaryrefslogtreecommitdiffstats
path: root/mat/programčki
diff options
context:
space:
mode:
authorAnton Luka Šijanec <anton@sijanec.eu>2022-05-04 22:05:37 +0200
committerAnton Luka Šijanec <anton@sijanec.eu>2022-05-04 22:05:37 +0200
commit67ec51041e49881bc9e5aa0dd90121e20023367b (patch)
treeab4a2c276b272b2547f37a1c8cfacede9c00a5c7 /mat/programčki
parentfizproj (diff)
downloadsola-gimb-3-67ec51041e49881bc9e5aa0dd90121e20023367b.tar
sola-gimb-3-67ec51041e49881bc9e5aa0dd90121e20023367b.tar.gz
sola-gimb-3-67ec51041e49881bc9e5aa0dd90121e20023367b.tar.bz2
sola-gimb-3-67ec51041e49881bc9e5aa0dd90121e20023367b.tar.lz
sola-gimb-3-67ec51041e49881bc9e5aa0dd90121e20023367b.tar.xz
sola-gimb-3-67ec51041e49881bc9e5aa0dd90121e20023367b.tar.zst
sola-gimb-3-67ec51041e49881bc9e5aa0dd90121e20023367b.zip
Diffstat (limited to 'mat/programčki')
-rw-r--r--mat/programčki/ničle.singlethreaded16bit.c35
1 files changed, 31 insertions, 4 deletions
diff --git a/mat/programčki/ničle.singlethreaded16bit.c b/mat/programčki/ničle.singlethreaded16bit.c
index 49d53a6..eb1f672 100644
--- a/mat/programčki/ničle.singlethreaded16bit.c
+++ b/mat/programčki/ničle.singlethreaded16bit.c
@@ -27,22 +27,38 @@ int main (int argc, char ** argv) {
perror("open");
return 2;
}
- if (ftruncate(fd, 128 + šir*šir*2) == -1) {
+ if (ftruncate(fd, 128 + šir*šir
+#ifdef SESTNAJST
+ *2
+#endif
+ ) == -1) {
perror("ftruncate");
if (close(fd) == -1)
perror("close");
return 3;
}
void * p;
- if ((p = mmap(NULL, 128+šir*šir*2, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0)) == MAP_FAILED) {
+ if ((p = mmap(NULL, 128+šir*šir
+#ifdef SESTNAJST
+ *2
+#endif
+ , PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0)) == MAP_FAILED) {
perror("mmap");
if (close(fd) == -1)
perror("close");
return 4;
}
unsigned char * slika = (unsigned char *) p + 128;
- memset(p, 0, 128 + šir*šir*2);
+ memset(p, 0, 128 + šir*šir
+#ifdef SESTNAJST
+ *2
+#endif
+ );
+#ifdef SESTNAJST
sprintf(p, "P5\n\n%58lld\n%58lld\n65535\n", šir, šir); // precisely calculated with dc(1) (:
+#else
+ sprintf(p, "P5\n\n%57lld\n%57lld\n255\n", šir, šir);
+#endif
long long int stopnja = atoi(argv[1]);
double koeficienti[stopnja+1]; // kako prikladno! polinom nte stopnje ima n+1 členov
double ničle[2*stopnja]; // ima pa n ničel, 2n so realni deli, 2n+1 pa imagin
@@ -66,6 +82,7 @@ int main (int argc, char ** argv) {
izven_slike++;
continue;
}
+#ifdef SESTNAJST
slika[2*šir*višina_na_sliki+širina_na_sliki*2+1]++;
if (!slika[2*šir*višina_na_sliki+širina_na_sliki*2+1]) {
if (slika[2*šir*višina_na_sliki+širina_na_sliki*2] != 255)
@@ -73,11 +90,21 @@ int main (int argc, char ** argv) {
else
over++;
}
+#else
+ if (slika[šir*višina_na_sliki+širina_na_sliki] == 255)
+ over++;
+ else
+ slika[šir*višina_na_sliki+širina_na_sliki]++;
+#endif
}
}
fprintf(stderr, "\r KONČANO \n");
gsl_poly_complex_workspace_free(w);
- if (munmap(p, 128 + šir*šir) == -1)
+ if (munmap(p, 128 + šir*šir
+#ifdef SESTNAJST
+ *2
+#endif
+ ) == -1)
perror("munmap"); // nima smisla ukinjat programa, sistem si je sam kriv >:)
if (close(fd) == -1)
perror("close");