JavaScript Ninja – Faster PowerSet 🙆

function get_a_power_set(){
      /* normalize input. before calling 'get_a_power_set' you can set 'get_a_power_set.initial_set' to be an array and 'get_a_power_set.is_beautify' to 'true' to get beautified output.
  var   feed = (1 === arguments.length) ? Array.prototype.slice.call(arguments,-1).pop() : arguments
      , initial_set = ("object"  !== typeof this.initial_set || -1 === this.initial_set.constructor.name.toLowerCase().indexOf("array")) ? [ [] ] : this.initial_set;
      , is_beautify = ("boolean" !== typeof this.is_beautify                                                                           ) ? false  : this.is_beautify;
  

  /* calculate */
  feed =  Array.prototype.reduce.call(feed, function (progression_set, current_item) {
    initial_set = [current_item]; /* re-use to store current item-variation */
    
    return progression_set.reduce(function (progression_set, current_item) {
      return progression_set.push(current_item.concat(initial_set)), progression_set
    }, progression_set)
    
  }, initial_set)

  
  /* beautified output (optional) */
  feed = (true === is_beautify) ? 
                                  JSON.stringify(feed, null, 2).replace(/,\n /g, "\n ,").replace(/ *(,(\ +))/g,"$2,") : 
                                  initial_feed;

  /* output */
  return feed;
}
get_a_power_set(["a","b"],"c")

–> will calculate the power-set of '[ ["a","b"], "c" ]'

get_a_power_set("a")

–> will calculate the power-set of ' "a" '

get_a_power_set.is_beautify = true;
get_a_power_set(["a"])

–> will output:

        "[
          []
         ,[
            "a"
          ]
        ]"
get_a_power_set.is_beautify = true;
get_a_power_set.initial_set = [];
get_a_power_set(["a"])

–> will output (almost) the same result — without the “empty-group-set”.

        "[
         ,[
            "a"
          ]
        ]"

JavaScript Non-Linear Random Numbers

statistics-and-probability-560x560

While normall dice toss will give you 1partn where n is the number of sides-of the dice.

this is an equal chance of each of the sides to come in 1 toss.

there are few easy ways of modifying a toss-result, using some of JavaScript’s native Math functions, such as modulus (%) and power (Math.pow), there are, naturally other that will work just as well, essentially once should choose a set of functions that will increase or modify the numeric value in a non-linear ‘way’, Math.pow is a good example since it may work exponentially, combined with modulus operation to keep the value ‘in-range’ we can play with JavaScript’s pseudo-random implementation to make some *cool variations of good old dice-toss..

*:cool? well.. if you’re a math-geek like me.. :)
Continue reading

Happy “Engineering Day” – JavaScript Huristics, Infinate IFRAME Elements, HTML5 Geo-Location API And Quantum Mechanics

An algorithm-problem I’ve made recently is combined of the inf.geolocaion road-trip,
which is variation of travelling salesman problem (TSP),
it uses web as *nodes* in a chain to avoid detection of the geo-security protocol,
and actual geo-location-api (when HTML5 supported).

I had the full article in publishing process.. need time to find a way to shorten it, to be suitable for a post..

provide a chain of *inf* road-trip into *inf* IFRAME elements, 1->n-1
that have the following content:

<!DOCTYPE html><html><head><script>
window.bubbleUp = function(data,arrPreFrames){
  arrPreFrames.push(document.location.pathname); //preserve logging the chain of frames.
  if(self !== window.parent){
    "function" === typeof window.parent.bubbleUp  &&  window.parent.bubbleUp.call(this,data,arrPreFrames); //push data up
  }else{
    console.log(data,arrPreFrames);  //swindow.parent here
  }
};
</script></head><body><iframe allowtransparency="true" frameborder="0" scrolling="no" style="display:none;width:1px;height:1px;" 
src="http://icompile.eladkarako.com/loc--------------n-1------------.html"></iframe></body></html>

for example the second iframe in the series of [0,1,2,…,n-1,n,…],
will look like this:

<!DOCTYPE html><html><head><script>
window.bubbleUp = function(data,arrPreFrames){
  arrPreFrames.push(document.location.pathname); //preserve logging the chain of frames.
  if(self !== window.parent){
    "function" === typeof window.parent.bubbleUp  &&  window.parent.bubbleUp.call(this,data,arrPreFrames); //push data up
  }else{
    console.log(data,arrPreFrames);  //swindow.parent here
  }
};
</script></head><body><iframe allowtransparency="true" frameborder="0" scrolling="no" style="display:none;width:1px;height:1px;" 
src="http://icompile.eladkarako.com/loc0.html"></iframe></body></html>

