// "19-1a.c"
#include <stdio.h>
#include <time.h>
#define STATIC static
#include "bla.c"
#define MAX 447
#define STEP (14.0 / 0x100000)
#define DN 4
int bla_main(int argc, const char **argv)
{
int x, y, sx, sy, n, sn, c;
float cx, cy, zx, zy, xx, yy, tx, ty;
bla_Window *win = bla_openWin(512, 384, "mandel", 1);
for (y = 0; y < 384; y++) {
for (x = 0; x < 512; x++) {
sn = 0;
for (sx = 0; sx < DN; sx++) {
cx = (float) 0x4750 / 0x10000 + (x * DN + sx) * (STEP / DN);
for (sy = 0; sy < DN; sy++) {
cy = (float) -0x1e8 / 0x10000 - (y * DN + sy) * (STEP / DN);
zx = zy = 0.0;
for (n = 0; n < MAX; n++) {
xx = zx * zx;
yy = zy * zy;
if (xx + yy > 4.0) break;
tx = xx - yy;
ty = zx * zy * 2.0;
zx = tx + cx;
zy = ty + cy;
}
sn += n;
}
}
n = sn / (DN * DN);
c = bla_rgb(0, 0, 0);
if (n < 256)
c = bla_rgb(n, 0, 0);
else if (n < MAX)
c = bla_rgb(255, n - 255, 0);
bla_setPix(win, x, y, c);
}
bla_leapFlushAll(win, 300);
}
printf("time=%.3f[sec]\n", (float) clock() / CLOCKS_PER_SEC);
bla_end();
return 0; // dummy
}// "19-1b.c"
#include <stdio.h>
#include <time.h>
#define MAX 447
#define STEP (14.0 / 0x100000)
#define DN 4
int main()
{
int x, y, sx, sy, n, sn, h = 0;
float cx, cy, zx, zy, xx, yy, tx, ty;
for (y = 0; y < 384; y++) {
for (x = 0; x < 512; x++) {
sn = 0;
for (sx = 0; sx < DN; sx++) {
cx = (float) 0x4750 / 0x10000 + (x * DN + sx) * (STEP / DN);
for (sy = 0; sy < DN; sy++) {
cy = (float) -0x1e8 / 0x10000 - (y * DN + sy) * (STEP / DN);
zx = zy = 0.0;
for (n = 0; n < MAX; n++) {
xx = zx * zx;
yy = zy * zy;
if (xx + yy > 4.0) break;
tx = xx - yy;
ty = zx * zy * 2;
zx = tx + cx;
zy = ty + cy;
}
sn += n;
}
}
n = sn / (DN * DN);
h += n;
}
}
printf("h=%d\n", h);
printf("time=%.3f[sec]\n", (float) clock() / CLOCKS_PER_SEC);
return 0; // dummy
}h=28656157 time=1.807[sec]
// "19-1c.c"
#include <stdio.h>
#include <time.h>
int main()
{
int x, y, sx, sy, n, sn, h = 0;
long long cx, cy, zx, zy, xx, yy, tx, ty;
for (y = 0; y < 384; y++) {
for (x = 0; x < 512; x++) {
sn = 0;
for (sx = 0; sx < 4; sx++) {
cx = (x * 4 + sx) * 56 + 4673536;
for (sy = 0; sy < 4; sy++) {
cy = (y * 4 + sy) * -56 - 124928;
zx = zy = 0;
for (n = 0; n < 447; n++) {
xx = (zx * zx) >> 24;
yy = (zy * zy) >> 24;
if (xx + yy > 0x4000000) break;
tx = xx - yy;
ty = (zx * zy) >> 23;
zx = tx + cx;
zy = ty + cy;
}
sn += n;
}
}
n = sn / 16;
h += n;
}
}
printf("h=%d\n", (int) h);
printf("time=%.3f[sec]\n", (float) clock() / CLOCKS_PER_SEC);
return 0; // dummy
}h=28656617 time=1.177[sec]
zy = ((zy * zx) >> 23) + cy; zx = xx - yy + cx;
// "19-1d.c"
#include <stdio.h>
#include <time.h>
int main()
{
int n, sn, h = 0;
long long x, y, cx, cy, zx, zy, xx, yy, xx0;
for (y = -125152; y > -211168; y -= 224) {
for (x = 4673760; x < 4788448; x += 224) {
sn = 7152;
for (cx = x - 224; cx < x; cx += 56) {
xx0 = (cx * cx) >> 24;
for (cy = y + 224; cy > y; cy -= 56) {
zy = cy;
zx = cx;
xx = xx0;
yy = (cy * cy) >> 24;
n = -446;
do {
zy = (zy * zx) >> 23;
zx = xx + cx - yy;
zy = zy + cy;
n++;
if (n >= 0) goto skip;
xx = (zx * zx) >> 24;
yy = (zy * zy) >> 24;
} while (xx + yy <= 0x4000000);
sn += n;
skip:
;
}
}
h += sn >> 4;
}
}
printf("h=%d\n", h);
printf("time=%.3f[sec]\n", (float) clock() / CLOCKS_PER_SEC);
return 0; // dummy
}h=28656617 time=1.115[sec]
// "19-1e.c"
#include <stdio.h>
#include <time.h>
int main()
{
int x, y, ix, iy, n, sn, h = 0;
float cx, cy, zx, zy, xx, yy, xx0;
for (y = -125152; y > -211168; y -= 224) {
for (x = 4673760; x < 4788448; x += 224) {
sn = 7152;
for (ix = x - 224; ix < x; ix += 56) {
cx = ix * (1.0 / 16777216.0);
xx0 = cx * cx;
for (iy = y + 224; iy > y; iy -= 56) {
cy = iy * (1.0 / 16777216.0);
zy = cy;
zx = cx;
xx = xx0;
yy = cy * cy;
n = -446;
do {
zy = zy * zx * 2.0;
zx = xx + cx - yy;
zy = zy + cy;
n++;
if (n >= 0) goto skip;
xx = zx * zx;
yy = zy * zy;
} while (xx + yy <= 4.0);
sn += n;
skip:
;
}
}
h += sn >> 4;
}
}
printf("h=%d\n", h);
printf("time=%.3f[sec]\n", (float) clock() / CLOCKS_PER_SEC);
return 0; // dummy
}h=28655896 time=1.761[sec]
| コメント | お名前 | NameLink | |