Kronecker product based fractals: Difference between revisions

m
added whitespace to the simple matrices and used a better glyph, added whitespace and highlighting to the task preamble, added whitespace before the table of contents (TOC) .
(Added Go)
m (added whitespace to the simple matrices and used a better glyph, added whitespace and highlighting to the task preamble, added whitespace before the table of contents (TOC) .)
Line 1:
{{task|Fractals}}
 
This task is based on   [[Kronecker product| Kronecker product]]   of two matrices. If your
language has no a built-in function for such product then you need to implement it first.<br>
 
If your language has no a built-in function for such product then you need to implement it first.<br>
 
The essence of fractals is self-replication (at least, self-similar replications).
 
So, using &nbsp; '''n''' &nbsp; times self-product of the matrix &nbsp; (filled with '''0'''/'''1''') &nbsp; we will have a fractal of the n-th&nbsp; order.'''n'''<brsup>th<br/sup> &nbsp; order.
Actually, "self-product" is a Kronecker power of the matrix. In other words: for a matrix '''M''' and a power '''n''' create a function like '''matkronpow(M, n)''', which returns MxMxMx... (n times product).<br>
 
A formal recurrent <i>algorithm</i> of creating Kronecker power of a matrix is the following:<br>
Actually, "self-product" is a Kronecker power of the matrix.
<b>Algorithm:</b>
 
Actually, "self-product" is a Kronecker power of the matrix. In other words: for a matrix &nbsp; '''M''' &nbsp; and a power &nbsp; '''n''' &nbsp; create a function like &nbsp; '''matkronpow(M, n)''', which returns MxMxMx... (n times product).<br>
<br>which returns &nbsp; M<small>x</small>M<small>x</small>M<small>x</small>... &nbsp; ('''n''' &nbsp; times product).
 
A formal recurrent <i>algorithm</i> of creating Kronecker power of a matrix is the following:<br>
 
 
<b>;Algorithm:</b>
<ul>
<li>Let M is an initial matrix, and Rn is a resultant block matrix of the Kronecker power, where n is the power (a.k.a. order).</li>
Line 15 ⟶ 26:
Even just looking at the resultant matrix you can see what will be plotted.<br>
There are virtually infinitely many fractals of this type. You are limited only by your creativity and
the power of your computer.<br>
 
 
;Task:
Using [[Kronecker_product| Kronecker product]] implement and show two popular and well-known fractals, i.e.:
Line 21 ⟶ 34:
* [[wp:Sierpinski carpet| Sierpinski carpet fractal]].
 
 
<br>The last one ([[Sierpinski carpet| Sierpinski carpet]]) is already here on RC, but built using different approaches.<br>
 
 
;Test cases:
These 2 fractals (each order/power 4 at least) should be built using the following 2 simple matrices:
<pre>
|0 1 0| and |1 1 1|
|1 1 1| |1 0 1|
|0 1 0| |1 1 1|
</pre>
 
;Note:
* Output could be a graphical or ASCII-art representation, but if an order is set > 4 then printing is not suitable.
Line 34 ⟶ 51:
* It would be nice to see one additional fractal of your choice, e.g., based on using a single (double) letter(s) of an alphabet, any sign(s) or already made a resultant matrix of the Kronecker product.
 
 
<br>See implementations and results below in JavaScript, PARI/GP and R languages. They have additional samples of "H", "+" and checkerboard fractals.
<br><br>
 
=={{header|C}}==