and the first iframe in the series of [0,1,2,…,n-1,n,…],
meaning #0 will look like this:

<!DOCTYPE html><html><head></head><body><script>
window.bubbleUp = function(data,arrPreFrames){
  arrPreFrames.push(document.location.pathname); //preserve logging the chain of frames.
  if(self !== window.parent){
    "function" === typeof window.parent.bubbleUp  &&  window.parent.bubbleUp.call(this,data,arrPreFrames); //push data up
  }else{
    console.log(data,arrPreFrames);  //swindow.parent here
  }
};

"undefined" !== typeof window.navigator.geolocation  &&  window.navigator.geolocation.getCurrentPosition(function(geo){ //initial action
  window.bubbleUp({
    "longitude":geo.coords.longitude,
    "latitude":geo.coords.latitude,
    "altitude":geo.coords.altitude,
    "asString":(function(){return "longitude="+geo.coords.longitude+";latitude="+geo.coords.latitude+";altitude="+geo.coords.altitude;}())
  },[]);
},function(positionErr){
    var o = {"verbose": positionErr.message, "errCode": positionErr.code};
    o["errStr"] = (function(){  //add corrent reason as new item
                    for(var errKey in positionErr){ 
                      if("code" !== errKey  &&   positionErr[ errKey ] === positionErr.code){
                        return errKey;
                      } 
                    }
                    return ""; 
                  }());
    o["asString"] = (function(){return "errCode="+o.errCode+";errStr="+o.errStr+";verbose="+o.verbose;}());
    window.bubbleUp(o, []);
},{
"enableHighAccuracy":true,
"maximumAge":600000, //milliseconds (::10 minutes cached)
"timeout":30000,     //milliseconds (::30 seconds till timeout)
});
</script></body></html>

the TOP (which will not be used for natural reasons) will be any target page,
implementing or not implementing the bubbleUp method,

lets make things more fun by introducing JavaScript into quantum mechanics
and to make complexity of TSP algorithm independent to window.TOP at any-point, we’ll attach it to quantum-events of any sort, this way it can be resolved using heuristics such as solutions for another problem dealing with similar probability related case, named Schrödinger’s cat problem.

I wish a very happy “Engineering Day”, to physicists, computer-science researchers and developers everywhere.

p.s.
get your nose up from that screen and go outside for 20 minutes :)

JavaScript and Canvas Playing : Generate Random Noise and Download The Image From The Canvas With New HTML5 Download Attribute + Demo

Generate some random noise (color or black&white) over canvas,
then, get the image, or download it using the new HTML5 “download”-attribute, or as a generic resource.

<style type="text/css">
.random-gen-canvas-white {
    width: 300px;
    height: 300px;
    background-color: rgba(255, 255, 255, .8);
    outline: 1px solid rgba(0, 0, 0, .3);
    box-shadow: 5px 5px 5px rgba(0, 0, 0, .2);
    margin-bottom: 10px;
}
.btn {
    width: 90%;
    height: 50px;
    margin: 2px 2px 2px 2px;
}
.btn-bnw {} .btn-color {} .btn-download {} .btn-clear {}
</style>
<canvas id="canvasWhite" class="random-gen-canvas-white" width="300" height="300"></canvas>
<script type="text/javascript">
function canvas_genRandomBNW() {
    var canvas = document.getElementById("canvasWhite"),
        ctx = canvas.getContext('2d'),
        i, ii = 1200;
    for (var i = 0; i < ii; i += 1) {
        ctx.fillStyle = (~~(Math.random() * 2)) === 1 ? "rgba(255,255,255,.9)" : "rgba(0,0,0,.9)";
        ctx.fillRect(~~(Math.random() * 300), //x
            ~~(Math.random() * 300), //y
            1, 1);
    }
    return true;
}

function canvas_genRandomCOLOR() {
    var canvas = document.getElementById("canvasWhite"),
        ctx = canvas.getContext('2d'),
        i, ii = 1200,
        r, g, b, a;
    for (var i = 0; i < ii; i += 1) {
        r = (~~(Math.random() * 256)); //red
        g = (~~(Math.random() * 256)); //green
        b = (~~(Math.random() * 256)); //blue
        a = "." + (30 + (~~(Math.random() * 71)))
            .toString(); //alpha transparency from .30 to .90
        ctx.fillStyle = "rgba(" + r + "," + g + "," + b + "," + a + ")";
        ctx.fillRect(~~(Math.random() * 300), //x
            ~~(Math.random() * 300), //y
            1, 1);
    }
    return true;
}

