<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel rdf:about="https://community.wolfram.com">
    <title>Community RSS Feed</title>
    <link>https://community.wolfram.com</link>
    <description>RSS Feed for Wolfram Community showing any discussions tagged with Computer Science sorted by most viewed.</description>
    <items>
      <rdf:Seq>
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/404292" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/3118205" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/1077888" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/148287" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/897081" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/1112012" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/1298554" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/454405" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/374658" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/218587" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/394537" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/568332" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/434905" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/550504" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/1045419" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/897811" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/943405" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/1421180" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/126665" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/504085" />
      </rdf:Seq>
    </items>
  </channel>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/404292">
    <title>JaroWinkler distance in Wolfram Language ?</title>
    <link>https://community.wolfram.com/groups/-/m/t/404292</link>
    <description>Does anyone have an idea for an efficient implementation of [JaroWinkler distance][1]? If there is a built in function with a different name it would be great, please let me know. If not, perhaps a modification of [Levenshtein][2] or similar would do or a compiled version (not sure which functions to use to make it compilable). I know good etiquette is to show some code, but I have to compare millions of strings pairwise and need the most efficient approach. Any advice would be appreciated - thanks in advance! &#xD;
&#xD;
BTW does anyone see any link between Shannon Entropy and Levenshtein and similar distances? Is it possible to talk about distance metric between strings in terms of information change needed to turn one string into the other? &#xD;
&#xD;
  [1]: https://en.wikipedia.org/wiki/Jaro%E2%80%93Winkler_distance&#xD;
  [2]: http://reference.wolfram.com/language/ref/EditDistance.html</description>
    <dc:creator>Sam Carrettie</dc:creator>
    <dc:date>2014-12-09T02:00:25Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/3118205">
    <title>Wolfram quantum framework: tensor networks, spiders, and ZX formalism</title>
    <link>https://community.wolfram.com/groups/-/m/t/3118205</link>
    <description>![enter image description here][1]&#xD;
&#xD;
&amp;amp;[Wolfram Notebook][2]&#xD;
&#xD;
&#xD;
  [1]: https://community.wolfram.com//c/portal/getImageAttachment?filename=heroimage.png&amp;amp;userId=1539902&#xD;
  [2]: https://www.wolframcloud.com/obj/5b3b5265-f1e2-406c-aef4-45a5f9ec363b</description>
    <dc:creator>Mohammad Bahrami</dc:creator>
    <dc:date>2024-02-07T19:21:52Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/1077888">
    <title>Solving Suguru (Tectonic) puzzles</title>
    <link>https://community.wolfram.com/groups/-/m/t/1077888</link>
    <description>![enter image description here][1]&#xD;
&#xD;
Above is the starting grid of a so called Suguru puzzle (also known as Tectonic or number block puzzles). See https://krazydad.com/suguru/ for many more puzzles.&#xD;
&#xD;
The rules are simple:&#xD;
&#xD;
 1. each cell (thin lines) contains a single integer.&#xD;
 2. each container (cage, block) (thick lines) contains the non-repeating integer starting from 1 to the size of the container.&#xD;
 3. adjacent (including diagonally touching) cells do not have the same number&#xD;
&#xD;
So, for example, this means that in the bottom we have a container of size 2 that those cells will contain the numbers 1 and 2 or 2 and 1.&#xD;
&#xD;
Let&amp;#039;s set up the candidates for each cell, and the containers (I called them tectons):&#xD;
&#xD;
    tectons = {&#xD;
       {{1, 1}, {1, 2}, {2, 1}, {2, 2}, {3, 1}},&#xD;
       {{1, 3}, {1, 4}, {1, 5}, {2, 3}, {2, 4}},&#xD;
       {{1, 6}, {1, 7}, {2, 5}, {2, 6}, {3, 5}},&#xD;
       {{1, 8}, {2, 7}, {2, 8}, {3, 6}, {3, 7}},&#xD;
       {{1, 9}, {2, 9}, {3, 9}, {4, 8}, {4, 9}},&#xD;
       {{3, 8}},&#xD;
       {{5, 8}},&#xD;
       {{5, 9}, {6, 8}, {6, 9}, {7, 8}, {7, 9}},&#xD;
       {{4, 6}, {4, 7}, {5, 6}, {5, 7}, {6, 7}},&#xD;
       {{5, 5}, {6, 5}, {6, 6}, {7, 4}, {7, 5}},&#xD;
       {{5, 2}, {5, 3}, {6, 3}, {6, 4}, {7, 3}},&#xD;
       {{3, 3}, {3, 4}, {4, 4}, {4, 5}, {5, 4}},&#xD;
       {{3, 2}, {4, 1}, {4, 2}, {4, 3}, {5, 1}},&#xD;
       {{6, 1}, {6, 2}, {7, 1}, {7, 2}},&#xD;
       {{7, 6}, {7, 7}}&#xD;
       };&#xD;
    givens = &amp;lt;|&#xD;
       {1, 1} -&amp;gt; 1,&#xD;
       {2, 2} -&amp;gt; 2,&#xD;
       {3, 1} -&amp;gt; 4,&#xD;
       {1, 4} -&amp;gt; 1,&#xD;
       {2, 8} -&amp;gt; 3,&#xD;
       {3, 3} -&amp;gt; 4,&#xD;
       {3, 9} -&amp;gt; 4,&#xD;
       {4, 4} -&amp;gt; 1,&#xD;
       {5, 1} -&amp;gt; 4,&#xD;
       {5, 3} -&amp;gt; 5,&#xD;
       {5, 5} -&amp;gt; 4,&#xD;
       {5, 7} -&amp;gt; 5,&#xD;
       {6, 8} -&amp;gt; 3,&#xD;
       {7, 5} -&amp;gt; 2,&#xD;
       {7, 9} -&amp;gt; 5&#xD;
       |&amp;gt;;&#xD;
