Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #5559
| From | "Oleksandr Rasputinov" <oleksandr_rasputinov@hmamail.com> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: "Esoteric of the week" |
| Date | 2011-10-09 07:52 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <j6rjsl$1ll$1@smc.vnet.net> (permalink) |
| References | <j6q5mt$ov1$1@smc.vnet.net> |
On Sat, 08 Oct 2011 19:44:45 +0100, Bill Rowe <readnews@sbcglobal.net>
wrote:
> On 10/6/11 at 4:23 AM, weh@snafu.de (Dr. Wolfgang Hintze) wrote:
>
>> What about setting up a regular column "esoteric of the week" naming
>> functions that are rarely used ?
>
> The difficulty is a determination of rarely used. Who decides?
> And how? ... For me at least, the operational definition of rarely
> used would be those functions I have to look up syntax to use correctly.
>
Along these lines, I would suggest a family of undocumented Internal`
functions that can be quite useful:
Internal`InheritedBlock:
works just like Block, except that the definitions of the localized
symbols are copied from the global environment (including Attributes,
Options, etc.). Useful for temporarily overriding the properties of
System` functions without going through the Unprotect/modify/Protect
dance, for example.
{Internal`Bag, Internal`StuffBag, Internal`BagPart}:
described by Daniel Lichtblau here:
<http://stackoverflow.com/questions/6691491/implementing-a-quadtree-in-mathematica>.
Apart from being useful for building your own data structures, Bags are
considered to be scalars by the Mathematica compiler and can be used to
build up lists inside compiled code without AppendTo (and its associated
CopyTensor). (Sow/Reap use Bags but at present don't work in compiled code
because their ability to associate a tag with each expression relies on
pattern matching.)
Internal`Deflatten:
Somewhat similar to Partition, but only works with 1-d Lists and operates
based on a structural specification as given by Dimensions. Similar to the
RESHAPE function from Fortran 90. Say we have a list (which must be a
full-rank tensor) with some nested structure:
lst = Partition[{{11, 12, 13}, {21, 22, 23}, {31, 32, 33}}, {2, 1}, 1];
dims = Dimensions[lst]
{2, 3, 2, 1}
lst == Internal`Deflatten[Flatten[lst], dims]
True
an important point to note about Internal`Deflatten is that a dimensional
specification must not be given that would require more elements in the
source array than actually exist in order to produce a full-rank tensor
result. That is, for Internal`Deflatten[lst, dims], Times @@ dims <=
Length@Flatten[lst] must be fulfilled, otherwise the kernel will crash.
Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Find similar | Unroll thread
Re: = ? Bill Rowe <readnews@sbcglobal.net> - 2011-10-08 18:44 +0000
Re: "Esoteric of the week" "Oleksandr Rasputinov" <oleksandr_rasputinov@hmamail.com> - 2011-10-09 07:53 +0000
Re: "Esoteric of the week" Richard Fateman <fateman@cs.berkeley.edu> - 2011-10-10 08:27 +0000
Re: "Esoteric of the week" "Oleksandr Rasputinov" <oleksandr_rasputinov@hmamail.com> - 2011-10-09 07:52 +0000
csiph-web