function canvas_getImage() {
    var canvas = document.getElementById("canvasWhite"),
        a = document.createElement("a");
    a.setAttribute("target", "_blank");
    a.setAttribute("type", "image/png");
    a.setAttribute("href", canvas.toDataURL("image/png"));
    document.getElementsByTagName("body")[0].appendChild(a);
    a.click(true);
}

function canvas_download_using_html5_download_attribute() {
    var canvas = document.getElementById("canvasWhite"),
        a = document.createElement("a");
    a.setAttribute("type", "image/png");
    a.setAttribute("href", canvas.toDataURL("image/png"));
    a.setAttribute("download", "random_image_" + (99999999 + ~~(Math.random() * 999999))
        .toString(13) + ".png");
    document.getElementsByTagName("body")[0].appendChild(a);
    a.click(true);
}

function canvas_download_forcing_by_using_octetstream_mimetype() {
    var canvas = document.getElementById("canvasWhite"),
        a = document.createElement("a");
    a.setAttribute("type", "image/png");
    a.setAttribute("href", canvas.toDataURL("image/png")
        .replace('data:image/png;', 'data:application/octet-stream;'));
    a.setAttribute("download", "random_image_" + (99999999 + ~~(Math.random() * 999999))
        .toString(13) + ".png");
    document.getElementsByTagName("body")[0].appendChild(a);
    a.click(true);
}

function canvas_clear() {
    var canvas = document.getElementById("canvasWhite");
    canvas.width = canvas.width;
}
</script>
<button class="btn btn-bnw" onclick="javascript:canvas_genRandomBNW();" type="button">Add Black&amp;White Noise!</button>
<button class="btn btn-color" onclick="javascript:window.canvas_genRandomCOLOR();" type="button">Add Color Noise!</button>
<button class="btn btn-getImage" onclick="javascript:window.canvas_getImage();" type="button">Open Image In New Tab!</button>
<button class="btn btn-download" onclick="javascript:window.canvas_download_using_html5_download_attribute();" type="button">Download Image! (HTML5-download attribute)</button>
<button class="btn btn-download" onclick="javascript:window.canvas_download_forcing_by_using_octetstream_mimetype();" type="button">Download Image! (as octet-stream mimetype)</button>
<button class="btn btn-clear" onclick="javascript:window.canvas_clear();" type="button">Clear</button>

here is the same code wrapped in PRE tag so WordPress will actually run it as a sample (nice and easy!)
















September 15th, 2016 - edit:

Some Log2 patterns
*plus a little trick to get a "better random" by reversing the digits.

<!doctype html>
<html dir="ltr" lang="en-US">
<head>
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
  <meta http-equiv="Content-Type"    content="text/html;charset=UTF-8"/>
  <meta name="viewport"              content="width=device-width,height=device-height,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
  <style type="text/css" media="all">
    html{ 
      background: none lightblue;
    }
  </style>
</head>
<body>
<style type="text/css">
.random-gen-canvas-white {
    width: 300px;
    height: 300px;
    background-color: rgba(255, 255, 255, .8);
    outline: 1px solid rgba(0, 0, 0, .3);
    box-shadow: 5px 5px 5px rgba(0, 0, 0, .2);
    margin-bottom: 10px;
}
.btn {
    width: 90%;
    height: 50px;
    margin: 2px 2px 2px 2px;
}
.btn-bnw {} .btn-color {} .btn-download {} .btn-clear {}
</style>
<canvas id="canvasWhite" class="random-gen-canvas-white" width="300" height="300"></canvas>
<script type="text/javascript">

function getRandom(modulo){
var number = Math.random();
number = String(number).substr(2,8).split('').reverse().join('');
number = Number(number);
number = Math.log2(1+1/number) / Math.log2(number);
number = String(number).replace(/[\,\.\-e]/gi,"");
number = Number(number);

return "undefined" === typeof modulo ? number : number % modulo;
}