&#xD;
Let&amp;#039;s create the database (db) of candidates, and process the given hints:&#xD;
&#xD;
    If[! DuplicateFreeQ[Join @@ tectons], Print[&amp;#034;Cells have to be unique among tectonics&amp;#034;]; Abort[];];&#xD;
    canddb = With[{x = #}, {#, Range[Length[x]]} &amp;amp; /@ x] &amp;amp; /@ tectons;&#xD;
    canddb = Association[Rule @@@ (Join @@ canddb)];&#xD;
    KeyValueMap[(canddb[#1] = {#2}) &amp;amp;, givens];&#xD;
&#xD;
Now we need a way to visualize them:&#xD;
&#xD;
    ClearAll[VisualizeTectonic, VisualizeTectonicSideHelper, VisualizeTectonicNumberHelper]&#xD;
    VisualizeTectonicNumberHelper[{row_, column_}, cand_List] := Module[{p, l, poss, t},&#xD;
      l = Length[cand];&#xD;
      p = {column, -row};&#xD;
      If[l == 1,&#xD;
       Text[Style[First[cand], Black, 17], p]&#xD;
       ,&#xD;
       MapThread[Text[Style[#1, 12, Red], #2] &amp;amp;, {cand, CirclePoints[p, 0.2, l]}]&#xD;
       ]&#xD;
      ]&#xD;
    VisualizeTectonicSideHelper[tecton_List] := Module[{p, sides},&#xD;
      p = {#2, -#1} &amp;amp; @@@ tecton;&#xD;
      sides = Partition[{# + {-0.5, -0.5}, # + {0.5, -0.5}, # + {0.5, 0.5}, # + {-0.5, 0.5}}, 2, 1, 1] &amp;amp; /@ p;&#xD;
      sides = Join @@ sides;&#xD;
      sides = Tally[Sort /@ sides];&#xD;
      Table[If[Last[s] == 1, {Thickness[0.01], Line[First[s]]}, Line[First[s]]], {s, sides}]&#xD;
     ]&#xD;
    VisualizeTectonic[canddb_Association, tectons_List] := Module[{nums, sides, cb},&#xD;
      nums = KeyValueMap[VisualizeTectonicNumberHelper, canddb];&#xD;
      sides = VisualizeTectonicSideHelper /@ tectons;&#xD;
      cb = #2 - #1 &amp;amp; @@@ CoordinateBounds[Transpose[Join @@ tectons]];&#xD;
      Graphics[{nums, sides}, ImageSize -&amp;gt; Norm[cb] 15]&#xD;
     ]&#xD;
&#xD;
Trying out:&#xD;
&#xD;
    VisualizeTectonic[canddb, tectons]&#xD;
&#xD;
gives:&#xD;
&#xD;
![enter image description here][2]&#xD;
&#xD;
The red numbers now indicates possible candidates for each cell, black numbers are solved. Now it is time to eliminate numbers until we find the correct answer for each cell.&#xD;
&#xD;
We will start by defining two helper functions:&#xD;
&#xD;
    ClearAll[NeighbourQ, Neighbours]&#xD;
    NeighbourQ[p : {x_, y_}, p2 : {x2_, y2_}] := ChessboardDistance[p, p2] === 1&#xD;
    Neighbours[p : {x_, y_}] := Transpose[p + Transpose[{{-1, -1}, {-1, 0}, {-1, 1}, {0, -1}, {0, 1}, {1, -1}, {1, 0}, {1, 1}}]]&#xD;
&#xD;
to test if two cells are neighbours, and what the neighbours of a cell are, respectively.&#xD;
&#xD;
Now we can easily create a new function to delete candidates around cells that are solved:&#xD;
&#xD;
    Do[&#xD;
      {k, v} = List @@ Part[Normal[canddb], i];&#xD;
      If[Length[v] == 1,&#xD;
       neighbours = Neighbours[k];&#xD;
       Do[&#xD;
        If[KeyExistsQ[canddb, nb],&#xD;
          canddb[nb] = DeleteCases[canddb[nb], First[v]];&#xD;
          ];&#xD;
        ,&#xD;
        {nb, neighbours}&#xD;
        ]&#xD;
       ];&#xD;
      ,&#xD;
      {i, Length[canddb]}&#xD;
      ];&#xD;
&#xD;
Executing this and then calling `VisualizeTectonic[canddb, tectons]` gives:&#xD;
&#xD;
![enter image description here][3]&#xD;
&#xD;
We can also delete any candidate that matches a solved number inside a container:&#xD;
&#xD;
    (* delete candidates from singles in same tecton *)&#xD;
    Do[&#xD;
      values = canddb /@ t;&#xD;
      If[Length[values] &amp;gt; 1,&#xD;
       singles = Select[Transpose[{t, values}], Length[Last[#]] == 1 &amp;amp;];&#xD;
       nonsingles = Complement[t, singles[[All, 1]]];&#xD;
       (canddb[#1] = Complement[canddb[#1], Join @@ singles[[All, 2]]]) &amp;amp; /@ nonsingles&#xD;
      ]&#xD;
     ,&#xD;
      {t, tectons}&#xD;
     ];&#xD;
    &#xD;
    VisualizeTectonic[canddb, tectons]&#xD;
&#xD;
![enter image description here][4]&#xD;
&#xD;
If a candidate only appears once inside a container then that must be the position:&#xD;
&#xD;
    (* hidden singles *)&#xD;
    Do[&#xD;
      values = canddb /@ t;&#xD;
      values = Tally[Join @@ values];&#xD;
      values = Select[values, Last[#] == 1 &amp;amp;][[All, 1]];&#xD;
      If[Length[values] &amp;gt; 0,&#xD;
       Do[&#xD;
         If[ContainsAny[canddb[c], values],&#xD;
           canddb[c] = Intersection[canddb[c], values]&#xD;
           ];&#xD;
         ,&#xD;
         {c, t}&#xD;
         ];&#xD;
       ]&#xD;
      ,&#xD;
      {t, tectons}&#xD;
      ];&#xD;
    VisualizeTectonic[canddb, tectons]&#xD;
&#xD;
![enter image description here][5]&#xD;
&#xD;
We can even try some more elaborate tests in order to eliminate candidates:&#xD;
&#xD;
    (* in each tecton search for cells with numbers that appear at least twice then &#xD;
    look at their common neighbours: eliminate that number from the common neighbours *)&#xD;
    Do[&#xD;
      values = canddb /@ t;&#xD;
      values = Tally[Join @@ values];&#xD;
      values = Select[values, Last[#] &amp;gt; 1 &amp;amp;][[All, 1]];&#xD;
      Do[&#xD;
       cells = Select[t, MemberQ[canddb[#], v] &amp;amp;];&#xD;
       nb = Neighbours /@ cells;&#xD;
       nb = Intersection @@ nb;&#xD;
       nb = Complement[nb, cells]; (*strictly speaking not necessary I think *)&#xD;
       nb = Intersection[nb, Join @@ tectons];&#xD;
       If[Length[nb] &amp;gt; 0,&#xD;
        Do[&#xD;
          canddb[n] = DeleteCases[canddb[n], v];&#xD;
          ,&#xD;
          {n, nb}&#xD;
          ];&#xD;
        ];&#xD;
       ,&#xD;
       {v, values}&#xD;
       ]&#xD;
      ,&#xD;
      {t, tectons}&#xD;
      ];&#xD;
    VisualizeTectonic[canddb, tectons]&#xD;
&#xD;
![enter image description here][6]&#xD;
&#xD;
Lastly we can look at pairs of cells, if two adjacent cells both have the same 2 candidates left, then one can eliminate those two candidates from their common neighbours:&#xD;
&#xD;
    (* naked pairs *)&#xD;
    paircells = GatherBy[KeyValueMap[List, Select[canddb, Length[#] == 2 &amp;amp;]], Sort@*Last][[All, All, 1]];&#xD;
    pairedpaircells = Select[paircells, Length[#] &amp;gt; 1 &amp;amp;];&#xD;
    pairedpaircells = Join @@ (Subsets[#, {2}] &amp;amp; /@ pairedpaircells);&#xD;
    pairedpaircells = Select[pairedpaircells, NeighbourQ @@ # &amp;amp;];&#xD;
    neigbours = Intersection[##, Keys[canddb]] &amp;amp; @@@ Map[Neighbours, pairedpaircells, {2}];&#xD;
    vals = canddb /@ pairedpaircells[[All, 1]];&#xD;
    del = Transpose[{neigbours, vals}];&#xD;
    Do[&#xD;
      {nb, v} = d;&#xD;
      Do[&#xD;
       canddb[n] = Complement[canddb[n], v]&#xD;
       ,&#xD;
       {n, nb}&#xD;
       ]&#xD;
      ,&#xD;
      {d, del}&#xD;
      ];&#xD;
    VisualizeTectonic[canddb, tectons]&#xD;
&#xD;
![enter image description here][7]&#xD;
&#xD;
We can now execute the above code-pieces repeatedly to further eliminate all the candidates and solve the puzzle:&#xD;
&#xD;
![enter image description here][8]&#xD;
&#xD;
Here is all the code and a while loop that iterates the candidate-elimination functions until there is not progress any more:&#xD;
&#xD;
    ClearAll[VisualizeTectonic, VisualizeTectonicSideHelper, VisualizeTectonicNumberHelper, NeighbourQ, Neighbours]&#xD;
    VisualizeTectonicNumberHelper[{row_, column_}, cand_List] := Module[{p, l, poss, t},&#xD;
      l = Length[cand];&#xD;
      p = {column, -row};&#xD;
      If[l == 1,&#xD;
       Text[Style[First[cand], Black, 17], p]&#xD;
       ,&#xD;
       MapThread[Text[Style[#1, 12, Red], #2] &amp;amp;, {cand, CirclePoints[p, 0.2, l]}]&#xD;
       ]&#xD;
      ]&#xD;
    VisualizeTectonicSideHelper[tecton_List] := Module[{p, sides},&#xD;
      p = {#2, -#1} &amp;amp; @@@ tecton;&#xD;
      sides = Partition[{# + {-0.5, -0.5}, # + {0.5, -0.5}, # + {0.5, 0.5}, # + {-0.5, 0.5}}, 2, 1, 1] &amp;amp; /@ p;&#xD;
      sides = Join @@ sides;&#xD;
      sides = Tally[Sort /@ sides];&#xD;
      Table[If[Last[s] == 1, {Thickness[0.01], Line[First[s]]}, Line[First[s]]], {s, sides}]&#xD;
      ]&#xD;
    VisualizeTectonic[canddb_Association, tectons_List] := &#xD;
     Module[{nums, sides, cb},&#xD;
      nums = KeyValueMap[VisualizeTectonicNumberHelper, canddb];&#xD;
      sides = VisualizeTectonicSideHelper /@ tectons;&#xD;
      cb = #2 - #1 &amp;amp; @@@ CoordinateBounds[Transpose[Join @@ tectons]];&#xD;
      Graphics[{nums, sides}, ImageSize -&amp;gt; Norm[cb] 15]&#xD;
      ]&#xD;
    NeighbourQ[p : {x_, y_}, p2 : {x2_, y2_}] := ChessboardDistance[p, p2] === 1&#xD;
    Neighbours[p : {x_, y_}] := Transpose[p + Transpose[{{-1, -1}, {-1, 0}, {-1, 1}, {0, -1}, {0, 1}, {1, -1}, {1, 0}, {1, 1}}]]&#xD;
    tectons = {&#xD;
       {{1, 1}, {1, 2}, {2, 1}, {2, 2}, {3, 1}},&#xD;
       {{1, 3}, {1, 4}, {1, 5}, {2, 3}, {2, 4}},&#xD;
       {{1, 6}, {1, 7}, {2, 5}, {2, 6}, {3, 5}},&#xD;
       {{1, 8}, {2, 7}, {2, 8}, {3, 6}, {3, 7}},&#xD;
       {{1, 9}, {2, 9}, {3, 9}, {4, 8}, {4, 9}},&#xD;
       {{3, 8}},&#xD;
       {{5, 8}},&#xD;
       {{5, 9}, {6, 8}, {6, 9}, {7, 8}, {7, 9}},&#xD;
       {{4, 6}, {4, 7}, {5, 6}, {5, 7}, {6, 7}},&#xD;
       {{5, 5}, {6, 5}, {6, 6}, {7, 4}, {7, 5}},&#xD;
       {{5, 2}, {5, 3}, {6, 3}, {6, 4}, {7, 3}},&#xD;
       {{3, 3}, {3, 4}, {4, 4}, {4, 5}, {5, 4}},&#xD;
       {{3, 2}, {4, 1}, {4, 2}, {4, 3}, {5, 1}},&#xD;
       {{6, 1}, {6, 2}, {7, 1}, {7, 2}},&#xD;
       {{7, 6}, {7, 7}}&#xD;
       };&#xD;
    givens = &amp;lt;|&#xD;
       {1, 1} -&amp;gt; 1,&#xD;
       {2, 2} -&amp;gt; 2,&#xD;
       {3, 1} -&amp;gt; 4,&#xD;
       {1, 4} -&amp;gt; 1,&#xD;
       {2, 8} -&amp;gt; 3,&#xD;
       {3, 3} -&amp;gt; 4,&#xD;
       {3, 9} -&amp;gt; 4,&#xD;
       {4, 4} -&amp;gt; 1,&#xD;
       {5, 1} -&amp;gt; 4,&#xD;
       {5, 3} -&amp;gt; 5,&#xD;
       {5, 5} -&amp;gt; 4,&#xD;
       {5, 7} -&amp;gt; 5,&#xD;
       {6, 8} -&amp;gt; 3,&#xD;
       {7, 5} -&amp;gt; 2,&#xD;
       {7, 9} -&amp;gt; 5&#xD;
       |&amp;gt;;&#xD;
    &#xD;
    If[! DuplicateFreeQ[Join @@ tectons], Print[&amp;#034;Cells have to be unique among tectonics&amp;#034;]; Abort[];];&#xD;
    canddb = With[{x = #}, {#, Range[Length[x]]} &amp;amp; /@ x] &amp;amp; /@ tectons;&#xD;
    canddb = Association[Rule @@@ (Join @@ canddb)];&#xD;
    KeyValueMap[(canddb[#1] = {#2}) &amp;amp;, givens];&#xD;
&#xD;
    VisualizeTectonic[canddb, tectons]&#xD;
    &#xD;
    oldcanddb = 1;&#xD;
    While[oldcanddb =!= canddb,&#xD;
     oldcanddb = canddb;&#xD;
     &#xD;
     (* delete from neighbours of singles *)&#xD;
     Do[&#xD;
      {k, v} = List @@ Part[Normal[canddb], i];&#xD;
      If[Length[v] == 1,&#xD;
       neighbours = Neighbours[k];&#xD;
       Do[&#xD;
        If[KeyExistsQ[canddb, nb],&#xD;
          canddb[nb] = DeleteCases[canddb[nb], First[v]];&#xD;
          ];&#xD;
        ,&#xD;
        {nb, neighbours}&#xD;
        ]&#xD;
       ];&#xD;
      ,&#xD;
      {i, Length[canddb]}&#xD;
      ];&#xD;
     &#xD;
     (* delete candidates from singles in same tecton *)&#xD;
     Do[&#xD;
      values = canddb /@ t;&#xD;
      If[Length[values] &amp;gt; 1,&#xD;
       singles = Select[Transpose[{t, values}], Length[Last[#]] == 1 &amp;amp;];&#xD;
       nonsingles = Complement[t, singles[[All, 1]]];&#xD;
       (canddb[#1] = Complement[canddb[#1], Join @@ singles[[All, 2]]]) &amp;amp; /@ nonsingles&#xD;
       ]&#xD;
      ,&#xD;
      {t, tectons}&#xD;
      ];&#xD;
     &#xD;
     (* hidden singles *)&#xD;
     Do[&#xD;
      values = canddb /@ t;&#xD;
      values = Tally[Join @@ values];&#xD;
      values = Select[values, Last[#] == 1 &amp;amp;][[All, 1]];&#xD;
      If[Length[values] &amp;gt; 0,&#xD;
       Do[&#xD;
         If[ContainsAny[canddb[c], values],&#xD;
           canddb[c] = Intersection[canddb[c], values]&#xD;
           ];&#xD;
         ,&#xD;
         {c, t}&#xD;
         ];&#xD;
       ]&#xD;
      ,&#xD;
      {t, tectons}&#xD;
      ];&#xD;
     &#xD;
     (* in each tecton search for cells with numbers that appear at least \&#xD;
    twice then look at their common neighbours: eliminate that number \&#xD;
    from the common neighbours *)&#xD;
     Do[&#xD;
      values = canddb /@ t;&#xD;
      values = Tally[Join @@ values];&#xD;
      values = Select[values, Last[#] &amp;gt; 1 &amp;amp;][[All, 1]];&#xD;
      Do[&#xD;
       cells = Select[t, MemberQ[canddb[#], v] &amp;amp;];&#xD;
       nb = Neighbours /@ cells;&#xD;
       nb = Intersection @@ nb;&#xD;
       nb = Complement[nb, cells]; (* strictly speaking not necessary I think *)&#xD;
       nb = Intersection[nb, Join @@ tectons];&#xD;
       If[Length[nb] &amp;gt; 0,&#xD;
        Do[&#xD;
          canddb[n] = DeleteCases[canddb[n], v];&#xD;
          ,&#xD;
          {n, nb}&#xD;
          ];&#xD;
        ];&#xD;
       ,&#xD;
       {v, values}&#xD;
       ]&#xD;
      ,&#xD;
      {t, tectons}&#xD;
      ];&#xD;
     &#xD;
     (* pairs *)&#xD;
     paircells = GatherBy[KeyValueMap[List, Select[canddb, Length[#] == 2 &amp;amp;]], Sort@*Last][[All, All, 1]];&#xD;
     pairedpaircells = Select[paircells, Length[#] &amp;gt; 1 &amp;amp;];&#xD;
     pairedpaircells = Join @@ (Subsets[#, {2}] &amp;amp; /@ pairedpaircells);&#xD;
     pairedpaircells = Select[pairedpaircells, NeighbourQ @@ # &amp;amp;];&#xD;
     neigbours = Intersection[##, Keys[canddb]] &amp;amp; @@@ Map[Neighbours, pairedpaircells, {2}];&#xD;
     vals = canddb /@ pairedpaircells[[All, 1]];&#xD;
     del = Transpose[{neigbours, vals}];&#xD;
     Do[&#xD;
      {nb, v} = d;&#xD;
      Do[&#xD;
       canddb[n] = Complement[canddb[n], v]&#xD;
       ,&#xD;
       {n, nb}&#xD;
       ]&#xD;
      ,&#xD;
      {d, del}&#xD;
      ];&#xD;
     &#xD;
     ]&#xD;
    VisualizeTectonic[canddb, tectons]&#xD;
&#xD;
# Brute force solver #&#xD;
&#xD;
This however does not solve all puzzles:&#xD;
&#xD;
    tectons = {&#xD;
      {{1, 1}, {1, 2}, {2, 1}, {3, 1}, {4, 1}},&#xD;
      {{1, 3}, {1, 4}, {2, 2}, {2, 3}, {3, 2}},&#xD;
      {{1, 5}, {2, 4}, {2, 5}, {3, 3}, {3, 4}},&#xD;
      {{1, 6}, {1, 7}, {2, 7}, {2, 8}, {3, 8}},&#xD;
      {{1, 8}, {1, 9}, {1, 10}, {1, 11}, {2, 9}},&#xD;
      {{1, 12}, {2, 12}},&#xD;
      {{2, 6}, {3, 5}, {3, 6}, {3, 7}, {4, 5}},&#xD;
      {{2, 10}, {2, 11}, {3, 11}, {3, 12}, {4, 12}},&#xD;
      {{3, 9}, {3, 10}, {4, 8}, {4, 9}, {4, 10}},&#xD;
      {{4, 2}, {4, 3}, {5, 1}, {5, 2}, {6, 1}},&#xD;
      {{4, 4}, {5, 4}, {5, 5}, {5, 6}, {6, 5}},&#xD;
      {{4, 6}, {4, 7}, {5, 7}, {5, 8}, {6, 8}},&#xD;
      {{4, 11}, {5, 10}, {5, 11}, {5, 12}, {6, 11}},&#xD;
      {{5, 3}, {6, 3}, {6, 4}, {7, 4}, {7, 5}},&#xD;
      {{6, 6}},&#xD;
      {{6, 7}, {7, 7}, {8, 7}, {8, 8}, {9, 7}},&#xD;
      {{7, 8}, {7, 9}, {8, 9}, {8, 10}, {9, 10}},&#xD;
      {{8, 11}},&#xD;
      {{5, 9}, {6, 9}, {6, 10}, {7, 10}, {7, 11}},&#xD;
      {{6, 12}, {7, 12}, {8, 12}, {9, 11}, {9, 12}},&#xD;
      {{10, 12}},&#xD;
      {{9, 8}, {9, 9}, {10, 9}, {10, 10}, {10, 11}},&#xD;
      {{9, 6}, {10, 5}, {10, 6}, {10, 7}, {10, 8}},&#xD;
      {{9, 1}, {10, 1}, {10, 2}, {10, 3}, {10, 4}},&#xD;
      {{7, 1}, {8, 1}, {8, 2}, {9, 2}, {9, 3}},&#xD;
      {{6, 2}, {7, 2}, {7, 3}, {8, 3}, {8, 4}},&#xD;
      {{7, 6}, {8, 5}, {8, 6}, {9, 4}, {9, 5}}&#xD;
      };&#xD;
    &#xD;
    givens = &amp;lt;|&#xD;
      {1, 1} -&amp;gt; 3,&#xD;
      {3, 1} -&amp;gt; 1,&#xD;
      {1, 3} -&amp;gt; 4,&#xD;
      {1, 5} -&amp;gt; 3,&#xD;
      {1, 10} -&amp;gt; 2,&#xD;
      {2, 12} -&amp;gt; 2,&#xD;
      {3, 11} -&amp;gt; 5,&#xD;
      {5, 1} -&amp;gt; 2,&#xD;
      {5, 8} -&amp;gt; 5,&#xD;
      {5, 11} -&amp;gt; 4,&#xD;
      {6, 3} -&amp;gt; 2,&#xD;
      {7, 1} -&amp;gt; 5,&#xD;
      {7, 11} -&amp;gt; 5,&#xD;
      {7, 12} -&amp;gt; 3,&#xD;
      {8, 6} -&amp;gt; 3,&#xD;
      {9, 9} -&amp;gt; 5,&#xD;
      {9, 12} -&amp;gt; 5,&#xD;
      {10, 2} -&amp;gt; 5,&#xD;
      {10, 8} -&amp;gt; 3&#xD;
      |&amp;gt;;&#xD;
&#xD;
Which can be solved till the following state using the above techniques:&#xD;
&#xD;
![enter image description here][9]&#xD;
&#xD;
We can now define this depth-first recursive backtracking algorithm:&#xD;
&#xD;
    ClearAll[ValidGridQ, BackTrackHelper, BackTrack]&#xD;
    ValidGridQ[canddb_Association, tectons_, lastkey_] := Module[{vals, tecton, nbs},&#xD;
      nbs = Neighbours[lastkey];&#xD;
      nbs = Intersection[nbs, Keys[canddb]]; (* neighbours that exist *)&#xD;
      nbs = First /@ Select[canddb /@ nbs, Length[#] == 1 &amp;amp;]; (* get the values of neighbours with a single value *)&#xD;
      If[FreeQ[nbs, First@canddb[lastkey]], (* if this does not contain the &amp;#039;set&amp;#039; one *)&#xD;
       tecton = SelectFirst[tectons, MemberQ[lastkey]];&#xD;
       vals = canddb /@ tecton;&#xD;
       If[ContainsAll[Flatten[vals], Range[Length[tecton]]], (* each tecton still has all its values in it *)&#xD;
        vals = First /@ Select[vals, Length[#] == 1 &amp;amp;];&#xD;
        DuplicateFreeQ[vals] (* and these set values does not have duplicates *)&#xD;
        ,&#xD;
        False&#xD;
        ]&#xD;
       ,&#xD;
       False&#xD;
       ]&#xD;
      ]&#xD;
    BackTrackHelper[candidatesdb_Association, tectons_] := Module[{nextkey, options, copy},&#xD;
      nextkey = First[Keys[Select[candidatesdb, Length[#] &amp;gt; 1 &amp;amp;]], Missing[]];&#xD;
      If[Not[MissingQ[nextkey]],&#xD;
       options = candidatesdb[nextkey];&#xD;
       Do[&#xD;
        copy = candidatesdb;&#xD;
        copy[nextkey] = {o};&#xD;
        If[ValidGridQ[copy, tectons, nextkey], BackTrackHelper[copy, tectons]]&#xD;
        ,&#xD;
        {o, options}&#xD;
        ]&#xD;
       ,&#xD;
       Throw[candidatesdb];&#xD;
       ]&#xD;
      ]&#xD;
    BackTrack[candidatesdb_Association, tectons_] := Catch[BackTrackHelper[candidatesdb, tectons]; Missing[]]&#xD;
&#xD;
Calling the function and visualizing the output:&#xD;
&#xD;
    canddb = BackTrack[canddb, tectons];&#xD;
    VisualizeTectonic[canddb, tectons]&#xD;
&#xD;
![enter image description here][10]&#xD;
&#xD;
Which is correct! I hope you enjoyed this little solver code. Some related solvers I made can be found here:&#xD;
&#xD;
 - [Solving a KenKen puzzle using logic][11]&#xD;
 - [Solving the UK Intelligence Agency&amp;#039;s Christmas Puzzle][12]&#xD;
 - [Solving Hidato, Beehive, and Numbrix puzzles][13]&#xD;
&#xD;
Most of these solvers work in a similar manner: elimination of candidates.&#xD;
&#xD;
  [1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=11951.png&amp;amp;userId=73716&#xD;
  [2]: http://community.wolfram.com//c/portal/getImageAttachment?filename=83692.png&amp;amp;userId=73716&#xD;
  [3]: http://community.wolfram.com//c/portal/getImageAttachment?filename=70763.png&amp;amp;userId=73716&#xD;
  [4]: http://community.wolfram.com//c/portal/getImageAttachment?filename=36914.png&amp;amp;userId=73716&#xD;
  [5]: http://community.wolfram.com//c/portal/getImageAttachment?filename=86955.png&amp;amp;userId=73716&#xD;
  [6]: http://community.wolfram.com//c/portal/getImageAttachment?filename=45396.png&amp;amp;userId=73716&#xD;
  [7]: http://community.wolfram.com//c/portal/getImageAttachment?filename=72907.png&amp;amp;userId=73716&#xD;
  [8]: http://community.wolfram.com//c/portal/getImageAttachment?filename=86068.png&amp;amp;userId=73716&#xD;
  [9]: http://community.wolfram.com//c/portal/getImageAttachment?filename=70249.png&amp;amp;userId=73716&#xD;
  [10]: http://community.wolfram.com//c/portal/getImageAttachment?filename=1033810.png&amp;amp;userId=73716&#xD;
  [11]: http://community.wolfram.com/groups/-/m/t/613040&#xD;
  [12]: http://community.wolfram.com/groups/-/m/t/755538&#xD;
  [13]: http://community.wolfram.com/groups/-/m/t/892653</description>
    <dc:creator>Sander Huisman</dc:creator>
    <dc:date>2017-04-30T23:03:19Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/148287">
    <title>Folds in a sheet of paper / metal / cloth</title>
    <link>https://community.wolfram.com/groups/-/m/t/148287</link>
    <description>I am an artist, drawing and working with 3d. Since long time, I am missing a method to form realistic folds and wrinkles into virtual sheets of paper, metal or cloth. I found some attempts within 3d-programs, but I never saw something that was not very limited or looked like rubber. Because it is so easy at reality, but so difficult at the computer, I think there is just little mathematical base.First of all: Could anybody tell me, what field of mathematics this is?&#xD;
&#xD;
&#xD;
[img=width: 800px; height: 1132px; ]/c/portal/getImageAttachment?filename=Folds-01.jpg&amp;amp;userId=145842[/img]&#xD;
&#xD;
[img=width: 800px; height: 1132px; ]/c/portal/getImageAttachment?filename=Folds-02.jpg&amp;amp;userId=145842[/img]</description>
    <dc:creator>Dietmar Klein</dc:creator>
    <dc:date>2013-11-03T23:03:23Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/897081">
    <title>OOP environment for Mathematica without additional packages</title>
    <link>https://community.wolfram.com/groups/-/m/t/897081</link>
    <description>I&amp;#039;d like to introduce the OOP environment for Mathematica, with no-additional packages. &#xD;
&#xD;
Mathematica has many style of paradigm, however, the programming style of OOP is an old but not sufficient backed-up environment. Let&amp;#039;s consider the function group UpSet. UpSet has been seemed the basic idea relating OOP and the function group being equipped from the first version, but you can see the description of the function group is so small and short in the manual. &#xD;
&#xD;
Now, the UpSet function becomes the most important function because the function group is the key parts to establish the OOP environment. With very small size pattern of CLASS constructed with SetDelayed UpSetDelayed, and Module leads to the OOP paradigm. This paradigm includes Encapsulation, inheritance, and Polymorphism in very straight forward style. OOP on the Mathematica suits for Graphics, Events, and the Dynamic directly and give us new kind of power for Mathematica programming.&#xD;
&#xD;
The method is very easy as follows. Basically, you define the CLASS which is &amp;#034;SetDelayed definition of Module-d UpSetDelyaed functions&amp;#034;, you construct INSTANCES distinguished by the name having each local values, and each INSTANCE functions when you send name conbined MESSAGES defined in the CLASS. In the following code, class name is &amp;#034;pclass&amp;#034;, two method named &amp;#034;set&amp;#034; and &amp;#034;get&amp;#034;, object list name is &amp;#034;object&amp;#034;. In my definition, OBJECT is the group name of INSTANCE created from CLASS.&#xD;
&#xD;
    (*prepare class*)&#xD;
    pclass[nam_] := Module[{local = 0},&#xD;
      set[nam[x_]] ^:= local = x;&#xD;
      get[nam] ^:= local^2;]&#xD;
    (*prepare object list*)&#xD;
    object = Table[Unique[], {10}];&#xD;
    (*create instances*)&#xD;
    Table[pclass[object[[i]]], {i, 10}];&#xD;
    (*send message to set local values of instances*)&#xD;
    Table[set[object[[i]][i]], {i, 10}];&#xD;
    (*send message to get results of instances*)&#xD;
    Table[get[object[[i]]], {i, 10}]&#xD;
&#xD;
    {1, 4, 9, 16, 25, 36, 49, 64, 81, 100}&#xD;
&#xD;
I hope you enjoy the new paradigm.&#xD;
&#xD;
In [Google slide][1], you can see more detailed OOP discussion.&#xD;
&#xD;
  [1]: https://docs.google.com/presentation/d/1U9m4k0Z5KMmulgPRTPWUPbePY1MB2t3FMG4aCxk34uM/pub?start=false&amp;amp;loop=false&amp;amp;delayms=3000</description>
    <dc:creator>Hirokazu Kobayashi</dc:creator>
    <dc:date>2016-08-01T02:15:54Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/1112012">
    <title>BVH accelerated 3D shadow mapping</title>
    <link>https://community.wolfram.com/groups/-/m/t/1112012</link>
    <description>[Shadow mapping][1] is a process of applying shadows to a computer graphic.  `Graphics3D` allows the user to specify lighting conditions for the surfaces of 3D graphical primitives, however, visualising the shadow an object projects onto a surface requires the processes of shadow mapping.  Each pixel of the projection surface must check if it is visible from the light source; if this check returns false then the pixel forms a shadow.  This becomes a problem of geometric intersections, i.e., for this case, the intersection between a line and a triangle.  For a 3D model with 100s and more of polygons, repeated intersection tests across the entire model for each pixel is an extremely costly (and inefficient) task.  Now this becomes a problem of search optimisation.    &#xD;
&#xD;
![enter image description here][2]&#xD;
&#xD;
&#xD;
Obtaining Data&#xD;
--------------&#xD;
&#xD;
This project uses 3D models from [SketchUp&amp;#039;s online repository][3] which are converted to COLLADA files using SketchUp.  The functions used are held in a package, accessible via [github][4] along with all the data referenced throughout.&#xD;
&#xD;
    (* load package and 3D model *)&#xD;
    &amp;lt;&amp;lt; &amp;#034;https://raw.githubusercontent.com/b-goodman/\&#xD;
    GeometricIntersections3D/master/GeometricIntersections3D.wl&amp;#034;;&#xD;
    &#xD;
    modelPath = &#xD;
      &amp;#034;https://raw.githubusercontent.com/b-goodman/\&#xD;
    GeometricIntersections3D/master/Demo/House/houseModel4.dae&amp;#034;;&#xD;
    &#xD;
    (* vertices of model&amp;#039;s polygons *)&#xD;
    polyPoints = Delete[0]@Import[modelPath, &amp;#034;PolygonObjects&amp;#034;];&#xD;
    &#xD;
    (* import model as region *)&#xD;
    modelRegion = Import[modelPath, &amp;#034;MeshRegion&amp;#034;];&#xD;
    &#xD;
    (* use region to generate minimal bounding volume *)&#xD;
    cuboidPartition = Delete[0]@BoundingRegion[modelRegion, &amp;#034;MinCuboid&amp;#034;];&#xD;
    &#xD;
    (* verify *)&#xD;
    Graphics3D[{&#xD;
      Polygon[polyPoints],&#xD;
      {Hue[0, 0, 0, 0], EdgeForm[Black], Cuboid[cuboidPartition]}&#xD;
      }, Boxed -&amp;gt; False]&#xD;
&#xD;
![imported model data][5]&#xD;
&#xD;
Generate a Bounding Volume Hierarchy (BVH)&#xD;
------------------------------------------&#xD;
&#xD;
Shadow mapping (and more generally collision testing) may be optimised via space partitioning achieved by dividing the 3D model&amp;#039;s space into a hierarchy of bounding volumes (BV) stored as a graph, thus forming a [bounding volume hierarchy][6].  The simplest case uses the result of an intersection between a ray and a single BV for the entire model to discard all rays which don&amp;#039;t come close to any of the model&amp;#039;s polygons.  Of course, those which do pass the first test must still be tested against the entire model so the initial BV is subdivided with each sub BV assigned to a particular part of the model hence reducing the total amount of polygons to be tested against.  The initial BV forms the root of the tree and it&amp;#039;s subdivisions (leaf boxes) are joined via edges.  We can add more levels to the tree by repeating the subdivision for each of the leaf boxes and ultimately refining the search for potential intersecting polygons.   &#xD;
&#xD;
    (* Begin tree.  Initial AABB is root.  Subdivide root AABB and link returns to root *) &#xD;
    newBVH[cuboidPartitions_,polyPoints_]:=Block[{&#xD;
    newLevel,edges&#xD;
    },&#xD;
    newLevel=Quiet[cullIntersectingPartitions[cuboidSubdivide[cuboidPartitions],polyPoints]];&#xD;
    edges=cuboidPartitions\[DirectedEdge]#&amp;amp;/@newLevel;&#xD;
    Return[&amp;lt;|&#xD;
    &amp;#034;Tree&amp;#034;-&amp;gt;TreeGraph[edges],&#xD;
    &amp;#034;PolygonObjects&amp;#034;-&amp;gt;polyPoints&#xD;
    |&amp;gt;];&#xD;
    ];&#xD;
&#xD;
    bvh = newBVH[{cuboidPartition}, polyPoints];&#xD;
    &#xD;
The BVH is a tree graph with the model&amp;#039;s polygon vertices encapsulated within an association&#xD;
&#xD;
    Keys[bvh]&#xD;
    &#xD;
    {&amp;#034;Tree&amp;#034;, &amp;#034;PolygonObjects&amp;#034;}&#xD;
    &#xD;
The BVH consists of a root box derived from the model&amp;#039;s minimal  bounding volume and it&amp;#039;s 8 sub-divisions &#xD;
&#xD;
    bvh[&amp;#034;Tree&amp;#034;]&#xD;
&#xD;
![enter image description here][7]&#xD;
&#xD;
The boxes at the lowest level of the BVH are the leaf boxes &#xD;
&#xD;
    leafBoxesLV1 = &#xD;
      Select[VertexList[bvh[&amp;#034;Tree&amp;#034;]], &#xD;
       VertexOutDegree[bvh[&amp;#034;Tree&amp;#034;], #] == 0 &amp;amp;];&#xD;
    &#xD;
    Graphics3D[{&#xD;
      Polygon[polyPoints],&#xD;
      {Hue[0, 0, 0, 0], EdgeForm[Black], Cuboid /@ leafBoxesLV1}&#xD;
      }, Boxed -&amp;gt; False]&#xD;
&#xD;
![enter image description here][8]&#xD;
&#xD;
Adding a new level sub-divides each leaf box into 8 sub-divisions. &#xD;
&#xD;
    With[{&#xD;
      testCuboid = {{0, 0, 0}, {10, 10, 10}}&#xD;
      },&#xD;
     Manipulate[&#xD;
      Graphics3D[{&#xD;
        If[n == 0, Cuboid[testCuboid], &#xD;
         Cuboid /@ Nest[cuboidSubdivide, testCuboid, n]]&#xD;
        }, Boxed -&amp;gt; False, Axes -&amp;gt; {True, False}],&#xD;
      {{n, 0}, 0, 4, 1}&#xD;
      ]&#xD;
     ]&#xD;
&#xD;
![enter image description here][9]&#xD;
&#xD;
The time needed for each addition to the BVH increases dramatically.&#xD;
&#xD;
    Length /@ NestList[cuboidSubdivide, {{{0, 0, 0}, {1, 1, 1}}}, 5]&#xD;
    &#xD;
     {1, 8, 64, 512, 4096, 32768}&#xD;
&#xD;
1-2 added levels is usually enough for the models used in this project.&#xD;
&#xD;
    (* Each new subdivision acts as root.  For each, subdivide further and remove any non-intersecting boxes.  Link back to parent box as directed edge *)&#xD;
    addLevelBVH[BVH_]:=Block[{&#xD;
    tree=BVH[&amp;#034;Tree&amp;#034;],polyPoints=BVH[&amp;#034;PolygonObjects&amp;#034;],returnEdges&#xD;
    },&#xD;
    Module[{&#xD;
    subEdges=Map[&#xD;
    Function[{levelComponent},levelComponent\[DirectedEdge]#&amp;amp;/@Quiet@cullIntersectingPartitions[cuboidSubdivide[levelComponent],polyPoints]],&#xD;
    Pick[VertexList[tree],VertexOutDegree[tree],0]]&#xD;
    },&#xD;
    returnEdges=ConstantArray[0,Length[subEdges]];&#xD;
    Do[returnEdges[[i]]=EdgeAdd[tree,subEdges[[i]]],{i,1,Length[subEdges],1}];&#xD;
    ];&#xD;
    returnEdges=DeleteDuplicates[Flatten[Join[EdgeList/@returnEdges]]];&#xD;
    Return[&amp;lt;|&#xD;
    &amp;#034;Tree&amp;#034;-&amp;gt;TreeGraph[returnEdges],&#xD;
    &amp;#034;PolygonObjects&amp;#034;-&amp;gt;polyPoints&#xD;
    |&amp;gt;]&#xD;
    ];&#xD;
&#xD;
 &#xD;
    bvh2 = addLevelBVH[bvh];&#xD;
    bvh2[&amp;#034;Tree&amp;#034;]&#xD;
&#xD;
![enter image description here][10]&#xD;
&#xD;
Any subs which don&amp;#039;t intersect with the model don&amp;#039;t contribute to the BVH and so are removed as part of the process.&#xD;
&#xD;
    cullIntersectingPartitions=Compile[{&#xD;
    {cuboidPartitions,_Real,3},&#xD;
    {polyPoints,_Real,3}&#xD;
    },&#xD;
    Select[cuboidPartitions,Function[{partitions},MemberQ[ParallelMap[Quiet@intersectTriangleBox[partitions,#]&amp;amp;,polyPoints],True]]],&#xD;
    CompilationTarget-&amp;gt;&amp;#034;C&amp;#034;&#xD;
    ];&#xD;
&#xD;
&#xD;
Visualising the leaf boxes shows that empty BVs are removed.  &#xD;
&#xD;
    leafBoxesLV2 = &#xD;
      Select[VertexList[bvh2[&amp;#034;Tree&amp;#034;]], &#xD;
       VertexOutDegree[bvh2[&amp;#034;Tree&amp;#034;], #] == 0 &amp;amp;];&#xD;
    &#xD;
    Graphics3D[{&#xD;
      Polygon[polyPoints],&#xD;
      {Hue[0, 0, 0, 0], EdgeForm[Black], Cuboid /@ leafBoxesLV2}&#xD;
      }, Boxed -&amp;gt; False]&#xD;
&#xD;
![enter image description here][11]&#xD;
&#xD;
Once  all levels are added, the BVH is finalised by linking each leaf box to its associated polygons.  This does not effect the tree structure as the link association is held seperate.&#xD;
&#xD;
    (*For each outermost subdivision (leaf box), find intersecting polygons.  Link to intersecting box via directed edge.  Append to graph *)&#xD;
    finalizeBVH[BVH_]:=Block[{&#xD;
    (* all leaf boxes for BVH *)&#xD;
    leafBoxes=Select[&#xD;
    VertexList[BVH[&amp;#034;Tree&amp;#034;]],&#xD;
    VertexOutDegree[BVH[&amp;#034;Tree&amp;#034;],#]==0&amp;amp;&#xD;
    ],&#xD;
    (* setup temp association *)&#xD;
    temp=&amp;lt;||&amp;gt;,&#xD;
    (* block varaibles *)&#xD;
    leafPolygons,&#xD;
    leafPolygonsEdges&#xD;
    },&#xD;
    (* For each BVH leaf box *)&#xD;
    Do[&#xD;
    (* 3.1. intersecitng polygons for specified BVH leaf box *)&#xD;
    leafPolygons=Select[&#xD;
    BVH[&amp;#034;PolygonObjects&amp;#034;],&#xD;
    Quiet@intersectTriangleBox[leafBoxes[[i]],#]==True&amp;amp;&#xD;
    ];&#xD;
    (* 3.2. associate each specified BVH leaf box to its intersecting polygon(s) *)&#xD;
    AppendTo[temp,leafBoxes[[i]]-&amp;gt;leafPolygons],&#xD;
    {i,1,Length[leafBoxes],1}&#xD;
    ];&#xD;
    Return[&amp;lt;|&#xD;
    &amp;#034;Tree&amp;#034;-&amp;gt;BVH[&amp;#034;Tree&amp;#034;],&#xD;
    &amp;#034;LeafObjects&amp;#034;-&amp;gt;temp,&#xD;
    &amp;#034;PolygonObjects&amp;#034;-&amp;gt;BVH[&amp;#034;PolygonObjects&amp;#034;]&#xD;
    |&amp;gt;]&#xD;
    ];&#xD;
&#xD;
    bvh2 = finalizeBVH[bvh2];&#xD;
&#xD;
While it only needs doing once, generating the BVH is often the longest part of the procedure so it&amp;#039;s a good idea to export it on completion.&#xD;
&#xD;
&#xD;
Generating The Scene&#xD;
--------------------&#xD;
&#xD;
The scene is an encapsulation of all data and parameters used for the ray caster.  It&amp;#039;s initially structured as: &#xD;
    &#xD;
    scene=&amp;lt;|&#xD;
    &amp;#034;BVH&amp;#034;-&amp;gt;BVHobj,                               -- (*The BVH previously generated*)&#xD;
    &amp;#034;SourcePositions&amp;#034;-&amp;gt;lightingPath,      -- (*The 3D position(s) of the light source*)&#xD;
    &amp;#034;FrameCount&amp;#034;-&amp;gt;frameCount,            -- (*A timestep for animation and a parameter if lightingPath is continuous*)&#xD;
    &amp;#034;Refinement&amp;#034;-&amp;gt;rayRefinement,        -- (*Ray density; smaller values give finer results.*)&#xD;
    &amp;#034;ProjectionPoints&amp;#034;-&amp;gt;planeSpec,       -- (*3D points forming surface(s) that shadow(s) are cast onto.*)&#xD;
    &amp;#034;FrameData&amp;#034;-&amp;gt;&amp;lt;||&amp;gt;                           -- (*Initially empty, data from the ray caster will be stored here.*)&#xD;
    |&amp;gt;&#xD;
&#xD;
&#xD;
Generating The Projection Surface&#xD;
-----------------------------&#xD;
&#xD;
The house should look like its casting it&amp;#039;s shadow onto the earth so we define a list of points which represent the discrete plane it stands on.  Each ray is a line drawn between each point on the projection surface and the position of the scene&amp;#039;s light source.&#xD;
&#xD;
    (* rayRefinement *)&#xD;
    ref = 20;&#xD;
    (* the height of the projection surface *)&#xD;
    planeZoffset = 0;&#xD;
    (* the discrete projection surface - each point is the origin of a \&#xD;
    ray *)&#xD;
    projectionPts = &#xD;
      Catenate[Table[{x, y, planeZoffset}, {x, -900, 1200, ref}, {y, -600,&#xD;
          1000, ref}]];&#xD;
    &#xD;
    Graphics3D[{&#xD;
      Polygon[polyPoints],&#xD;
      Cuboid /@ ({##, ## + {ref, ref, 0}} &amp;amp; /@ projectionPts)&#xD;
      }, Axes -&amp;gt; True, AxesLabel -&amp;gt; {&amp;#034;X&amp;#034;, &amp;#034;Y&amp;#034;, &amp;#034;Z&amp;#034;}, ImageSize -&amp;gt; Large]&#xD;
&#xD;
![enter image description here][12]&#xD;
&#xD;
&#xD;
Specifying A Light Source&#xD;
-------------------------&#xD;
&#xD;
The light source is typically a continuous BSplineFunction which is sampled according to the number of frames the user wants.  But it may also be a discrete list of 3D points too (in which case the number of frames is equal to the length of the list).&#xD;
&#xD;
Using a modification of  a `SunPosition` example in the documentation, a list of the 3D Cartesian positions of the sun between sunrise and sunset, with a time step 30 minutes, is produced.&#xD;
&#xD;
![enter image description here][13]&#xD;
&#xD;
    solarPositionPts0[location_:Here, date_:DateValue[Now,{&amp;#034;Year&amp;#034;,&amp;#034;Month&amp;#034;,&amp;#034;Day&amp;#034;}],tSpec_:{30,&amp;#034;Minute&amp;#034;}]:=&#xD;
    Evaluate[CoordinateTransformData[&amp;#034;Spherical&amp;#034;-&amp;gt;&amp;#034;Cartesian&amp;#034;,&amp;#034;Mapping&amp;#034;,{1,\[Pi]/2-(#2 Degree),2Pi-(#1 Degree)}]]&amp;amp;@@@(Function[{series},Map[QuantityMagnitude,series[&amp;#034;Values&amp;#034;],{2}]]@SunPosition[location,DateRange[Sunrise[#],Sunset[#],tSpec]&amp;amp;[DateObject[date]]])&#xD;
&#xD;
    solarPositionPts[Here, DateObject[{2017, 6, 1}], {30, &amp;#034;Minute&amp;#034;}]&#xD;
    &#xD;
    {{0.4700, -0.88253, -0.0155}, {0.4026, -0.91178, 0.0809},...,{0.4219, 0.90493, 0.0554}}&#xD;
&#xD;
&#xD;
It&amp;#039;s easier to rotate the sun&amp;#039;s path rather than the model and projection plane.  Different transforms may also be applied to best-fit the path into the scene.&#xD;
&#xD;
    solarXoffset = 0;&#xD;
    solarYoffset = 0;&#xD;
    solarZoffset = 0;&#xD;
    zRotation = \[Pi]/3.5;&#xD;
    scale = 1300;&#xD;
    &#xD;
    sourceSpec = &#xD;
      RotationTransform[zRotation, {0, 0, 1}][&#xD;
        # + {solarXoffset, solarYoffset, solarZoffset} &amp;amp; /@ (solarPositionPts[Here, DateObject[{2017, 6, 1}], {30, &amp;#034;Minute&amp;#034;}] scale)&#xD;
      ];&#xD;
    &#xD;
    lightingPath = BSplineCurve[sourceSpec];&#xD;
&#xD;
&#xD;
&#xD;
Specify A Frame Count&#xD;
---------------------&#xD;
&#xD;
A frame count must be specified to discretize the light path into 3D points.  Each of these points forms the end of each ray.&#xD;
If the light source is a discrete list, then its length is used to infer the frame count instead and does not need specifying by the user.&#xD;
&#xD;
    frameCount = 30;&#xD;
&#xD;
&#xD;
Constructing The Scene&#xD;
----------------------&#xD;
&#xD;
Now we can preview the scene&#xD;
&#xD;
    Graphics3D[{&#xD;
      Polygon[polyPoints],&#xD;
      Cuboid /@ ({##, ## + {ref, ref, 0}} &amp;amp; /@ projectionPts),&#xD;
      lightingPath,&#xD;
      {Darker@Yellow, PointSize[0.03], &#xD;
       Point[BSplineFunction[sourceSpec] /@ Range[0, 1, N[1/frameCount]]]}&#xD;
      }, Axes -&amp;gt; True, AxesLabel -&amp;gt; {&amp;#034;X&amp;#034;, &amp;#034;Y&amp;#034;, &amp;#034;Z&amp;#034;}, ImageSize -&amp;gt; Large]&#xD;
&#xD;
![enter image description here][14]&#xD;
&#xD;
 All paramaters have been set, it&amp;#039;s time to construct the scene.  Specifying a continuous lighting path must be done using a `BSPlineCurve`.&#xD;
&#xD;
    scene = newScene[bvh2, lightingPath, frameCount, ref, projectionPts]&#xD;
&#xD;
![enter image description here][15]&#xD;
&#xD;
&#xD;
&#xD;
Processing A Scene For Shadow Mapping&#xD;
-------------------------------------&#xD;
&#xD;
The BVH optimises the ray caster by reducing the number of polygons to search against for an intersection.  If the ray intersects with the BVH root box then a breadth-first search along the BVH tree is initiated.  Starting with the root box,the out-components are selected by their intersection with a ray and are used as roots for the search&amp;#039;s next level.&#xD;
&#xD;
    (* select peripheral out-components of root box that intersect with ray *)&#xD;
    intersectingSubBoxes[BVHObj_,initialVertex_,rayOrigin_,raySource_]:=Select[Rest[VertexOutComponent[BVHObj[&amp;#034;Tree&amp;#034;],{initialVertex},1]],intersectRayBox[#,rayOrigin,raySource]==True&amp;amp;];&#xD;
&#xD;
    (* for root box intersecting rays, find which leaf box(es) intersect with ray *)&#xD;
    BVHLeafBoxIntersection[BVHObj_,rayInt_,rayDest_]:=Block[{v0},&#xD;
    (*initialize search *)v0=intersectingSubBoxes[BVHObj,VertexList[BVHObj[&amp;#034;Tree&amp;#034;]][[1]],rayInt,rayDest];&#xD;
    (* breadth search *)&#xD;
    If[v0=={},Return[v0],&#xD;
    While[&#xD;
    (* check that vertex isn&amp;#039;t a polygon - true if !0.  Check that intersection isn&amp;#039;t empty *)&#xD;
    AllTrue[VertexOutDegree[BVHObj[&amp;#034;Tree&amp;#034;],#]&amp;amp;/@v0,#=!=0&amp;amp;],&#xD;
    v0=Flatten[intersectingSubBoxes[BVHObj,#,rayInt,rayDest]&amp;amp;/@v0,1];&#xD;
    If[v0==={},Break[]]&#xD;
    ];&#xD;
    Return[v0];&#xD;
    ]&#xD;
    ];&#xD;
    &#xD;
&#xD;
The code below generates a visualisation of this process using the input data from the scene generated.&#xD;
&#xD;
    raySource = scene[&amp;#034;ProjectionPoints&amp;#034;][[3700]];&#xD;
    rayDestination = scene[&amp;#034;FrameData&amp;#034;][16][&amp;#034;SourcePosition&amp;#034;];&#xD;
    &#xD;
    lv1Intersection = &#xD;
      BVHLeafBoxIntersection[bvh, raySource, rayDestination];&#xD;
    lv2Intersection = &#xD;
      BVHLeafBoxIntersection[bvh2, raySource, rayDestination];&#xD;
    &#xD;
    lv1Subgraph = &#xD;
      Subgraph[Graph[EdgeList[bvh2[&amp;#034;Tree&amp;#034;]]], &#xD;
       First[VertexList[bvh2[&amp;#034;Tree&amp;#034;]]] \[DirectedEdge] # &amp;amp; /@ &#xD;
        lv1Intersection];&#xD;
    lv2Subgraphs = Subgraph[Graph[EdgeList[bvh2[&amp;#034;Tree&amp;#034;]]], Flatten[Table[&#xD;
         lv1Intersection[[&#xD;
             i]] \[DirectedEdge] # &amp;amp; /@ (Intersection[#, &#xD;
               lv2Intersection] &amp;amp; /@ ((Rest@&#xD;
                  VertexOutComponent[bvh2[&amp;#034;Tree&amp;#034;], #] &amp;amp; /@ &#xD;
                lv1Intersection)))[[i]],&#xD;
         {i, 1, Length[lv1Intersection], 1}&#xD;
         ], 1]];&#xD;
    lbl = ((#[[1]] -&amp;gt; #[[2]]) &amp;amp; /@ (Transpose[{lv2Intersection, &#xD;
           ToString /@ Range[Length[lv2Intersection]]}]));&#xD;
    edgeStyle = Join[&#xD;
       ReleaseHold@&#xD;
        Thread[(# -&amp;gt; HoldForm@{Thick, Blue}) &amp;amp;[EdgeList[lv2Subgraphs]]],&#xD;
       ReleaseHold@&#xD;
        Thread[(# -&amp;gt; HoldForm@{Thick, Red}) &amp;amp;[EdgeList[lv1Subgraph]]]&#xD;
       ];&#xD;
    &#xD;
    rayBVHTraversal = Graph[EdgeList[bvh2[&amp;#034;Tree&amp;#034;]], EdgeStyle -&amp;gt; edgeStyle,&#xD;
       VertexLabels -&amp;gt; lbl,&#xD;
       GraphHighlight -&amp;gt; lv2Intersection,&#xD;
       ImageSize -&amp;gt; Medium];&#xD;
    &#xD;
    rayModelIntersection = Graphics3D[{&#xD;
        {Green, Thickness[0.01], &#xD;
         Line[{raySource, rayDestination - {220, -400, 400}}]},&#xD;
        {Hue[0, 0, 0, 0], EdgeForm[{Thick, Red}], &#xD;
         Cuboid /@ lv1Intersection},&#xD;
        {Hue[.6, 1, 1, .3], EdgeForm[{Thick, Blue}], &#xD;
         Cuboid /@ lv2Intersection},&#xD;
        {Opacity[0.5], Polygon[polyPoints]},&#xD;
        Inset @@@ &#xD;
         Transpose[{ToString /@ Range[Length[lv2Intersection]], &#xD;
           RegionCentroid /@ Cuboid @@@ lv2Intersection}]&#xD;
        }];&#xD;
    &#xD;
    Column[{&#xD;
      Row[&#xD;
       Show[rayModelIntersection, ViewPoint -&amp;gt; #, Boxed -&amp;gt; False, &#xD;
          ImageSize -&amp;gt; Medium] &amp;amp; /@ {{-\[Infinity], 0, &#xD;
          0}, {0, -\[Infinity], 0}}&#xD;
       ],&#xD;
      rayBVHTraversal&#xD;
      }]&#xD;
&#xD;
![enter image description here][17]&#xD;
&#xD;
At the centre of the graph lies the vertex representing the root BV where all searches originate from.  The search continues out form all vertices which have intersected with the ray.&#xD;
&#xD;
&#xD;
    (* test intersection between ray and object polygon via BVH search *)&#xD;
    intersectionRayBVH[BVHObj_,rayOrigin_,rayDest_]:=With[{&#xD;
    intersectionLeafBoxes=BVHLeafBoxIntersection[BVHObj,rayOrigin,rayDest]&#xD;
    },&#xD;
    Block[{i},If[intersectionLeafBoxes=!={},&#xD;
    Return[Catch[For[i=1,i&amp;lt;Length[#],i++,&#xD;
    Function[{thowQ},If[thowQ,Throw[thowQ]]][intersectRayTriangle[#[[1]],#[[2]],#[[3]],rayOrigin,rayDest]&amp;amp;@#[[i]]]&#xD;
    ]&amp;amp;[DeleteDuplicates[Flatten[Lookup[BVHObj[&amp;#034;LeafObjects&amp;#034;],intersectionLeafBoxes],1]]]]===True],&#xD;
    Return[False]&#xD;
    ]]&#xD;
    ];&#xD;
&#xD;
Once the tree has been fully searched, the remaining boxes are used to lookup their associated polygons.  Since the same polygon may intersect more than one box, any duplicates are deleted.  A line-triangle intersection test is iteratively applied over the resultant list, breaking at the first instance of a True return.  This ray has now been found to intersect a part of the 3D model thus its origin point (from the `projectionPts` list) will represent a single point of shadow on the projection surface.  This point is stored in a list which will be used to draw the shadow for a single frame.  &#xD;
&#xD;
    candidatePolys = DeleteDuplicates[Flatten[Lookup[&#xD;
         bvh2[&amp;#034;LeafObjects&amp;#034;],&#xD;
         BVHLeafBoxIntersection[bvh2, raySource, rayDestination]&#xD;
         ], 1]];&#xD;
    &#xD;
    intersectingPolys = &#xD;
      Select[candidatePolys,PrimitiveIntersectionQ3D[Line[{raySource, rayDestination}],Triangle[#]] &amp;amp;];&#xD;
    &#xD;
    rayModelIntersectionPolys = Graphics3D[{&#xD;
        {Green, Thickness[0.01], &#xD;
         Line[{raySource, rayDestination - {220, -400, 400}}]},&#xD;
        {Hue[1, 1, 1, .5], EdgeForm[Black], Polygon[candidatePolys]},&#xD;
        {Hue[0.3, 1, 1, .5], Polygon[intersectingPolys]}&#xD;
        }, Boxed -&amp;gt; False];&#xD;
    &#xD;
    Row[Show[rayModelIntersectionPolys, ViewPoint -&amp;gt; #, ImageSize -&amp;gt; Medium] &amp;amp; /@ {{0, 0, \[Infinity]}, {0, \[Infinity], 0}}]&#xD;
&#xD;
Highlighted in green, the ray has been found to intersect with 2 polygons.&#xD;
&#xD;
![enter image description here][18]&#xD;
&#xD;
The BVH search is performed for each ray, for each frame.&#xD;
&#xD;
A scene is the input for the ray caster.  If a scene is to be re-processed with different parameters then a new scene must be made.&#xD;
The output of the ray caster is held within a scene object.  The data for each frame is associated to its frame index and is all held in the scene&amp;#039;s &amp;#034;FrameData&amp;#034; field.&#xD;
&#xD;
Begin processing.  A status bar will indicate progress in terms of frames rendered.&#xD;
&#xD;
    scene = renderScene[scene];&#xD;
&#xD;
it&amp;#039;s best to save any progress by exporting afterwards.&#xD;
&#xD;
    Export[&amp;#034;House_scene.txt&amp;#034;, Compress[scene]]&#xD;
&#xD;
&#xD;
Reviewing Processed Scenes&#xD;
--------------------------&#xD;
&#xD;
Each frame holds the shadow and ground data separately and have been expressed as zero-thickness cuboids (tiles) and each with side length equal to the `rayRefinement` parameter (recall that smaller values yield finer results).&#xD;
&#xD;
Individual frames are accessed by their frame index.  This examines frame 10.&#xD;
&#xD;
    Keys[scene[&amp;#034;FrameData&amp;#034;][10]]&#xD;
    &#xD;
    {&amp;#034;ShadowPts&amp;#034;, &amp;#034;SourcePosition&amp;#034;, &amp;#034;GroundPts&amp;#034;}&#xD;
&#xD;
&#xD;
Accessing the processed scene&amp;#039;s &amp;#034;FrameData&amp;#034; field allows a single specified frame to be drawn in Graphics3D.&#xD;
&#xD;
    Graphics3D[{&#xD;
      Polygon[scene[&amp;#034;BVH&amp;#034;][&amp;#034;PolygonObjects&amp;#034;]],&#xD;
      {GrayLevel[0.3], EdgeForm[], &#xD;
       Cuboid /@ scene[&amp;#034;FrameData&amp;#034;][10][&amp;#034;ShadowPts&amp;#034;]},&#xD;
      {EdgeForm[], Cuboid /@ scene[&amp;#034;FrameData&amp;#034;][10][&amp;#034;GroundPts&amp;#034;]},&#xD;
      {Darker@Yellow, PointSize[0.04], &#xD;
       Point[scene[&amp;#034;FrameData&amp;#034;][10][&amp;#034;SourcePosition&amp;#034;]]}&#xD;
      }, Boxed -&amp;gt; False, Background -&amp;gt; LightBlue]&#xD;
&#xD;
![enter image description here][23]&#xD;
&#xD;
&#xD;
`viewSceneFrame` does the task above for any processed scene and specified frame.  It inherits Graphics3D options as well as custom ones affecting the scene elements (shadow and ground style, toggle source drawing and gridlines).&#xD;
&#xD;
    viewSceneFrame[scene, 10, DrawGrid -&amp;gt; False, ShadowColor -&amp;gt; GrayLevel[0.3], SurfaceColor -&amp;gt; Lighter@Orange,  DrawSource -&amp;gt; True, Boxed -&amp;gt; False, Background -&amp;gt; LightBlue]&#xD;
&#xD;
![enter image description here][24]&#xD;
&#xD;
    Show[viewSceneFrame[scene, 10, DrawGrid -&amp;gt; False, &#xD;
      ShadowColor -&amp;gt; GrayLevel[0.3], SurfaceColor -&amp;gt; Lighter@Orange, &#xD;
      DrawSource -&amp;gt; True, Boxed -&amp;gt; False, Background -&amp;gt; LightBlue], &#xD;
     ViewPoint -&amp;gt; {0, 0, \[Infinity]}]&#xD;
&#xD;
![enter image description here][25]&#xD;
&#xD;
&#xD;
    sceneBounds = Join[&#xD;
       Most[MinMax /@ Transpose[scene[&amp;#034;ProjectionPoints&amp;#034;]]],&#xD;
       {MinMax[&#xD;
         Last /@ Values[scene[&amp;#034;FrameData&amp;#034;][[All, &amp;#034;SourcePosition&amp;#034;]]]]}&#xD;
       ];&#xD;
    viewSceneFrame[scene, 10, DrawGrid -&amp;gt; False, &#xD;
     ShadowColor -&amp;gt; GrayLevel[0.3], SurfaceColor -&amp;gt; Lighter@Orange, &#xD;
     DrawSource -&amp;gt; True, Boxed -&amp;gt; False, Background -&amp;gt; LightBlue, &#xD;
     Axes -&amp;gt; True, AxesLabel -&amp;gt; {&amp;#034;X&amp;#034;, &amp;#034;Y&amp;#034;, &amp;#034;Z&amp;#034;}, PlotRange -&amp;gt; sceneBounds]&#xD;
&#xD;
![enter image description here][26]&#xD;
&#xD;
&#xD;
Retaining the same options, the scene may also be animated.  To ensure a smooth playback, each frame is exported as .gif into `$TemporaryDirectory`, imported back as a list and animated.  The animation is also exported for future use.&#xD;
&#xD;
    animateScene[scene,&#xD;
     DrawGrid -&amp;gt; False,&#xD;
     ShadowColor -&amp;gt; GrayLevel[0.3],&#xD;
     SurfaceColor -&amp;gt; Lighter@Orange,&#xD;
     DrawSource -&amp;gt; True,&#xD;
     Boxed -&amp;gt; False,&#xD;
     Background -&amp;gt; LightBlue,&#xD;
     PlotRange -&amp;gt; sceneBounds,&#xD;
     ImageSize -&amp;gt; {{800}, {600}}&#xD;
     ]&#xD;
&#xD;
![enter image description here][27]&#xD;
&#xD;
&#xD;
We can also plot the cumulative solar exposure.&#xD;
&#xD;
All points from the projection plane which don&amp;#039;t intersect with the model (i.e, aren&amp;#039;t shadow points) are extracted from the scene&amp;#039;s frames&#xD;
&#xD;
    exposure = Values[scene[&amp;#034;FrameData&amp;#034;][[All, &amp;#034;GroundPts&amp;#034;]]]&#xD;
&#xD;
![enter image description here][28]&#xD;
&#xD;
&#xD;
&#xD;
The occurrences of each exposure point is tallied&#xD;
&#xD;
    tally = Tally[Flatten[exposure, 1]]&#xD;
&#xD;
![enter image description here][29]&#xD;
&#xD;
&#xD;
And the range of frequencies from which is generated&#xD;
&#xD;
    tallyRange = &#xD;
     Range @@ Insert[MinMax[Last /@ SortBy[tally, Last]], 1, -1]&#xD;
    &#xD;
    {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, \&#xD;
    20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30}&#xD;
&#xD;
&#xD;
A color scale corresponding to the range of frequencies from above will be used to colorize the plot&#xD;
&#xD;
    colorScale = &#xD;
     ColorData[&amp;#034;SolarColors&amp;#034;, &amp;#034;ColorFunction&amp;#034;] /@ Rescale[tallyRange]&#xD;
&#xD;
![enter image description here][30]&#xD;
&#xD;
&#xD;
Replacement rules are used to replace each exposure point&amp;#039;s frequency with it&amp;#039;s corresponding color&#xD;
&#xD;
    colorScaleRules = Thread @@ {tallyRange -&amp;gt; colorScale}&#xD;
&#xD;
![enter image description here][31]&#xD;
&#xD;
&#xD;
The resultant exposure map is a list of tiles, each coloured according to it&amp;#039;s positional frequency.&#xD;
&#xD;
    heatMap = &#xD;
     Insert[MapAt[Cuboid, &#xD;
         Reverse@MapAt[Replace[colorScaleRules], #, -1], -1], EdgeForm[], &#xD;
        2] &amp;amp; /@ tally&#xD;
&#xD;
![enter image description here][32]&#xD;
&#xD;
Finally, the map is drawn.  It&amp;#039;s still a `Graphics3D` object so it may be rotated and viewed from any angle.&#xD;
&#xD;
    Row[{&#xD;
      Show[Graphics3D[{&#xD;
         {Opacity[0.3], Green, Polygon[scene[&amp;#034;BVH&amp;#034;][&amp;#034;PolygonObjects&amp;#034;]]},&#xD;
         heatMap&#xD;
         }, Boxed -&amp;gt; False, ImageSize -&amp;gt; Large], ViewPoint -&amp;gt; Above],&#xD;
      BarLegend[{&amp;#034;SolarColors&amp;#034;, MinMax[tallyRange]}]&#xD;
      }]&#xD;
&#xD;
![enter image description here][33]&#xD;
&#xD;
The process of generating an exposure map forms a function within the `GeometricIntersections3D` package.  &#xD;
Alternative color schemes may also be specified.&#xD;
&#xD;
    sceneExposureMap[scene, &amp;#034;TemperatureMap&amp;#034;]&#xD;
&#xD;
![enter image description here][34]&#xD;
&#xD;
&#xD;
The bar scale for the exposure plot measures duration in frames but a time scale may be recovered.&#xD;
Given that the solar path used to light the scene lasts about 14 hours and the scene was rendered for 30 frames, that gives about 30 minutes per frame.&#xD;
&#xD;
    dailySunHours = &#xD;
     UnitConvert[DateDifference[Sunrise[], Sunset[]], &#xD;
      MixedRadix[&amp;#034;Hours&amp;#034;, &amp;#034;Minutes&amp;#034;, &amp;#034;Seconds&amp;#034;]]&#xD;
&#xD;
![enter image description here][35]&#xD;
&#xD;
&#xD;
    dailySunHours/30&#xD;
&#xD;
![enter image description here][36]&#xD;
&#xD;
&#xD;
&#xD;
&#xD;
&#xD;
&#xD;
&#xD;
&#xD;
This has been a very rewarding project with some exciting potentials beyond computer graphics.  Indeed, much optimisations can be made to the intersections package.  &#xD;
The different methods of space partitioning for BVH construction should be investigated as the one currently employed is rather rudimentary.&#xD;
Anti-aliasing methods to be investigated also.&#xD;
&#xD;
Both the House and Sundial processes are documented in the notebooks attached.  All necessary data may also be downloaded to save time.&#xD;
&#xD;
&#xD;
&#xD;
&#xD;
 &#xD;
&#xD;
&#xD;
  [1]: https://en.wikipedia.org/wiki/Shadow_mapping&#xD;
  [2]: http://community.wolfram.com//c/portal/getImageAttachment?filename=animation.gif&amp;amp;userId=605083&#xD;
  [3]: https://3dwarehouse.sketchup.com/&#xD;
  [4]: https://github.com/b-goodman/GeometricIntersections3D&#xD;
  [5]: http://community.wolfram.com//c/portal/getImageAttachment?filename=Process_House_Import.png&amp;amp;userId=605083&#xD;
  [6]: https://en.wikipedia.org/wiki/Bounding_volume_hierarchy&#xD;
  [7]: http://community.wolfram.com//c/portal/getImageAttachment?filename=Process_House_TreeLV1.png&amp;amp;userId=605083&#xD;
  [8]: http://community.wolfram.com//c/portal/getImageAttachment?filename=Process_House_leafBoxesLV1.png&amp;amp;userId=605083&#xD;
  [9]: http://community.wolfram.com//c/portal/getImageAttachment?filename=cuboidSubdivide.gif&amp;amp;userId=605083&#xD;
  [10]: http://community.wolfram.com//c/portal/getImageAttachment?filename=Process_House_TreeLV2.png&amp;amp;userId=605083&#xD;
  [11]: http://community.wolfram.com//c/portal/getImageAttachment?filename=Process_House_leafBoxesLV2.png&amp;amp;userId=605083&#xD;
  [12]: http://community.wolfram.com//c/portal/getImageAttachment?filename=Process_House_projectionPoints.png&amp;amp;userId=605083&#xD;
  [13]: http://community.wolfram.com//c/portal/getImageAttachment?filename=solarPosition.PNG&amp;amp;userId=605083&#xD;
  [14]: http://community.wolfram.com//c/portal/getImageAttachment?filename=Process_House_scenePreview.png&amp;amp;userId=605083&#xD;
  [15]: http://community.wolfram.com//c/portal/getImageAttachment?filename=Process_House_sceneConstructor.png&amp;amp;userId=605083&#xD;
  [16]: http://community.wolfram.com//c/portal/getImageAttachment?filename=Process_House_projectionPoints.png&amp;amp;userId=605083&#xD;
  [17]: http://community.wolfram.com//c/portal/getImageAttachment?filename=Process_House_raySearch.png&amp;amp;userId=605083&#xD;
  [18]: http://community.wolfram.com//c/portal/getImageAttachment?filename=Process_House_rayIntersection.png&amp;amp;userId=605083&#xD;
  [19]: http://community.wolfram.com//c/portal/getImageAttachment?filename=Process_House_projectionPoints.png&amp;amp;userId=605083&#xD;
  [20]: http://community.wolfram.com//c/portal/getImageAttachment?filename=Process_House_projectionPoints.png&amp;amp;userId=605083&#xD;
  [21]: http://community.wolfram.com//c/portal/getImageAttachment?filename=Process_House_projectionPoints.png&amp;amp;userId=605083&#xD;
  [22]: http://community.wolfram.com//c/portal/getImageAttachment?filename=Process_House_projectionPoints.png&amp;amp;userId=605083&#xD;
  [23]: http://community.wolfram.com//c/portal/getImageAttachment?filename=Process_House_singleFrame_1.png&amp;amp;userId=605083&#xD;
  [24]: http://community.wolfram.com//c/portal/getImageAttachment?filename=Process_House_singleFrame_2.png&amp;amp;userId=605083&#xD;
  [25]: http://community.wolfram.com//c/portal/getImageAttachment?filename=Process_House_singleFrame_3.png&amp;amp;userId=605083&#xD;
  [26]: http://community.wolfram.com//c/portal/getImageAttachment?filename=Process_House_singleFrame_4.png&amp;amp;userId=605083&#xD;
  [27]: http://community.wolfram.com//c/portal/getImageAttachment?filename=animation_House.gif&amp;amp;userId=605083&#xD;
  [28]: http://community.wolfram.com//c/portal/getImageAttachment?filename=Process_House_exposureStep_A.png&amp;amp;userId=605083&#xD;
  [29]: http://community.wolfram.com//c/portal/getImageAttachment?filename=Process_House_exposureStep_B.png&amp;amp;userId=605083&#xD;
  [30]: http://community.wolfram.com//c/portal/getImageAttachment?filename=Process_House_exposureStep_C.png&amp;amp;userId=605083&#xD;
  [31]: http://community.wolfram.com//c/portal/getImageAttachment?filename=Process_House_exposureStep_D.png&amp;amp;userId=605083&#xD;
  [32]: http://community.wolfram.com//c/portal/getImageAttachment?filename=Process_House_exposureStep_E.png&amp;amp;userId=605083&#xD;
  [33]: http://community.wolfram.com//c/portal/getImageAttachment?filename=Process_House_solarMap_A.png&amp;amp;userId=605083&#xD;
  [34]: http://community.wolfram.com//c/portal/getImageAttachment?filename=Process_House_solarMap_B.png&amp;amp;userId=605083&#xD;
  [35]: http://community.wolfram.com//c/portal/getImageAttachment?filename=sunHours.png&amp;amp;userId=605083&#xD;
  [36]: http://community.wolfram.com//c/portal/getImageAttachment?filename=sunHoursPerFrame.png&amp;amp;userId=605083</description>
    <dc:creator>Benjamin Goodman</dc:creator>
    <dc:date>2017-06-01T07:01:10Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/1298554">
    <title>Improve neural network performance with Mathematica 11.3 ?</title>
    <link>https://community.wolfram.com/groups/-/m/t/1298554</link>
    <description>I look at the blog post with the 11.3 word cloud with &amp;#039;Blockchain&amp;#039; as the BIG center and ask how important is that? As I run the exact same data science GPU code on identical hardware software configuration except for the change from Mathematica 11.2 to Mathematica 11.3 and see my neural network performance go from 295 seconds on 11.2 to 2038 seconds on 11.3. Again NO change other than Mathematica version. And then I see that Mathematica 11.3 still does not support current XCode LLVM/GCC compiler or NVIDIA for CUDA tools (watch it move back to old paclet for Mathematica 10.5 after you upgrade your XCode command line tools to current version, am I expected to pay money to figure this out?) .&#xD;
&#xD;
This is my experience as I explore the value of Mathematica since release 10 to today for data science and at the same time see the massive improvements and quality of Python, Jupyter, NVIDIA, iOS CoreML, Vulkan, Tensorflow  and core GPU computing on MacOS, iOS  and Linux.&#xD;
&#xD;
Really questioning the value proposition of Wolfram for data science going forward. Sad.</description>
    <dc:creator>David Proffer</dc:creator>
    <dc:date>2018-03-10T04:14:59Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/454405">
    <title>Clustering techniques for a large multi-asset portfolio</title>
    <link>https://community.wolfram.com/groups/-/m/t/454405</link>
    <description>Clustering decomposition is a data-mining and data processing technique for large datasets  grouping into simple representative objects. Although clustering is less known approach than other grouping methods (factor analysis in particular), it comes particularly handy when we face large sets of data and trying to identify patterns and features common to each cluster. We demonstrate the case on the financial data where we analyse a  large multi-asset portfolio with unique financial returns. We compare decomposition methods and provide cluster characteristics using statistical and probabilistic analysis including risk.&#xD;
&#xD;
![Clustering image][1]&#xD;
&#xD;
#Cluster analysis - brief introduction&#xD;
&#xD;
Cluster analysis is a data-mining and data processing approach for determining grouping patterns in the data structure.&#xD;
&#xD;
It is less known than other exploratory techniques, but still powerful and valid method for large dataset classification, pattern recognition, information retrieval and image analysis.&#xD;
&#xD;
It is generally referred as is an unsupervised learning technique used for classification of data where individual elements are partitioned into groups called clusters that represent proximate collections of data elements based on a **distance** or **dissimilarity** function. Identical element pairs have zero distance or dissimilarity, and all others have positive distance or dissimilarity.&#xD;
&#xD;
What is special about clusters?&#xD;
It is a method for determining how cases rather than variables group together. Structural features are handled though the distance function. Elements with similar proximity are grouped into clusters with consistent distance characteristics.&#xD;
&#xD;
##Clusters in financial data analysis&#xD;
&#xD;
Clusters are ideal method for classifying large sets of data into meaningful groups that can be further analysed using standard exploratory techniques.&#xD;
&#xD;
Clusters can be effectively used to reduce the dimensionality of data to be analysed. Each cluster can be effectively used as a *combined variable* with its own grouped characteristic.&#xD;
&#xD;
Clustering is closely linked to statistical distributions and represents *multi-objective optimisation problems* that naturally arise in finance.&#xD;
&#xD;
#Clustering of financial returns&#xD;
&#xD;
We look at clustering application on financial returns and consider the following case: &#xD;
&#xD;
We have collected large multi-asset portfolios with computed financial returns. Our objective is to divide the total portfolio into groups with similar characteristics and obtain meaningful statistics of each group.&#xD;
&#xD;
###Simulation of financial returns&#xD;
&#xD;
    portA = RandomVariate[NormalDistribution[-0.01, 0.008], {1600, 2}];&#xD;
    portB = RandomVariate[LogisticDistribution[0.007, 0.01], {1200, 2}];&#xD;
    portC = RandomVariate[StudentTDistribution[0.015, 0.01, 4], {1200, 2}];&#xD;
    portD = RandomVariate[LaplaceDistribution[-0.007, 0.01], {1000, 2}];&#xD;
    &#xD;
###Creating combined portfolio&#xD;
&#xD;
    portret = Join[portA, portB, portC, portD];&#xD;
&#xD;
Total size of combined portfolio:&#xD;
&#xD;
    Total[Length /@ portret]&#xD;
&#xD;
&amp;gt; 10000&#xD;
&#xD;
With distributional patterns showing skewed distribution of combined portfolio returns&#xD;
&#xD;
    Histogram[Flatten[portret], 40, ChartStyle -&amp;gt; &amp;#034;Rainbow&amp;#034;]&#xD;
![enter image description here][2]&#xD;
&#xD;
###This is confirmed in the 3D image&#xD;
&#xD;
    Histogram3D[portret, 50, ColorFunction -&amp;gt; &amp;#034;Rainbow&amp;#034;]&#xD;
![enter image description here][3]&#xD;
&#xD;
##Defining clustering of financial returns:&#xD;
Clusters are built on the notion of similarity / proximity amongst individual returns.&#xD;
Mathematica 10 offers several measures to choose from - we test four of them:&#xD;
&#xD;
 1. Euclidean distance:			&#xD;
&#xD;
        Sqrt[\[Sum](u-v)^2]&#xD;
&#xD;
 2. Squared Euclidean distance:		&#xD;
&#xD;
        \[Sum](u-v)^2&#xD;
&#xD;
 3. Manhattan distance:			&#xD;
&#xD;
        \[Sum]\[LeftBracketingBar]u-v\[RightBracketingBar]&#xD;
&#xD;
 4. Canberra distance:&#xD;
			&#xD;
&#xD;
        \[Sum]\[LeftBracketingBar]u-v\[RightBracketingBar]/(\[LeftBracketingBar]u\[RightBracketingBar]+\[LeftBracketingBar]v\[RightBracketingBar])	&#xD;
.&#xD;
&#xD;
        iSize = 250;&#xD;
        {ListPlot[&#xD;
          FindClusters[portret, 4, DistanceFunction -&amp;gt; EuclideanDistance], &#xD;
          PlotLabel -&amp;gt; &amp;#034;Eucld Dist&amp;#034;, ImageSize -&amp;gt; iSize], &#xD;
         ListPlot[FindClusters[portret, 4, &#xD;
           DistanceFunction -&amp;gt; SquaredEuclideanDistance], &#xD;
          PlotLabel -&amp;gt; &amp;#034;Sq Eucld Dist&amp;#034;, ImageSize -&amp;gt; iSize], &#xD;
         ListPlot[FindClusters[portret, 4, &#xD;
           DistanceFunction -&amp;gt; ManhattanDistance], PlotLabel -&amp;gt; &amp;#034;Manht Dist&amp;#034;, &#xD;
          ImageSize -&amp;gt; iSize], &#xD;
         ListPlot[FindClusters[portret, 4, &#xD;
           DistanceFunction -&amp;gt; CanberraDistance], &#xD;
          PlotLabel -&amp;gt; &amp;#034;Canberra Dist&amp;#034;, ImageSize -&amp;gt; iSize]}&#xD;
![enter image description here][4]&#xD;
&#xD;
We can see that each distance function partitions clusters in a distinct way.	&#xD;
&#xD;
#Working with clusters&#xD;
##Selecting the cluster&#xD;
Let&amp;#039;s select the Manhattan distance method for clustering of our mega-portfolio:&#xD;
&#xD;
    mclust = FindClusters[portret, 4, &#xD;
       DistanceFunction -&amp;gt; ManhattanDistance];&#xD;
    ListPlot[mclust, PlotMarkers -&amp;gt; Automatic, &#xD;
     PlotLegends -&amp;gt; {&amp;#034;Clust 1&amp;#034;, &amp;#034;Clust 2&amp;#034;, &amp;#034;Clust 3&amp;#034;, &amp;#034;Clust 4&amp;#034;}]&#xD;
![enter image description here][5]&#xD;
##Analysing each cluster profile&#xD;
Clusters size:&#xD;
&#xD;
    BarChart[Map[Length, mclust], PlotLabel -&amp;gt; Style[&amp;#034;Clusters size&amp;#034;, 16],&#xD;
      ChartStyle -&amp;gt; &amp;#034;DarkRainbow&amp;#034;, BarOrigin -&amp;gt; Left, &#xD;
     LabelingFunction -&amp;gt; After]&#xD;
![enter image description here][6]&#xD;
&#xD;
We can observe unequal distribution of cluster sizes =&amp;gt; cluster 1 is just half of the cluster 4. This is due to the distancing distribution of clusters specification.&#xD;
###Cluster Norm&#xD;
Cluster norm provides valuable information about the distance function inside each cluster. &#xD;
&#xD;
    BarChart[Map[Norm, mclust], PlotLabel -&amp;gt; Style[&amp;#034;Clusters norm&amp;#034;, 16], &#xD;
     ChartStyle -&amp;gt; &amp;#034;RoseColors&amp;#034;, BarOrigin -&amp;gt; Right, &#xD;
     LabelingFunction -&amp;gt; Before]&#xD;
![enter image description here][7]&#xD;
&#xD;
#Statistical analysis of clusters&#xD;
Clusters are treated as &amp;#039;objects&amp;#039; and we can perform any statistical analysis on them.&#xD;
For example - we can compute descriptive statistics to identify moments of each cluster.&#xD;
##Location and dispersion measures&#xD;
&#xD;
    size = Length[mclust];&#xD;
    legnd = {&amp;#034;Cluster 1&amp;#034;, &amp;#034;Cluster 2&amp;#034;, &amp;#034;Cluster 3&amp;#034;, &amp;#034;Cluster 4&amp;#034;};&#xD;
    clmean = Table[Mean[Flatten[mclust[[i]]]], {i, size}];&#xD;
    clvol = Table[StandardDeviation[Flatten[mclust[[i]]]], {i, size}];&#xD;
    {BarChart[clmean, ChartStyle -&amp;gt; &amp;#034;Pastel&amp;#034;, &#xD;
      PlotLabel -&amp;gt; &amp;#034;Clusters means&amp;#034;, LabelingFunction -&amp;gt; Above, &#xD;
      ImageSize -&amp;gt; 320, ChartLegends -&amp;gt; legnd], &#xD;
     BarChart[clvol, ChartStyle -&amp;gt; &amp;#034;FallColors&amp;#034;, &#xD;
      PlotLabel -&amp;gt; &amp;#034;Clusters vols&amp;#034;, LabelingFunction -&amp;gt; Above, &#xD;
      ImageSize -&amp;gt; 320, ChartLegends -&amp;gt; legnd]}&#xD;
![enter image description here][8]&#xD;
&#xD;
First two clusters reside in the negative return territory, but are less volatile than the ones which show positive returns.&#xD;
&#xD;
We can get further insight into each cluster dispersion by looking at quartile deviation and inter quartile range:&#xD;
&#xD;
    clqdev = Table[QuartileDeviation[Flatten[mclust[[i]]]], {i, size}];&#xD;
    cliqrng = Table[InterquartileRange[Flatten[mclust[[i]]]], {i, size}];&#xD;
    {BarChart[clqdev, ChartStyle -&amp;gt; &amp;#034;LakeColors&amp;#034;, &#xD;
      PlotLabel -&amp;gt; Style[&amp;#034;Clusters Quartile Deviation&amp;#034;, 16], &#xD;
      LabelingFunction -&amp;gt; Above, ImageSize -&amp;gt; 320, ChartLegends -&amp;gt; legnd],&#xD;
      BarChart[cliqrng, ChartStyle -&amp;gt; &amp;#034;SunsetColors&amp;#034;, &#xD;
      PlotLabel -&amp;gt; Style[&amp;#034;Clusters vols&amp;#034;, 16], LabelingFunction -&amp;gt; Above, &#xD;
      ImageSize -&amp;gt; 320, ChartLegends -&amp;gt; legnd]}&#xD;
![enter image description here][9]&#xD;
&#xD;
The above dispersion statistics is confirmed also in the quartile domain - quartile deviation is the lowest for negative returns clusters, but higher for the positive one. This indicates higher risk in the positive return segments.&#xD;
##Clusters shape measures&#xD;
&#xD;
    cskew = Table[Skewness[Flatten[mclust[[i]]]], {i, size}];&#xD;
    ckurt = Table[Kurtosis[Flatten[mclust[[i]]]], {i, size}];&#xD;
    {BarChart[cskew, ChartStyle -&amp;gt; &amp;#034;MintColors&amp;#034;, &#xD;
      PlotLabel -&amp;gt; Style[&amp;#034;Clusters skewness&amp;#034;, 16], &#xD;
      LabelingFunction -&amp;gt; Above, ImageSize -&amp;gt; 320, ChartLegends -&amp;gt; legnd],&#xD;
      BarChart[ckurt, ChartStyle -&amp;gt; &amp;#034;LakeColors&amp;#034;, &#xD;
      PlotLabel -&amp;gt; Style[&amp;#034;Clusters kurtosis&amp;#034;, 16], &#xD;
      LabelingFunction -&amp;gt; Above, ImageSize -&amp;gt; 320, ChartLegends -&amp;gt; legnd]}&#xD;
![enter image description here][10]&#xD;
Moments statistics reveal non-normality pattern in all clustered data.&#xD;
#Probabilistic analysis of clustered returns&#xD;
Extension to the probabilistic calculations on the clusters is trivial: For example - we may want to determine each cluster probability of financial return &amp;lt; 0&#xD;
&#xD;
    Table[Probability[x &amp;lt; 0, x \[Distributed] Flatten[mclust[[i]]]], {i, &#xD;
        size}] // N;&#xD;
    BarChart[%, PlotLabel -&amp;gt; Style[&amp;#034;Clusters return probability &amp;lt; 0&amp;#034;, 16],&#xD;
      ChartStyle -&amp;gt; &amp;#034;Rainbow&amp;#034;, LabelingFunction -&amp;gt; Above]&#xD;
![enter image description here][11]&#xD;
Being in the negative return domain, the first two clusters show the highest probability of negative returns.&#xD;
##Clusters risk measure&#xD;
We can easily calculate Value at Risk threshold for each cluster:&#xD;
&#xD;
    varT = Table[Quantile[Flatten[mclust[[i]]], 0.01], {i, size}];&#xD;
    BarChart[varT, ChartStyle -&amp;gt; &amp;#034;SolarColors&amp;#034;, &#xD;
     PlotLabel -&amp;gt; Style[&amp;#034;VaR threshold at 99% level&amp;#034;, 16], &#xD;
     LabelingFunction -&amp;gt; Below]&#xD;
![enter image description here][12]&#xD;
&#xD;
and then using the above measure to obtain the Tail VaR statistics:&#xD;
&#xD;
    tVaR = Table[&#xD;
       NExpectation[x \[Conditioned] x &amp;lt; varT[[i]], &#xD;
        x \[Distributed] Flatten[mclust[[i]]]], {i, size}];&#xD;
    BarChart[tVaR, ChartStyle -&amp;gt; &amp;#034;TemperatureMap&amp;#034;, &#xD;
     PlotLabel -&amp;gt; Style[&amp;#034;Tail VaR threshold at 99% level&amp;#034;, 16], &#xD;
     LabelingFunction -&amp;gt; Below]&#xD;
    ![enter image description here][13]&#xD;
Tail VaR (Expected shortfall) reveals the same risk as the VaR above. The first cluster is the most riskiest whilst the last one in the least riskiest cluster.&#xD;
##Cluster distributions&#xD;
Creating clusters objects allow us to visualise and work with cluster distributions&#xD;
&#xD;
    Table[Histogram[Flatten[mclust[[i]]], 25, &#xD;
      ColorFunction -&amp;gt; Function[{height}, ColorData[&amp;#034;Rainbow&amp;#034;][height]], &#xD;
      ImageSize -&amp;gt; 225], {i, size}]&#xD;
![enter image description here][14]&#xD;
Clusters one and four generate highly skewed profiles - cluster 1 negative and cluster 4 positive.  Clusters two are three are more symmetrical.&#xD;
&#xD;
The distribution patterns can also be analysed in the 3D format as they provide richer insight into the distributions in higher dimensions. As we can see below, the low-frequency outliers are still present in each cluster and add to the risk of each group. &#xD;
&#xD;
    clr = {&amp;#034;Pastel&amp;#034;, &amp;#034;LightTemperatureMap&amp;#034;, &amp;#034;RedBlueTones&amp;#034;, &#xD;
       &amp;#034;AvocadoColors&amp;#034;};&#xD;
    Table[Evaluate@&#xD;
       Histogram3D[mclust[[i]], 50, &amp;#034;PDF&amp;#034;, ImageSize -&amp;gt; 250, &#xD;
        ColorFunction -&amp;gt; clr[[i]]], {i, size}] // Quiet&#xD;
![enter image description here][15]&#xD;
#Summary&#xD;
##Why clusters?&#xD;
&#xD;
 - Ideal tool for knowledge discovery and pattern recognition in datasets.&#xD;
 - Great technique for automatic data classification and numerical taxonomy.&#xD;
 - Well-suited tool for financial data analysis:&#xD;
     - Patterns detection&#xD;
     - Drivers recognition&#xD;
     - Characteristics extraction&#xD;
&#xD;
Great technique for automatic data classification and numerical taxonomy&#xD;
&#xD;
  [1]: /c/portal/getImageAttachment?filename=DClustersImage.jpg&amp;amp;userId=387433&#xD;
  [2]: http://community.wolfram.com//c/portal/getImageAttachment?filename=Clusteringfiancialdata.png&amp;amp;userId=95400&#xD;
  [3]: http://community.wolfram.com//c/portal/getImageAttachment?filename=p2.png&amp;amp;userId=95400&#xD;
  [4]: http://community.wolfram.com//c/portal/getImageAttachment?filename=p3.png&amp;amp;userId=95400&#xD;
  [5]: http://community.wolfram.com//c/portal/getImageAttachment?filename=p4.png&amp;amp;userId=95400&#xD;
  [6]: http://community.wolfram.com//c/portal/getImageAttachment?filename=p5.png&amp;amp;userId=95400&#xD;
  [7]: http://community.wolfram.com//c/portal/getImageAttachment?filename=p6.png&amp;amp;userId=95400&#xD;
  [8]: http://community.wolfram.com//c/portal/getImageAttachment?filename=p7.png&amp;amp;userId=95400&#xD;
  [9]: http://community.wolfram.com//c/portal/getImageAttachment?filename=p8.png&amp;amp;userId=95400&#xD;
  [10]: http://community.wolfram.com//c/portal/getImageAttachment?filename=p9.png&amp;amp;userId=95400&#xD;
  [11]: http://community.wolfram.com//c/portal/getImageAttachment?filename=p10.png&amp;amp;userId=95400&#xD;
  [12]: http://community.wolfram.com//c/portal/getImageAttachment?filename=p11.png&amp;amp;userId=95400&#xD;
  [13]: http://community.wolfram.com//c/portal/getImageAttachment?filename=p12.png&amp;amp;userId=95400&#xD;
  [14]: http://community.wolfram.com//c/portal/getImageAttachment?filename=p13.png&amp;amp;userId=95400&#xD;
  [15]: http://community.wolfram.com//c/portal/getImageAttachment?filename=p14.png&amp;amp;userId=95400</description>
    <dc:creator>Igor Hlivka</dc:creator>
    <dc:date>2015-03-07T00:17:13Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/374658">
    <title>The Misfortunes of a Trio of Mathematicians Using Computer Algebra Systems</title>
    <link>https://community.wolfram.com/groups/-/m/t/374658</link>
    <description>Please, read the following article to appear in next month&amp;#039;s issue of the Notices of the American Mathematical Society:&#xD;
http://www.ams.org/notices/201410/rnoti-p1249.pdf&#xD;
Thank you!</description>
    <dc:creator>Gilmar Rodriguez-Pierluissi</dc:creator>
    <dc:date>2014-10-22T17:24:13Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/218587">
    <title>Enigma-like machine in Wolfram Language?</title>
    <link>https://community.wolfram.com/groups/-/m/t/218587</link>
    <description>Hi all, one of my friends shared the following link, which I found interesting to share with you and by the way, ask the community if it is to do something like the machine enigma that is on that page, I hope someone has any idea how to do it.&#xD;
&#xD;
[url=http://enigmaco.de/enigma/enigma.swf]http://enigmaco.de/enigma/enigma.swf[/url]</description>
    <dc:creator>Luis Ledesma</dc:creator>
    <dc:date>2014-03-13T23:51:00Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/394537">
    <title>Divide a triangle into four small triangles</title>
    <link>https://community.wolfram.com/groups/-/m/t/394537</link>
    <description>Hello all, I am writing to tell you my idea. The process of splitting up a triangle either in four smaller triangles, do so by the larger angle as shown below:&#xD;
&#xD;
    Graphics[Line[{{0, 0}, {7, -5}, {8, 10}, {0, 0}}]]&#xD;
After analyze the angles of the triangle we see that the larger angle is what is at the point {0,0}, subsequently we construct a straight line to the midpoint of the opposite side to the point {0,0 } Finally we estimate the midpoints of the sides adjacent to the point {0,0 } and the join by a straight line to the midpoint of the opposite side that we calculated above ,for finally getting the following figure:&#xD;
&#xD;
![first step][1]&#xD;
&#xD;
&#xD;
If we do the same steps with each of the four triangles, we will be able to obtain more triangles 16 in total&#xD;
&#xD;
![second step][2]&#xD;
&#xD;
Can anyone help me to do what I say, I have made some progress but I am having some problems in order to apply it several times on a initial triangle&#xD;
&#xD;
&#xD;
  [1]: /c/portal/getImageAttachment?filename=montanafr.bmp&amp;amp;userId=133435&#xD;
  [2]: /c/portal/getImageAttachment?filename=montanagh.bmp&amp;amp;userId=133435</description>
    <dc:creator>Luis Ledesma</dc:creator>
    <dc:date>2014-11-22T19:26:37Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/568332">
    <title>ELSEIF or ELIF in mathematica?</title>
    <link>https://community.wolfram.com/groups/-/m/t/568332</link>
    <description>Hello all, I am having confusion with the IF statement because I have seen that in other languages there is ELSEIF or ELIF, and when searching for something similar in Mathematica didn&amp;#039;t find it, it is for this reason that I am turning to you to ask them if there is something similar to ELSEIF or ELIF  or definitely should i use WHICH, I share with you some images of what I am talking about. By its aid, a thousand thanks,greetings&#xD;
&#xD;
![elifmaple][1]&#xD;
&#xD;
HERE IN MATLAB&#xD;
&#xD;
&#xD;
![elseifmatlab][2]&#xD;
&#xD;
&#xD;
  [1]: /c/portal/getImageAttachment?filename=elifmaple.PNG&amp;amp;userId=133435&#xD;
  [2]: /c/portal/getImageAttachment?filename=elseifmatlab.PNG&amp;amp;userId=133435</description>
    <dc:creator>Luis Ledesma</dc:creator>
    <dc:date>2015-09-21T00:35:50Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/434905">
    <title>A Smart Cities Hackathon. 20-22 February 2015, at UPC, Barcelona, Spain</title>
    <link>https://community.wolfram.com/groups/-/m/t/434905</link>
    <description>This hackathon is intended to propose some challenges around the Smart City Concept and offer the participants to showcase its skills, learn emerging technologies and share ideas.&#xD;
&#xD;
Main objective is to promote the usage of the iCity platform building new services based on PC or embedded systems such as simple platforms like Raspberry Pi or Galileo boards. In particular, to develop applications through iCity Platform, interacting with opened citys Information Systems to provide public interest services. In particular, Information Services offered by Municipality of Barcelona. Main topics are Data acquisition and actuation, Monitoring and management, Security, Transport and Mobility, e-Government, Environment, Tourism and culture, Sustainability.&#xD;
&#xD;
The Hackathon is opened to developers, students, researchers, business thinkers, policy analysts, journalists, designers, community organizers, urban planners, or anyone else who is interested in solving the biggest urban challenges today.&#xD;
Bernat Espigule will be available during the event to teach you the Wolfram language for projects developed with Raspberry Pi.&#xD;
&#xD;
Global event: http://www.global.datafest.net/&#xD;
&#xD;
Local event: http://www.global.datafest.net/cities/barcelona-spain</description>
    <dc:creator>Anna Calveras</dc:creator>
    <dc:date>2015-02-04T13:35:43Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/550504">
    <title>Who can fix math education, and how? Your thoughts please...</title>
    <link>https://community.wolfram.com/groups/-/m/t/550504</link>
    <description>![Look familiar...?][1]&#xD;
&#xD;
When last did you solve a quadratic equation by hand? Probably not since school, I&amp;#039;m guessing. It&amp;#039;s an open secret that maths education is way behind the times, failing to equip kids with skills they need in the real world. &#xD;
&#xD;
As a Wolfram Community member, you may well have come across the [Computer-Based Maths initiative][2], driven by Conrad Wolfram. For those who don&amp;#039;t know, it&amp;#039;s a programme designed to bring coding and computers into school maths curricula worldwide, using Wolfram technology. &#xD;
&#xD;
And now the CBM team wants *your* ideas ahead of the fourth [CBM Summit in London on 19-20 November][3]. We already have Jaak Aaviksoo, Simon Peyton Jones and Raspberry Pi&amp;#039;s Eben Upton, who [spoke at the last CBM Summit][4] in 2013. Now we&amp;#039;d like to hear from you...&#xD;
&#xD;
- Who would *you* like to hear speaking on this subject? &#xD;
- Do you have something you&amp;#039;d like to present yourself? &#xD;
- What are the most important topics that should be covered?&#xD;
&#xD;
Think about your country and your workplace too: &#xD;
&#xD;
- Are there thought leaders, education revolutionaries or forward-thinking math education projects the CBM team should know about? &#xD;
&#xD;
I&amp;#039;m looking forward to your comments...and maybe see you in London!&#xD;
&#xD;
[![CBM Summit, London, 19-20 November][5]][6]&#xD;
&#xD;
&#xD;
  [1]: /c/portal/getImageAttachment?filename=_thumb_117376.png&amp;amp;userId=383623&#xD;
  [2]: https://www.computerbasedmath.org/&#xD;
  [3]: http://www.computerbasedmath.org/events/maths-education-summit-2015/&#xD;
  [4]: https://www.youtube.com/watch?v=NZvttwpeVrc&amp;amp;list=PLzKFBYmW-UKpLGkkprg5LkHUVPaCV85R1&amp;amp;index=35&#xD;
  [5]: /c/portal/getImageAttachment?filename=SummitFooterFullSize.jpg&amp;amp;userId=383623&#xD;
  [6]: http://www.computerbasedmath.org/events/maths-education-summit-2015/</description>
    <dc:creator>Richard Asher</dc:creator>
    <dc:date>2015-08-20T15:52:37Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/1045419">
    <title>Visualize Machine Learning Data: From Python to Wolfram Language</title>
    <link>https://community.wolfram.com/groups/-/m/t/1045419</link>
    <description>I was reading an [online article about using the Pandas package of Python][1]. I think it might be fun to see how Wolfram Language can handle these tasks in manageable amount of code. Lets begin: &#xD;
&#xD;
    (*code source*)&#xD;
    url = &amp;#034;https://archive.ics.uci.edu/ml/machine-learning-databases/pima-indians-diabetes/pima-indians-diabetes.data&amp;#034;&#xD;
&#xD;
#Import Data#&#xD;
&#xD;
###Python###&#xD;
&#xD;
    import matplotlib.pyplot as plt&#xD;
    import pandas&#xD;
    names = [&amp;#039;preg&amp;#039;, &amp;#039;plas&amp;#039;, &amp;#039;pres&amp;#039;, &amp;#039;skin&amp;#039;, &amp;#039;test&amp;#039;, &amp;#039;mass&amp;#039;, &amp;#039;pedi&amp;#039;, &amp;#039;age&amp;#039;, &amp;#039;class&amp;#039;]&#xD;
    data = pandas.read_csv(url, names=names)&#xD;
&#xD;
###Wolfram Language###&#xD;
&#xD;
    (* $Version 11.1.0 for Mac OS X x86 (64-bit) (March 16, 2017)*)&#xD;
    data = Import[url];&#xD;
    names = {&amp;#034;preg&amp;#034;, &amp;#034;plas&amp;#034;, &amp;#034;pres&amp;#034;, &amp;#034;skin&amp;#034;, &amp;#034;test&amp;#034;, &amp;#034;mass&amp;#034;, &amp;#034;pedi&amp;#034;, &amp;#034;age&amp;#034;, &amp;#034;class&amp;#034;};&#xD;
    dataset = Dataset[Map[Association @@ Thread[names -&amp;gt; #] &amp;amp;, data]] (* turns {6,148} to &amp;lt;| preg -&amp;gt; 6 ,  plas -&amp;gt; 148 |&amp;gt;, row-wisely *)&#xD;
&#xD;
![ds][2]&#xD;
&#xD;
#Univariate Plots#&#xD;
&#xD;
## Histogram ##&#xD;
&#xD;
### Python ###&#xD;
&#xD;
    data.hist()&#xD;
    plt.show()&#xD;
&#xD;
###Wolfram Language###&#xD;
&#xD;
    width[&amp;#034;class&amp;#034;] = {0.1}; (* Very flexible to adjust the width of the bins on the fly *)&#xD;
    width[item_] := Automatic;&#xD;
    Histogram[dataset[All, #], width[#], PlotLabel -&amp;gt; #] &amp;amp; /@ names&#xD;
&#xD;
![conv][3]&#xD;
&#xD;
![plot0][4]&#xD;
&#xD;
## Density Plot ##&#xD;
&#xD;
&amp;gt;  The plots look like an abstracted histogram with a smooth curve drawn through the top of each bin, much like your eye tried to do with the histograms.&#xD;
&#xD;
So in Wolfram Language this is done by using a automatic smoothing kernel in `SmoothHistogram`. Just to be clear here, `DensityHistogram` in Mathematica means something different, which is like a 2D density plot with discrete color scale. &#xD;
&#xD;
###Python###&#xD;
&#xD;
    data.plot(kind=&amp;#039;density&amp;#039;, subplots=True, layout=(3,3), sharex=False)&#xD;
    plt.show()&#xD;
&#xD;
###Wolfram Language###&#xD;
&#xD;
    SmoothHistogram[dataset[All, #], PlotRange -&amp;gt; Full, PlotLabel -&amp;gt; #] &amp;amp; /@ names&#xD;
&#xD;
![plt2][5]&#xD;
&#xD;
##Box Whisker Plot ##&#xD;
&#xD;
###Python###&#xD;
&#xD;
    data.plot(kind=&amp;#039;box&amp;#039;, subplots=True, layout=(3,3), sharex=False, sharey=False)&#xD;
    plt.show()&#xD;
&#xD;
###Wolfram Language###&#xD;
&#xD;
    BoxWhiskerChart[dataset[All, #], PlotLabel -&amp;gt; #] &amp;amp; /@ names&#xD;
&#xD;
![plt3][6]&#xD;
&#xD;
# Multivariate Plot #&#xD;
&#xD;
##Correlation Matrix Plot##&#xD;
&#xD;
###Python###&#xD;
&#xD;
    correlations = data.corr()&#xD;
    # plot correlation matrix&#xD;
    fig = plt.figure()&#xD;
    ax = fig.add_subplot(111)&#xD;
    cax = ax.matshow(correlations, vmin=-1, vmax=1)&#xD;
    fig.colorbar(cax)&#xD;
    ticks = numpy.arange(0,9,1)&#xD;
    ax.set_xticks(ticks)&#xD;
    ax.set_yticks(ticks)&#xD;
    ax.set_xticklabels(names)&#xD;
    ax.set_yticklabels(names)&#xD;
    plt.show()&#xD;
&#xD;
###Wolfram Language###&#xD;
&#xD;
You are allowed to tweak the data with simple code here to have more control: &#xD;
&#xD;
    n = Length[names]&#xD;
    corr[dataset_, tuple_] := Correlation[&#xD;
      N@Normal@dataset[All, tuple[[1]]],&#xD;
      N@Normal@dataset[All, tuple[[2]]]&#xD;
      ]&#xD;
&#xD;
Generate some tuple of name pair&#xD;
&#xD;
    grid = Partition[Tuples[names, 2], n]&#xD;
    (*{{{preg,preg},{preg,plas},{preg,pres},{preg,skin},{preg,test} ... }}}*)&#xD;
    res = Map[corr[dataset, #] &amp;amp;, grid, {2}]&#xD;
    (* create correlation matrix : {{1., 0.129459, 0.141282, -0.0816718,...},...} *)&#xD;
&#xD;
Control label display by yourself &#xD;
&#xD;
     xLabel=yLabel=Transpose[{Range[n],names}]&#xD;
     (* {{1,preg},{2,plas},{3,pres},{4,skin},{5,test},{6,mass},{7,pedi},{8,age},{9,class}} *)&#xD;
&#xD;
Use `MatrixPlot` to create a color grid: &#xD;
&#xD;
    MatrixPlot[res,&#xD;
     FrameTicks -&amp;gt; {{yLabel, None}, {None, xLabel}},&#xD;
     FrameStyle -&amp;gt; Directive[14, Italic]&#xD;
     ]&#xD;
&#xD;
![plt4][7]&#xD;
&#xD;
##Scatterplot Matrix##&#xD;
&#xD;
###Python###&#xD;
&#xD;
    scatter_matrix(data) #default settings&#xD;
    plt.show()&#xD;
&#xD;
###Wolfram Language###&#xD;
&#xD;
The plot is broken down to a combo of `ListPlot` and `Histogram` according to the python article I was reading. For each factor pair, I use the following function to create data points and plot them together: &#xD;
&#xD;
    pair[dataset_, tuple_] := Transpose[{&#xD;
       N@Normal@dataset[All, tuple[[1]]],&#xD;
       N@Normal@dataset[All, tuple[[2]]]&#xD;
       }]&#xD;
&#xD;
    ListPlot[pair[dataset, {&amp;#034;age&amp;#034;, &amp;#034;skin&amp;#034;}], PlotStyle -&amp;gt; PointSize[0.02], AspectRatio -&amp;gt; 1] (*customized settings*)&#xD;
&#xD;
![scatter1][8]&#xD;
&#xD;
So I create a plot function as a wrapper upon the `pair` and `corr` function with the similar signature&#xD;
&#xD;
    plotfun[dataset_, tuple_] := If[tuple[[1]] === tuple[[2]],&#xD;
      Histogram[dataset[All, tuple[[1]]], Ticks -&amp;gt; None],(*histogram on diagonal*)&#xD;
      ListPlot[pair[dataset, tuple], PlotStyle -&amp;gt; PointSize[0.03], AspectRatio -&amp;gt; 1, Ticks -&amp;gt; None, Axes -&amp;gt; None, ImageSize -&amp;gt; {80, 80}] &#xD;
    ] &#xD;
&#xD;
The `ListPlot` is somewhat longer than the Python plot function because I think I can show some beautification settings in Mathematica to have the plot a professional look. Python users can point out how to do this with matplotlib in the comment. The action code to implement the plot over a grid is one-liner: &#xD;
&#xD;
    Grid[Map[plotfun[dataset, #] &amp;amp;, grid, {2}]] // Rasterize&#xD;
&#xD;
![scattergrid][9]&#xD;
&#xD;
The working notebook is attached. Please download and play around. The test data is also provided in `testdata.m` in the form of `Dataset[...]` in case the url above is dead. You can just import this file with `data=Import[&amp;#034;&amp;lt;path&amp;gt;/&amp;lt;to&amp;gt;/testdata.m&amp;#034;]` and the dataset is ready to be used in Mathematica.  &#xD;
&#xD;
&#xD;
  [1]: http://machinelearningmastery.com/visualize-machine-learning-data-python-pandas/&#xD;
  [2]: http://community.wolfram.com//c/portal/getImageAttachment?filename=datset.png&amp;amp;userId=23928&#xD;
  [3]: http://community.wolfram.com//c/portal/getImageAttachment?filename=conv.png&amp;amp;userId=23928&#xD;
  [4]: http://community.wolfram.com//c/portal/getImageAttachment?filename=plt0.png&amp;amp;userId=23928&#xD;
  [5]: http://community.wolfram.com//c/portal/getImageAttachment?filename=plt2.png&amp;amp;userId=23928&#xD;
  [6]: http://community.wolfram.com//c/portal/getImageAttachment?filename=plt3.png&amp;amp;userId=23928&#xD;
  [7]: http://community.wolfram.com//c/portal/getImageAttachment?filename=plt4.png&amp;amp;userId=23928&#xD;
  [8]: http://community.wolfram.com//c/portal/getImageAttachment?filename=plt5.png&amp;amp;userId=23928&#xD;
  [9]: http://community.wolfram.com//c/portal/getImageAttachment?filename=plt6.png&amp;amp;userId=23928</description>
    <dc:creator>Shenghui Yang</dc:creator>
    <dc:date>2017-03-28T01:47:16Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/897811">
    <title>[WSS16] Quantum Computing with the Wolfram Language</title>
    <link>https://community.wolfram.com/groups/-/m/t/897811</link>
    <description>**Introduction to the Problem**&#xD;
&#xD;
While a gate-based quantum computer has yet to be implemented at the level of more than a handful of qubits, and some worry that the decoherence problem will remain an obstacle to real-world use of these machines; the field of theoretical quantum computing has its own virtue apart from these problems of construction and implementation. The theory of quantum computation and quantum algorithms have been used as powerful tools to tackle long-standing problems in classical computation such as proving the security of certain encryption schemes and refining complexity classifications for &#xD;
some approaches to the Traveling Salesman problem. Moreover, learning how to apply quantum effects like superposition, interference, and entanglement in a useful, computational, manner can help students gain a better understanding of how the quantum world really works. These educational and research advantages of quantum computing, along with the ever-present goal of designing new quantum algorithms that can provide us with speedups over their classical counterparts, furnish ample reason to make the field as accessible as possible. The goal of this project was to do just that by using the Wolfram language to design functionality that allows for researchers and students alike to engage with quantum computing in a meaningful way.&#xD;
&#xD;
**Getting it Done**&#xD;
&#xD;
This project involved the design and development of a suite of functions that allows for the simulation of quantum computing algorithms. The overarching goal was a framework that allows for easy implementation of quantum circuits, with minimal work done by the user. The specific design challenges were to have a tool simple enough to be used as an educational aide and powerful enough for researchers. To this end circuits can be built iteratively, allowing  students, and those new to quantum computing, to build a working knowledge of the field as they increase the complexity of the algorithms. The system has a universal set of gates allowing it to carry out any operation possible for a quantum computer (up to limits on the number of qubits due to the size of the register).&#xD;
&#xD;
&#xD;
----------&#xD;
&#xD;
&#xD;
*Short note on this: I have not rigorously tested the system yet, but unless you want to wait several hours for  your computation to complete, I             suggest not attempting computations with more than ~20 qubits. To classically simulate an N-qubit register, requires a state vector of length 2&amp;lt;sup&amp;gt;N&amp;lt;/sup&amp;gt;. Interestingly, it is this insight into the computational difficulty of simulating a quantum state that led Feynman to realize the power that quantum computing could have.*&#xD;
&#xD;
&#xD;
----------&#xD;
&#xD;
&#xD;
The project has functionality for the following gates: Hadamard, X, Y, Z, Rotation (any angle, about any axis), C-NOT, C-anything, SWAP, and QFT. It takes input in standard quantum circuit notation, and can output circuit diagrams, and the corresponding unitary transformation matrix as well as return the probabilities for results of measurements on a given qubit. Moreover, there is built in functionality for easy circuit addition, allowing one to stitch together large circuits from smaller ones, a boon for comprehension and testing.&#xD;
&#xD;
**A Simple Example**&#xD;
&#xD;
We initialize some random circuit by specifying it&amp;#039;s corresponding circuit notation. For sake of brevity, we start with a medium-sized circuit that is already formed, and perform operations on it, but one can easily build a circuit up qubit-by-qubit and gate-by-gate with the applyQ and circuitQ functions. Below we name some variable `quantumCircuit` using the function `circuitQ` to which we pass some circuit notation. This notation is just a matrix representing the quantum logic circuit, with the gates and qubits arranged schematically. &#xD;
&#xD;
    quantumCircuit= circuitQ[{{&amp;#034;H&amp;#034;, &amp;#034;R[1,Pi/2]&amp;#034;, &amp;#034;N&amp;#034;, &amp;#034;SWAP1&amp;#034;}, {&amp;#034;H&amp;#034;, 1, &amp;#034;C&amp;#034;, &#xD;
    &amp;#034;SWAP2&amp;#034;}, {&amp;#034;X&amp;#034;, 1, &amp;#034;C&amp;#034;, 1}}];&#xD;
&#xD;
`circuitQ` outputs the circuit diagram corresponding to the notation given:&#xD;
&#xD;
![enter image description here][1]&#xD;
&#xD;
But, say I wish to alter the circuit. We can add in as many layers of gates or extra qubits as we wish, without having to deal with the pesky notation matrix. Here I add a Hadamard gate to the second qubit after the SWAP using the function `applyQ`:&#xD;
&#xD;
    applyQ[quantumCircuit, &amp;#034;H&amp;#034;, 2]&#xD;
the output of which is:&#xD;
&#xD;
![enter image description here][2]&#xD;
&#xD;
One can also use `Append`, `Join`,`Nest` and a variety of other Wolfram language functions to build up highly complex circuits. However, the `circuitQ` function is overloaded, and one can also perform computations with it. We will now build the actual unitary transformation matrix that corresponds to the circuit diagram:&#xD;
&#xD;
    unitar=matrixBuild@quantumCircuit&#xD;
which, for our circuit, produces:&#xD;
&#xD;
![enter image description here][3].&#xD;
&#xD;
Now we can easily perform operations with circuit. Let&amp;#039;s specify some random 3 qubit initial state (in the computational basis):&#xD;
&#xD;
    initalState = {1, 0, 0, 1, 0, 0, 1, 0} // Normalize&#xD;
![enter image description here][4]&#xD;
&#xD;
We can pass this initial state to the circuit easily with:&#xD;
&#xD;
    premeasure=unitar.initialState&#xD;
&#xD;
which gives back the state of the quantum register (in this case our 3 qubits) after they have been operated on by the circuit, but pre-measurement:&#xD;
&#xD;
![enter image description here][5]&#xD;
&#xD;
We can now sample our state using the `projection` function. Here we will calculate the probability of getting state |0&amp;gt; when measuring qubit #3:&#xD;
&#xD;
    projection[2,0,premeasure]&#xD;
&#xD;
which, for our case, gives back a probability of 2/3.&#xD;
&#xD;
**Wrap Up**&#xD;
&#xD;
This was only a very simple example. Using `applyQ` and `circuitQ` one can build and modify highly complex quantum circuits easily. `matrixBuild` does all the math of calculating the corresponding unitary transformation matrix for you. All that is left is for the user to pass an initial state and see the output. A good learning technique is to start with a very simple circuit and initial state, and slowly build up in complexity, performing measurements at each step, to build an intuition and working knowledge of any given quantum circuit.&#xD;
&#xD;
An obvious next step for the project would be to add functionality that allows for the easy implementation of a general quantum oracle. I would also like to add more gates to the gate library, including: $\sqrt{SWAP}$, Tofolli, and QFT&amp;lt;sup&amp;gt;-1&amp;lt;/sup&amp;gt; which were left out due to lack of time and are trivial to implement. These tools would make it significantly easier for researchers to model any given quantum circuit.&#xD;
&#xD;
**Where is the NKS?**&#xD;
&#xD;
Finding quantum algorithms that perform useful tasks faster than their classical counterparts is an open area of research. However, it is often quite difficult to design these algorithms to take advantage of interference, as well as the structure in a given computational problem that may be useful to exploit. As such, there are only a small number of important quantum algorithms that are currently known. Hopefully this tool will allow for NKS-style search experiments for interesting behavior in quantum circuits. Similar searches have been carried out for classical circuits, and the tools I built will make it easy to generate vast sets of random quantum circuits that follow certain rules. What remains is to build useful analytic tools for combing the space.&#xD;
&#xD;
&#xD;
  [1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=circuit.jpeg&amp;amp;userId=896802&#xD;
  [2]: http://community.wolfram.com//c/portal/getImageAttachment?filename=circuit2.jpeg&amp;amp;userId=896802&#xD;
  [3]: http://community.wolfram.com//c/portal/getImageAttachment?filename=unitar.jpeg&amp;amp;userId=896802&#xD;
  [4]: http://community.wolfram.com//c/portal/getImageAttachment?filename=3114initialstate.jpeg&amp;amp;userId=896802&#xD;
  [5]: http://community.wolfram.com//c/portal/getImageAttachment?filename=finalstate.jpeg&amp;amp;userId=896802</description>
    <dc:creator>Aaron Tohuvavohu</dc:creator>
    <dc:date>2016-08-02T02:35:38Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/943405">
    <title>A toy Wolfram Language interpreter in Haskell</title>
    <link>https://community.wolfram.com/groups/-/m/t/943405</link>
    <description>Recently I wrote a toy [Wolfram Language][1] interpreter as a way to learn more about Wolfram Language. I have implemented some basic language structure and built-in functions. I have hosted it on [github][2].&#xD;
&#xD;
![enter image description here][3]&#xD;
&#xD;
# A simple term rewriting system with Wolfram Language&amp;#039;s syntax&#xD;
&#xD;
Inspired by the book [Write Yourself a Scheme in 48 Hours](https://en.wikibooks.org/wiki/Write_Yourself_a_Scheme_in_48_Hours).&#xD;
I decide to write myself a simple `Wolfram Language`-like interpreter to learn more about `Haskell` as well as&#xD;
achieve a deeper understanding about `Wolfram Language`.&#xD;
&#xD;
&#xD;
## Running (Using [Stack](https://github.com/commercialhaskell/stack))&#xD;
&#xD;
    git clone https://github.com/jyh1/mmaclone.git&#xD;
    cd mmaclone/mmaclone&#xD;
    stack setup&#xD;
    stack build&#xD;
    stack exec mmaclone-exe&#xD;
&#xD;
Prebulid binary files are available on the [release page](https://github.com/jyh1/mmaclone/releases)&#xD;
&#xD;
## Features&#xD;
&#xD;
This interpreter is intended to mimic every exact detail of `Wolfram Language`, including but not limited to its syntax, semantic,&#xD;
expression structure, evaluation details, etc. (All the scripts below were executed in the REPL session of the `mmaclone` program)&#xD;
&#xD;
1. The program support nearly all `Wolfram Language`&amp;#039;s syntax sugar, infix operators as well as their precedence. Inequality expression chain is parsed in the same way with `Wolfram Language`.&#xD;
&#xD;
&#xD;
        In[1]:= FullForm[a==b&amp;gt;=c&amp;lt;=d&amp;lt;e]&#xD;
        Out[1]= Inequality[a,Equal,b,GreaterEqual,c,LessEqual,d]&#xD;
&#xD;
  Some more complicated examples.&#xD;
&#xD;
        In[2]:= FullForm[P@1@2//3]&#xD;
        Out[2]= 3[P[1[2]]]&#xD;
        In[3]:= FullForm[P&amp;#039;&amp;#039;&amp;#039;&amp;#039;[x]]&#xD;
        Out[3]= Derivative[4][P][x]&#xD;
        In[4]:= FullForm[Hold[(1 ##&amp;amp;)[2]]]&#xD;
        Out[4]= Hold[Function[Times[1,SlotSequence[1]]][2]]&#xD;
&#xD;
2. `Wolfram Language`&amp;#039;s powerful pattern matching is also implemented with scrupulous.&#xD;
&#xD;
        (*The famous bubble sort implementation*)&#xD;
        In[1]:= sortRule := {x___,y_,z_,k___}/;y&amp;gt;z -&amp;gt; {x,z,y,k}&#xD;
        In[2]:= {64, 44, 71, 48, 96, 47, 59, 71, 73, 51, 67, 50, 26, 49, 49}//.sortRule&#xD;
        Out[2]= {26,44,47,48,49,49,50,51,59,64,67,71,71,73,96}&#xD;
        (*Symbolic manipulation*)&#xD;
        In[3]:= rules:={Log[x_ y_]:&amp;gt;Log[x]+Log[y],Log[x_^k_]:&amp;gt;k Log[x]}&#xD;
        In[4]:= Log[a (b c^d)^e] //. rules&#xD;
        Out[4]= Log[a]+e (Log[b]+d Log[c])&#xD;
&#xD;
  Currently, the derivative function `D` is not built-in supported, but you could easily implement one with the powerful pattern matching facilities.&#xD;
&#xD;
          In[5]:= D[a_,x_]:=0&#xD;
          In[6]:= D[x_,x_]:=1&#xD;
          In[7]:= D[a_+b__,x_]:=D[a,x]+D[Plus[b],x]&#xD;
          In[8]:= D[a_ b__,x_]:=D[a,x] b+a D[Times[b],x]&#xD;
          In[9]:= D[a_^(b_), x_]:= a^b(D[b,x] Log[a]+D[a,x]/a b)&#xD;
          In[10]:= D[Log[a_], x_]:= D[a, x]/a&#xD;
          In[11]:= D[Sin[a_], x_]:= D[a,x] Cos[a]&#xD;
          In[12]:= D[Cos[a_], x_]:=-D[a,x] Sin[a]&#xD;
          (*performing derivative*)&#xD;
          In[13]:= D[Sin[x]/x,x]&#xD;
          Out[13]= -x^(-2) Sin[x]+Cos[x] x^(-1)&#xD;
          In[14]:= D[%,x]&#xD;
          Out[14]= -Cos[x] x^(-2)-(-2 x^(-3) Sin[x]+Cos[x] x^(-2))-x^(-1) Sin[x]&#xD;
&#xD;
    Pattern test facility is of the same semantic with `Wolfram Language`&amp;#039;s.&#xD;
&#xD;
          In[15]:= {{1,1},{0,0},{0,2}}/.{x_,x_}/;x+x==2 -&amp;gt; a&#xD;
          Out[15]= {a,{0,0},{0,2}}&#xD;
          In[16]:= {a, b, c, d, a, b, b, b} /. a | b -&amp;gt; x&#xD;
          Out[16]= {x,x,c,d,x,x,x,x}&#xD;
          In[17]:= g[a_*b__]:=g[a]+g[Times[b]]&#xD;
          In[18]:= g[x y z k l]&#xD;
          Out[18]= g[k]+g[l]+g[x]+g[y]+g[z]&#xD;
          In[19]:= q[i_,j_]:=q[i,j]=q[i-1,j]+q[i,j-1];q[i_,j_]/;i&amp;lt;0||j&amp;lt;0=0;q[0,0]=1;Null&#xD;
          In[20]:= q[5,5]&#xD;
          Out[20]= 252&#xD;
&#xD;
3. Some interesting scripts&#xD;
&#xD;
&#xD;
          In[1]:= ((#+##&amp;amp;) @@#&amp;amp;) /@{{1,2},{2,2,2},{3,4}}&#xD;
          Out[1]= {4,8,10}&#xD;
          In[2]:= fib[n_]:=fib[n]=fib[n-1]+fib[n-2];fib[1]=fib[2]=1;Null&#xD;
          In[3]:= fib[100]&#xD;
          Out[3]= 354224848179261915075&#xD;
          In[4]:= fib[1000000000000]&#xD;
          Iteration Limit exceeded, try to increase $IterationLimit&#xD;
          In[5]:= Print/@fib/@{10,100}&#xD;
          55&#xD;
          354224848179261915075&#xD;
          Out[5]= {Null,Null}&#xD;
&#xD;
&#xD;
## More&#xD;
&#xD;
For more information please refer to the project [wiki](https://github.com/jyh1/mmaclone/wiki) (still under construction).&#xD;
&#xD;
## Features that are likely to be added in future versions:&#xD;
&#xD;
(Some serious design errors are exposed during development, which I consider are inhibiting&#xD;
  the project from scaling up. So currently my primary focus would be on refactor&#xD;
  rather than adding new features/functions)&#xD;
&#xD;
1. More mathematical functions (`Sin`, `Cos`, `Mod` etc...)&#xD;
2. Arbitrary precision floating arithmetic using GMP(GNU Multiple Precision Arithmetic Library), currently arbitrary integer, double and rational number are supported.&#xD;
2. More built-in functions (`Level`, `Import`, `Derivative`etc...)&#xD;
3. More sophisticated pattern matching&#xD;
  * ~~head specification (of the form Blank[*Head*], currently it only support list type)~~(**Implemented**)&#xD;
  * ~~Pattern Test~~(**Implemented**)&#xD;
  * ~~BlankSequence, BlankNullSequence~~(**Implemented**)&#xD;
  * Other pattern matching expression, like `Verbatim`, `Longest`&#xD;
4. ~~RecursionLimit~~(**Implemented**)&#xD;
5. Negative index e.g. in `Part`&#xD;
6. Negative level specification&#xD;
7. Curried function e.g. `f[a][b]` (currently it will throw an error if one is trying to attach value to&#xD;
  the curried form through `Set` or `SetDelayed`)&#xD;
8. Use iPython as front end&#xD;
9. ~~Replace String implementation with more efficient Text~~(**Implemented**)&#xD;
&#xD;
&#xD;
  [1]: https://www.wolfram.com/language/&#xD;
  [2]: https://github.com/jyh1/mmaclone&#xD;
  [3]: http://community.wolfram.com//c/portal/getImageAttachment?filename=demo.png&amp;amp;userId=943384</description>
    <dc:creator>Yonghao Jin</dc:creator>
    <dc:date>2016-10-14T15:20:34Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/1421180">
    <title>Rubi - The Rule-based Integrator for Mathematica</title>
    <link>https://community.wolfram.com/groups/-/m/t/1421180</link>
    <description>Two months ago, Albert Rich posted [&amp;#034;What&amp;#039;s the hardest integral Mathematica running Rubi can find?&amp;#034;](http://community.wolfram.com/groups/-/m/t/1343015) here on the Wolfram Community.&#xD;
You might have also seen that I responded in detail, and pointed out a few things that could help improve Rubi (Rule-based integrator).&#xD;
While it appears nothing really happened afterward, this is far from reality.&#xD;
Since then, Albert and I have worked closely together to make Rubi more accessible and user-friendly.&#xD;
If you would like to learn how our productive collaboration evolved, let me invite you to read [my latest blog-post](http://halirutan.de/programming/Rubi/).&#xD;
However, here, we want to share an update that should serve as an overview of what we have done to improve Rubi.&#xD;
&#xD;
First of all, Rubi has got a new home under [rulebasedintegration.org](https://rulebasedintegration.org/), and its old website will no longer be updated.&#xD;
On the new website, you will find information, installation instructions, and links to the source-code and test-suites.&#xD;
&#xD;
Secondly, we created a [Rubi Organization](https://github.com/RuleBasedIntegration) on GitHub that serves as the headquarters for all things Rubi.&#xD;
It contains all Rubi&amp;#039;s code, notebooks, and test-suites nicely structured into several repositories.&#xD;
At the moment, we provide repositories for the&#xD;
&#xD;
* loadable package files and notebook source files defining over 6700 integration rules,&#xD;
* PDF files displaying the rules in human-readable mathematical notation alongside the Mathematica code, and&#xD;
* test-suite files containing over 71000 integration problems and their solutions.&#xD;
&#xD;
The integration test files are available in the syntax used by 4 popular computer algebra systems (Mathematica, Maple, Maxima, and Axiom).&#xD;
The test-suite can be used to compare Rubi&amp;#039;s results with other symbolic integrators, including Mathematica&amp;#039;s `Integrate` function.&#xD;
&#xD;
In addition to the transition to GitHub, we recently released version 4.16.0.3 of Rubi which significantly expands the class of expressions the system can integrate.&#xD;
But the most noticeable change for users is the completely reworked display of the rules and intermediate steps Rubi uses to integrate expressions.&#xD;
Although installation, usage, and examples are given on [Rubi&amp;#039;s website](https://rulebasedintegration.org/), let me show you how easy it is to install and run Rubi 4.16.0.3 using Mathematica 11.3:&#xD;
&#xD;
The command&#xD;
&#xD;
    PacletInstall[&amp;#034;https://github.com/RuleBasedIntegration/Rubi/releases/download/4.16.0.3/Rubi-4.16.0.3.paclet&amp;#034;];&#xD;
&#xD;
installs the Rubi-4.16.0.3 paclet on your computer.&#xD;
After that, to load Rubi into Mathematica all you have to do is issue the `Get` command&#xD;
&#xD;
    &amp;lt;&amp;lt; Rubi`&#xD;
&#xD;
Then to integrate an expression with respect to a variable, use Rubi&amp;#039;s `Int` command similar to Mathematica&amp;#039;s `Integrate` command.  For example, evaluating&#xD;
&#xD;
    Int[(Sec[x]^2 + Sec[x]^2*Tan[x])/((2 - Tan[x])*Sqrt[1 + Tan[x]^3]), x]&#xD;
&#xD;
returns the antiderivative (a.k.a. the indefinite integral)&#xD;
&#xD;
![enter image description here][1]&#xD;
&#xD;
Rubi&amp;#039;s unique ability to display the steps it uses to integrate expressions is a great feature of the system.&#xD;
For example, the `Steps` command&#xD;
&#xD;
    Steps@Int[(Sec[x]^2 + Sec[x]^2*Tan[x])/((2 - Tan[x])*Sqrt[1 + Tan[x]^3]), x]&#xD;
&#xD;
displays&#xD;
&#xD;
![enter image description here][2]&#xD;
&#xD;
Here, in red are the rules used to integrate the expression, and in blue are the intermediate results.&#xD;
Each rule can be expanded to show the rule number, which directly corresponds to the index of the rule in `Int`&amp;#039;s list of DownValues.&#xD;
More importantly, you can see the conditions that have to be satisfied so the rule can be applied.&#xD;
&#xD;
![enter image description here][3]&#xD;
&#xD;
Rubi&amp;#039;s `Stats` command provides statistics about the integration. For example,&#xD;
&#xD;
    Stats[Int[(Sec[x]^2 + Sec[x]^2*Tan[x])/((2 - Tan[x])*Sqrt[1 + Tan[x]^3]), x]]&#xD;
&#xD;
displays&#xD;
&#xD;
![enter image description here][4]&#xD;
&#xD;
The leaf-count size of an antiderivative is a crude measure of its complexity.&#xD;
As you can see, Rubi&amp;#039;s antiderivative for this integral has a leaf-count of 25.&#xD;
Now compare Rubi&amp;#039;s antiderivative with that produced by Mathematica 11.3 for the same integral:&#xD;
&#xD;
    Integrate[(Sec[x]^2 + Sec[x]^2*Tan[x])/((2 - Tan[x])*Sqrt[1 + Tan[x]^3]), x]&#xD;
&#xD;
![enter image description here][5]&#xD;
&#xD;
    LeafCount[%]&#xD;
    (*  290 *)&#xD;
&#xD;
Note that not only is Mathematica&amp;#039;s result more than 11 times the size of Rubi&amp;#039;s, it unnecessarily involves elliptic integral functions *and* the imaginary unit.&#xD;
&#xD;
Skeptics might be inclined to ask if Rubi&amp;#039;s dramatically simpler result is actually a valid antiderivative.&#xD;
Since symbolic differentiation is much easier than integration, antiderivatives can be verified correct by seeing if its derivative equals the original integrand as follows:&#xD;
&#xD;
    expr = (Sec[x]^2 + Sec[x]^2*Tan[x])/((2 - Tan[x])*Sqrt[1 + Tan[x]^3]);&#xD;
    FullSimplify[D[Int[expr, x], x] == expr]&#xD;
    FullSimplify[D[Integrate[expr, x], x] == expr]&#xD;
&#xD;
![enter image description here][6]&#xD;
&#xD;
As you can see Mathematica easily verifies Rubi&amp;#039;s antiderivative correct, but has a hard time verifying its own antiderivative correct...&#xD;
&#xD;
Albert and I are working on publishing the program used to thoroughly test each new version of Rubi before being released.&#xD;
The test program ensures Rubi&amp;#039;s result equals the optimal antiderivative for the over 71000 problems in the test-suite.&#xD;
And yes, the optimal antiderivatives have all been verified correct by differentiation.&#xD;
&#xD;
Of course, the optimal antiderivatives stored in the test-suite are actually just the simplest ones found so far.&#xD;
If you should find a substantially simpler antiderivative than the one in the test-suite, please report it so the test-suite can be made even harder on Rubi!&#xD;
&#xD;
If all that has got you interested in joining Rubi&amp;#039;s community of users, check out its website or talk to us in our [Gitter chatroom](https://gitter.im/Rule-Based-Integration/Lobby).&#xD;
&#xD;
&#xD;
  [1]: https://community.wolfram.com//c/portal/getImageAttachment?filename=10564sSs5M.png&amp;amp;userId=11733&#xD;
  [2]: https://community.wolfram.com//c/portal/getImageAttachment?filename=qDtIH.png&amp;amp;userId=11733&#xD;
  [3]: https://community.wolfram.com//c/portal/getImageAttachment?filename=vQ4GR.png&amp;amp;userId=11733&#xD;
  [4]: https://community.wolfram.com//c/portal/getImageAttachment?filename=43t8e.png&amp;amp;userId=11733&#xD;
  [5]: https://community.wolfram.com//c/portal/getImageAttachment?filename=xjKTJ.png&amp;amp;userId=11733&#xD;
  [6]: https://community.wolfram.com//c/portal/getImageAttachment?filename=eCoWB.png&amp;amp;userId=11733</description>
    <dc:creator>Patrick Scheibe</dc:creator>
    <dc:date>2018-08-24T02:50:37Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/126665">
    <title>Errors of exporting FITS file</title>
    <link>https://community.wolfram.com/groups/-/m/t/126665</link>
    <description>Could anyone help? Always getting errors when export simple data to FITS format. I&amp;#039;m using Macbook Air, OS X 10.8.4. Not sure if it&amp;#039;s machine dependent.   

e.g., 
[mcode]d = First@
   Import[&amp;#034;http://exampledata.wolfram.com/messier61.fits.gz&amp;#034;, 
    &amp;#034;RawData&amp;#034;];

Export[&amp;#034;image.fits&amp;#034;, d]

ConstantArray::ilsmn: Single or list of non-negative machine-sized integers expected at position 2 of ConstantArray[32,{-17}]. &amp;gt;&amp;gt;
Join::heads: Heads List and ConstantArray at positions 1 and 3 are expected to be the same. &amp;gt;&amp;gt;
BinaryWrite::nocoerce: Join[{83,73,77,80,76,69,32,32,61,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,84,32,47,32,78,111,114,109,97,108,32,70,73,84,83,32,102,105,108,101,32,&amp;lt;&amp;lt;750&amp;gt;&amp;gt;},&amp;lt;&amp;lt;3&amp;gt;&amp;gt;,{32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,&amp;lt;&amp;lt;13&amp;gt;&amp;gt;,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,&amp;lt;&amp;lt;27&amp;gt;&amp;gt;}] cannot be coerced to the specified format. &amp;gt;&amp;gt;[/mcode]</description>
    <dc:creator>XIN Wang</dc:creator>
    <dc:date>2013-09-19T19:44:31Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/504085">
    <title>How to color each point with a different color in ListPlot?? Please help</title>
    <link>https://community.wolfram.com/groups/-/m/t/504085</link>
    <description>Hello colleagues... I&amp;#039;m afraid that this is an easy question, but I found no solution yet&#xD;
&#xD;
Here it goes: I have a list of points, and a list of colors (both of the same length), say:   &#xD;
&#xD;
     aList = {{1, 1}, {2, 3}, {4, 5}, {6, 7}};&#xD;
     colorList = {Black, Red, Blue, Yellow};&#xD;
&#xD;
I want to plot the points using ListPlot, but taking care that each point should have a different color, according to the colorList.&#xD;
So, the point {1,1} should be colored black, the point {2,3} should be red, and so on....&#xD;
In the actual problem I&amp;#039;m solving, the length of the list is about 30.000, so I need an efficient way to construct the plots...&#xD;
&#xD;
Thank you very much!!! :-)&#xD;
&#xD;
Daniel</description>
    <dc:creator>Daniel Branco</dc:creator>
    <dc:date>2015-05-26T15:49:06Z</dc:date>
  </item>
</rdf:RDF>