function canvas_genRandomBNW() {
    var canvas = document.getElementById("canvasWhite"),
        ctx = canvas.getContext('2d'),
        i, ii = 1200;
setTimeout(function(){
    for (var i = 0; i < ii; i += 1) {
        ctx.fillStyle = getRandom(2) === 1 ? "rgba(255,255,255,.9)" : "rgba(0,0,0,.9)";
        ctx.fillRect(getRandom(300), //x
                     getRandom(300), //y
            1, 1);
    }
},20);
    return true;
}

function canvas_genRandomCOLOR() {
    var canvas = document.getElementById("canvasWhite"),
        ctx = canvas.getContext('2d'),
        i, ii = 1200,
        r, g, b, a;
setTimeout(function(){
    for (var i = 0; i < ii; i += 1) {
        r = getRandom(256); //red
        g = getRandom(256); //green
        b = getRandom(256); //blue
        a = "." + (30 + getRandom(71))
            .toString(); //alpha transparency from .30 to .90
        ctx.fillStyle = "rgba(" + r + "," + g + "," + b + "," + a + ")";
        ctx.fillRect(getRandom(300), //x
                     getRandom(300), //y
                     1, 1);
    }
},20);
    return true;
}

function canvas_getImage() {
    var canvas = document.getElementById("canvasWhite"),
        a = document.createElement("a");
    a.setAttribute("target", "_blank");
    a.setAttribute("type", "image/png");
    a.setAttribute("href", canvas.toDataURL("image/png"));
    document.getElementsByTagName("body")[0].appendChild(a);
    a.click(true);
}

function canvas_download_using_html5_download_attribute() {
    var canvas = document.getElementById("canvasWhite"),
        a = document.createElement("a");
    a.setAttribute("type", "image/png");
    a.setAttribute("href", canvas.toDataURL("image/png"));
    a.setAttribute("download", "random_image_" + getRandom(99999).toString(13) + ".png");
    document.getElementsByTagName("body")[0].appendChild(a);
    a.click(true);
}

function canvas_download_forcing_by_using_octetstream_mimetype() {
    var canvas = document.getElementById("canvasWhite"),
        a = document.createElement("a");
    a.setAttribute("type", "image/png");
    a.setAttribute("href", canvas.toDataURL("image/png")
        .replace('data:image/png;', 'data:application/octet-stream;'));
    a.setAttribute("download", "random_image_" + getRandom(99999).toString(13) + ".png");
    document.getElementsByTagName("body")[0].appendChild(a);
    a.click(true);
}

function canvas_clear() {
    var canvas = document.getElementById("canvasWhite");
    canvas.width = canvas.width;
}
</script>
<button class="btn btn-bnw" onclick="javascript:canvas_genRandomBNW();" type="button">Add Black&amp;White Noise!</button>
<button class="btn btn-color" onclick="javascript:window.canvas_genRandomCOLOR();" type="button">Add Color Noise!</button>
<button class="btn btn-getImage" onclick="javascript:window.canvas_getImage();" type="button">Open Image In New Tab!</button>
<button class="btn btn-download" onclick="javascript:window.canvas_download_using_html5_download_attribute();" type="button">Download Image! (HTML5-download attribute)</button>
<button class="btn btn-download" onclick="javascript:window.canvas_download_forcing_by_using_octetstream_mimetype();" type="button">Download Image! (as octet-stream mimetype)</button>
<button class="btn btn-clear" onclick="javascript:window.canvas_clear();" type="button">Clear</button></body>
</html>

here are some fun variations to base-formula and graphic-outputs,
which shows some white (empty) areas due to log's nature,
same goes for the color randomness, which seems to create a lovely-distribution maps :]

  • Math.log2(1+1/number) / Math.log2(number);
    icompile-eladkarako-com_eq_1-png
  • Math.log2(number);
    icompile-eladkarako-com_eq_2-png
  • Math.log2(number) + Math.log2(number);
    icompile-eladkarako-com_eq_3-png
  • Math.log10(number) * Math.log10(number);
    icompile-eladkarako-com_eq_4-png
  • Math.log10(number) % Math.log2(number);
    icompile-eladkarako-com_eq_5-png

try the next version yourself (also, you can right click it to see the source-code, or paste it in bin.eladkarako.com for quick variations fun :] )

C++ Cryptography Code-Segments I Use A Lot Lately

crypto1

static void blkcpy(void *, void *, size_t);
static void
blkcpy(void * dest, void * src, size_t len)
{
	size_t * D = dest;
	size_t * S = src;
	size_t L = len / sizeof(size_t);
	size_t i;

	for (i = 0; i < L; i++)
		D[i] = S[i];
}
static void blkxor(void *, void *, size_t);
static void
blkxor(void * dest, void * src, size_t len)
{
	size_t * D = dest;
	size_t * S = src;
	size_t L = len / sizeof(size_t);
	size_t i;

	for (i = 0; i < L; i++)
		D[i] ^= S[i];
}
static void salsa20_8(uint32_t[16]);
/**
 * salsa20_8(B):
 * Apply the salsa20/8 core to the provided block.
 */
static void
salsa20_8(uint32_t B[16])
{
	uint32_t x[16];
	size_t i;

	blkcpy(x, B, 64);
	for (i = 0; i < 8; i += 2) {
#define R(a,b) (((a) << (b)) | ((a) >> (32 - (b))))
		/* Operate on columns. */
		x[ 4] ^= R(x[ 0]+x[12], 7);  x[ 8] ^= R(x[ 4]+x[ 0], 9);
		x[12] ^= R(x[ 8]+x[ 4],13);  x[ 0] ^= R(x[12]+x[ 8],18);

		x[ 9] ^= R(x[ 5]+x[ 1], 7);  x[13] ^= R(x[ 9]+x[ 5], 9);
		x[ 1] ^= R(x[13]+x[ 9],13);  x[ 5] ^= R(x[ 1]+x[13],18);

		x[14] ^= R(x[10]+x[ 6], 7);  x[ 2] ^= R(x[14]+x[10], 9);
		x[ 6] ^= R(x[ 2]+x[14],13);  x[10] ^= R(x[ 6]+x[ 2],18);

		x[ 3] ^= R(x[15]+x[11], 7);  x[ 7] ^= R(x[ 3]+x[15], 9);
		x[11] ^= R(x[ 7]+x[ 3],13);  x[15] ^= R(x[11]+x[ 7],18);

		/* Operate on rows. */
		x[ 1] ^= R(x[ 0]+x[ 3], 7);  x[ 2] ^= R(x[ 1]+x[ 0], 9);
		x[ 3] ^= R(x[ 2]+x[ 1],13);  x[ 0] ^= R(x[ 3]+x[ 2],18);

		x[ 6] ^= R(x[ 5]+x[ 4], 7);  x[ 7] ^= R(x[ 6]+x[ 5], 9);
		x[ 4] ^= R(x[ 7]+x[ 6],13);  x[ 5] ^= R(x[ 4]+x[ 7],18);

		x[11] ^= R(x[10]+x[ 9], 7);  x[ 8] ^= R(x[11]+x[10], 9);
		x[ 9] ^= R(x[ 8]+x[11],13);  x[10] ^= R(x[ 9]+x[ 8],18);

		x[12] ^= R(x[15]+x[14], 7);  x[13] ^= R(x[12]+x[15], 9);
		x[14] ^= R(x[13]+x[12],13);  x[15] ^= R(x[14]+x[13],18);
#undef R
	}
	for (i = 0; i < 16; i++)
		B[i] += x[i];
}
static void blockmix_salsa8(uint32_t *, uint32_t *, uint32_t *, size_t);
/**
 * blockmix_salsa8(Bin, Bout, X, r):
 * Compute Bout = BlockMix_{salsa20/8, r}(Bin).  The input Bin must be 128r
 * bytes in length; the output Bout must also be the same size.  The
 * temporary space X must be 64 bytes.
 */
static void
blockmix_salsa8(uint32_t * Bin, uint32_t * Bout, uint32_t * X, size_t r)
{
	size_t i;

	/* 1: X
static uint64_t integerify(void *, size_t);
/**
 * integerify(B, r):
 * Return the result of parsing B_{2r-1} as a little-endian integer.
 */
static uint64_t
integerify(void * B, size_t r)
{
	uint32_t * X = (void *)((uintptr_t)(B) + (2 * r - 1) * 64);

	return (((uint64_t)(X[1]) << 32) + X[0]);
}
static void smix(uint8_t *, size_t, uint64_t, uint32_t *, uint32_t *);
/**
 * smix(B, r, N, V, XY):
 * Compute B = SMix_r(B, N).  The input B must be 128r bytes in length;
 * the temporary storage V must be 128rN bytes in length; the temporary
 * storage XY must be 256r + 64 bytes in length.  The value N must be a
 * power of 2 greater than 1.  The arrays B, V, and XY must be aligned to a
 * multiple of 64 bytes.
 */
static void
smix(uint8_t * B, size_t r, uint64_t N, uint32_t * V, uint32_t * XY)
{
	uint32_t * X = XY;
	uint32_t * Y = &XY[32 * r];
	uint32_t * Z = &XY[64 * r];
	uint64_t i;
	uint64_t j;
	size_t k;

	/* 1: X

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

/**
 * crypto_scrypt(passwd, passwdlen, salt, saltlen, N, r, p, buf, buflen):
 * Compute scrypt(passwd[0 .. passwdlen - 1], salt[0 .. saltlen - 1], N, r,
 * p, buflen) and write the result into buf.  The parameters r, p, and buflen
 * must satisfy r * p < 2^30 and buflen <= (2^32 - 1) * 32.  The parameter N  * must be a power of 2 greater than 1.  *  * Return 0 on success; or -1 on error.  */ int crypto_scrypt(const uint8_t * passwd, size_t passwdlen,     const uint8_t * salt, size_t saltlen, uint64_t N, uint32_t r, uint32_t p,     uint8_t * buf, size_t buflen) { 	void * B0, * V0, * XY0; 	uint8_t * B; 	uint32_t * V; 	uint32_t * XY; 	uint32_t i; 	/* Sanity-check parameters. */ #if SIZE_MAX > UINT32_MAX
	if (buflen > (((uint64_t)(1) << 32) - 1) * 32) { 		errno = EFBIG; 		goto err0; 	} #endif 	if ((uint64_t)(r) * (uint64_t)(p) >= (1 << 30)) { 		errno = EFBIG; 		goto err0; 	} 	if (((N & (N - 1)) != 0) || (N == 0)) { 		errno = EINVAL; 		goto err0; 	} 	if ((r > SIZE_MAX / 128 / p) ||
#if SIZE_MAX / 256 <= UINT32_MAX 	    (r > SIZE_MAX / 256) ||
#endif
	    (N > SIZE_MAX / 128 / r)) {
		errno = ENOMEM;
		goto err0;
	}

	/* Allocate memory. */
#ifdef HAVE_POSIX_MEMALIGN
	if ((errno = posix_memalign(&B0, 64, 128 * r * p)) != 0)
		goto err0;
	B = (uint8_t *)(B0);
	if ((errno = posix_memalign(&XY0, 64, 256 * r + 64)) != 0)
		goto err1;
	XY = (uint32_t *)(XY0);
#ifndef MAP_ANON
	if ((errno = posix_memalign(&V0, 64, 128 * r * N)) != 0)
		goto err2;
	V = (uint32_t *)(V0);
#endif
#else
	if ((B0 = malloc(128 * r * p + 63)) == NULL)
		goto err0;
	B = (uint8_t *)(((uintptr_t)(B0) + 63) & ~ (uintptr_t)(63));
	if ((XY0 = malloc(256 * r + 64 + 63)) == NULL)
		goto err1;
	XY = (uint32_t *)(((uintptr_t)(XY0) + 63) & ~ (uintptr_t)(63));
#ifndef MAP_ANON
	if ((V0 = malloc(128 * r * N + 63)) == NULL)
		goto err2;
	V = (uint32_t *)(((uintptr_t)(V0) + 63) & ~ (uintptr_t)(63));
#endif
#endif
#ifdef MAP_ANON
	if ((V0 = mmap(NULL, 128 * r * N, PROT_READ | PROT_WRITE,
#ifdef MAP_NOCORE
	    MAP_ANON | MAP_PRIVATE | MAP_NOCORE,
#else
	    MAP_ANON | MAP_PRIVATE,
#endif
	    -1, 0)) == MAP_FAILED)
		goto err2;
	V = (uint32_t *)(V0);
#endif

	/* 1: (B_0 ... B_{p-1}) 

Erdos distance problem

Combinatorial incidence geometry is the study of the possible combinatorial configurations between geometric objects such as lines and circles. One of the basic open problems in the subject has been the Erd?s distance problem, posed in 1946:

Problem 1 (Erd?s distance problem) Let {N} be a large natural number. What is the least number {\# \{ |x_i-x_j|: 1 \leq i < j \leq N \}} of distances that are determined by {N} points {x_1,\ldots,x_N} in the plane?

Erd?s called this least number {g(N)}. For instance, one can check that {g(3)=1} and {g(4)=2}, although the precise computation of {g} rapidly becomes more difficult after this. By considing {N} points in arithmetic progression, we see that {g(N) \leq N-1}. By considering the slightly more sophisticated example of a {\sqrt{N} \times \sqrt{N}} lattice grid (assuming that {N} is a square number for simplicity), and using some analytic number theory, one can obtain the slightly better asymptotic bound {g(N) = O( N / \sqrt{\log N} )}.

Continue reading

thoughts of the Banach

With the advent of analytic geometry, however, Euclidean geometry became reinterpreted as the study of Cartesian products {{\bf R}^d} of the real line {{\bf R}}. Using this analytic foundation rather than the classical geometrical one, it was no longer intuitively obvious how to define the measure {m(E)} of a general subset {E} of {{\bf R}^d}; we will refer to this (somewhat vaguely defined) problem of writing down the

Partial Differential Equations- Two-Dimensional Heat Equation

using separation of variables to ?nd the temperature distribution of rectangular and circular plates in the transient state.
Suppose that for a thin rectangular plate which occupies the plane region 0 ? x ? a, 0 ? y ? b, the top and bottom faces are insulated, and that its four edges are held at zero temperature. If the plate has the initial temperature function u(x, y, 0) = f(x, y), then in the transient state its temperature function u(x, y, t) is the solution of the following initial boundary value problem

We shall ?nd the solution of (36.1)

Mathematics Genealogy Project

The Mathematics Genealogy Project is a web-based database for the academic genealogy of mathematicians. As of 2007, it contained information on the graduation date, alma mater, doctoral advisor, and doctoral students of more than 100,000 pure and applied mathematicians, and PhD holders in related subjects.

Origins of the database
The project grew out of founder Harry Coonce’s desire to know the name of his advisor’s advisor. Coonce was Professor of Mathematics at Minnesota State University, Mankato, at the time of the project’s founding, and the project went online there in the fall of 1997. Coonce retired from Mankato in 1999, and in the fall of 2002 the university decided that it would no longer support the project. The project relocated at that time to North Dakota State University. Since 2003, the project has also operated under the auspices of the American Mathematical Society, and in 2005 it received a grant from the Clay Mathematics Institute.

Source of information
The genealogy information is obtained from sources such as Dissertation Abstracts International and Notices of the American Mathematical Society, but may be supplied by anyone via the project’s website. The searchable database contains the name of the mathematician, university which awarded the degree, year when the degree was awarded, title of the dissertation, names of the advisor and co-advisor, a flag of the country where the degree was awarded, a listing of doctoral students, and a count of academic descendants.

set it as my home-page for quite some time now
it is fun for browsing as well… ;}

http://www.genealogy.ams.org/

True Random


There are two principal methods used to generate random numbers. One measures some physical phenomenon that is expected to be random and then compensates for possible biases in the measurement process. The other uses computational algorithms that produce long sequences of apparently random results, which are in fact completely determined by a shorter initial value, known as a seed or key. The latter type are often called pseudo-random number generators.

Pseudo-random implementations, like LCG (linear congruential generator), usually uses a seed using a couple of runs with with a slightly different values of the multiplier coefficient (more on LCG).

True randomness can achieved from the sound a Zener diode caused by its avalanche breakdown, another way is sampling statics or a “white noise” this can be done using any simple receiver.

is doing just that, offering a free, online generator.

generate integer using the HTTP service.
Generating 1 random number [1 to 100, base 10] is easy!
http://www.random.org/integers/?num=1&min=1&max=100&col=1&base=10&format=plain&rnd=new
Watch

The downsize is active connection to the internet and a small delay, even thou the output does not need parsing.

quick&dirty wrapping:

Private Function trueRandom(ByVal num As Long, ByVal min As Long, ByVal max As Long) As Long()
    On Error Resume Next
    With Inet1
        .Document = "/integers/?num=" & num & "&min=" & min & "&max=" & max & "&col=1&base=10&format=plain&rnd=new"
        .RemoteHost = "www.random.org"
        .URL = "http://www.random.org/integers/?num=" & num & "&min=" & min & "&max=" & max & "&col=1&base=10&format=plain&rnd=new"
    End With
    Dim s as String
    s=Inet1.OpenURL
    'Here a Small Delay...
    trueRandom=CInt(Trim$(s))
End Function

MATLAB Advanced

MATLAB hides the tedious process of allocating memory for variables. This generosity, while often highly convenient, can cause you to waste a lot of run-time. Consider the following code, which implements Euler