Wednesday, May 31, 2017

C++ – CALLING OVERLOADED OPERATOR () FROM POINTER

http://www.tonysaad.net/category/notes/

Cite as:
Saad, T. "C++ – CALLING OVERLOADED OPERATOR () FROM POINTER". Weblog entry from Please Make A Note. https://pleasemakeanote.blogspot.com/2017/05/c-calling-overloaded-operator-from.html

Monday, April 11, 2016

Monday, September 28, 2015

How to Release all PBS Jobs with qrls

I have problems using qrls all on the Titan supercomputer. You can use the following little script as an alternative

First create a small script file
emacs qrlsall

In qrlsall, type the following
#!/bin/bash
jobids=$(showq -u tsaad | awk '{if ($3 == "UserHold") print $1;}')
echo $jobids
qrls $jobid
Now make qrlsall executable 
chmod +x qrlsall
Voila!

Cite as:
Saad, T. "How to Release all PBS Jobs with qrls". Weblog entry from Please Make A Note. https://pleasemakeanote.blogspot.com/2015/09/how-to-release-all-pbs-jobs-with-qrls.html

Monday, March 9, 2015

Latex v Symbol MathJax Wordpress

The default latex math symbol for v looks like a nu. I usually use \varv to avoid that stupid letter. However, MathJax does not support \varv. Here's what I did for my wordpress site www.cfdmath.com. In my header scripts (or where ever you put your mathjax script) add the following:
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
  "HTML-CSS": {
    availableFonts: []
  }
});
</script>
According to MathJax documentation, this essentially enforces MathJax to use web-based or image fonts. It seems to do the trick and all my v's look pretty now.

Cite as:
Saad, T. "Latex v Symbol MathJax Wordpress". Weblog entry from Please Make A Note. https://pleasemakeanote.blogspot.com/2015/03/latex-v-symbol-mathjax-wordpress.html

Thursday, March 5, 2015

Tuesday, March 3, 2015

Git Remote Branches not showing/not listed

Try
git config remote.origin.fetch +refs/heads/*:refs/remotes/origin/*
git fetch

Cite as:
Saad, T. "Git Remote Branches not showing/not listed". Weblog entry from Please Make A Note. https://pleasemakeanote.blogspot.com/2015/03/git-remote-branches-not-showingnot.html

Wednesday, July 16, 2014

Using GitStat to Generate Commit Statistics for Git Repositories


You will nee python and a working installation of gnuplot.
  1. cd ~/pkg/
  2. git clone git://github.com/hoxu/gitstats.git
  3. cd gitstats
  4. ./gitstats path-to-repository path-to-html-output
Done!
Here's what I do for my code
  1. cd ~/pkg/
  2. git clone git://github.com/hoxu/gitstats.git
  3. cd gitstats
  4. ./gitstats -c start_date=1/1/2014  ~/development/uintah-work/src ~/uintah-stats-2014/
For more information on the options provided by gitstat, use
./gitstats --help
Note that you will always need to use -c flag to change the gitstats configuration.

Cite as:
Saad, T. "Using GitStat to Generate Commit Statistics for Git Repositories". Weblog entry from Please Make A Note. https://pleasemakeanote.blogspot.com/2014/07/using-gitstat-to-generate-commit.html

Tuesday, June 24, 2014

Maximum Entropy PDF Reconstruction Code

Many of you have asked me to share my Maximum Entropy Method code for the reconstruction of density distributions. Unfortunately, I am unable to do that at the moment. In an effort to stop the email campaign that is asking me for the code, I decided to create a cgi interface for it and put it online. So here it goes...

Here is a summary of the maximum entropy method. You can access my code through the interface below. At the bottom of this page, you will find a example moments from known distributions. Use those to experiment with the code.
Usage:
  • Known Moments: The set of all known moments for the unknown distribution. Enter one moment per line in the textarea below. Moments are assumed to be integer moments and are given as m0, m1, m2, etc...
  • Number of Moments: Specify how many moments you wish to use (from the set of known moments) to reconstruct the distribution
  • Lower Bound: Specify the lower bound on the reconstructed distribution
  • Upper Bound: Specify the upper bound on the reconstructed distribution
  • Number of Integration Points: Has to do with the numerical quadrature algorithm. Defaults to 80,000
  • Maximum number of Iterations: specifies the number of internal iterations of the nonlinear solver
  • Tolerance: Specifies the nonlinear solver tolerance
  • Finite Difference Jacobian: Use finite difference to compute the Jacobian matrix
  • Discrete Distribution: Use to reconstruct Discrete distribution. NOTE: Make sure you use a realistic number of integration points!

Known Moments
Number of Moments
Lower Bound
Upper Bound
# of Integration Points
Maximum # of Iterations
Tolerance
Finite Difference Jacobian
Discrete Distribution

Cite as:
Saad, T. "Maximum Entropy PDF Reconstruction Code". Weblog entry from Please Make A Note. https://pleasemakeanote.blogspot.com/2014/06/maximum-entropy-pdf-reconstruction-code.html

Tuesday, July 23, 2013

how to move keynote from one mac to another

See:

http://geekinc.ca/moving-iwork-pages-keynote-and-numbers-from-an-old-apple-to-a-new-one/
I basically moved the following files:

  • Macintosh HD:Library:Preferences:com.apple.iWork09.Installer.plist
  • Macintosh HD:Library:Preferences:com.apple.iWork09.plist 
  •  Macintosh HD:Library:Application Support:Keynote
  • Macintosh HD:Library:Application Support:iWork ’09
  • Macintosh HD:Applications:iWork ’09


Cite as:
Saad, T. "how to move keynote from one mac to another". Weblog entry from Please Make A Note. https://pleasemakeanote.blogspot.com/2013/07/how-to-move-keynote-from-one-mac-to.html

Saturday, July 6, 2013

My New Project: Show Me the Math

Please join me in celebrating the launch of my new project "Show Me the Math", a journal purely dedicated to mathematical derivations of physical and numerical stuff. I will no longer post derivations on pleasemakeanote as those will go to showmethemath. I will start porting and improving the current derivations to the new blog as time goes by.

Thank you all for your support,
yNot

Cite as:
Saad, T. "My New Project: Show Me the Math". Weblog entry from Please Make A Note. https://pleasemakeanote.blogspot.com/2013/07/my-new-project-show-me-math.html

latex2html Underline Equations and Formulas

I recently tried to use latex2html to export a few of my tex documents to html. I simply used
latex2html main.tex
but I ended up with a bunch of unsavory lines under all of my equations. Upon googling things a bit, I found the following solution that worked for me:
https://ccrma.stanford.edu/~jos/webpub/Eliminating_Black_Rules_Equation.html
On my mac, here's what I did:

  1. search for the file alt-rule.pro (on my Mac, I opened the folder /usr and searched for it there. the file was located under: /usr/local/texlive/2012/texmf/dvips/config/
  2. edit the file as suggested by the link above. i.e., replace
    gsave newpath   /ruleY X /ruleX X
    with
    gsave newpath
    transform round exch round exch itransform
    /ruleY X /ruleX X
and Voila!


Cite as:
Saad, T. "latex2html Underline Equations and Formulas". Weblog entry from Please Make A Note. https://pleasemakeanote.blogspot.com/2013/07/latex2html-underline-equations-and.html

Wednesday, April 10, 2013

git autocomplete on Mac OS X

I use a variety both Linux and OSX in my work. Since my recent adoption of git, I have been mostly logged in to our Linux box and had been enjoying the awesome git autocomplete features in bash. When I switched to my Mac though, I couldn't get this work - but my pinky refused to stop pressing the tab key.

Luckily, the folks at git have an autocomplete script ready to install on your machine. Here's what you have to do:
curl https://raw.github.com/git/git/master/contrib/completion/git-completion.bash -o ~/.git-completion.bash
echo "source ~/.git-completion.bash" >> ~/.bash_profile

and Voila!

Thanks to Mike Pottyn for this: http://railslove.com/blog/2011/11/25/git-autocomplete-in-bash-on-a-mac

Cite as:
Saad, T. "git autocomplete on Mac OS X". Weblog entry from Please Make A Note. https://pleasemakeanote.blogspot.com/2013/04/git-autocomplete-on-mac-os-x.html

Thursday, January 31, 2013

Monday, September 17, 2012

XCode 4 Build Locations (Lion, Mountain Lion)

Apparently, the "most advanced" operating system in the world is not very friendly for power-users and developers.

The new xcode 4 has had a major rehaul. I just updated to mountain lion and the latest xcode (4.4.1). The first annoying feature that you will notice about xcode is the non-intuitive and complex user interface. I can't even find the console or the debugging tools... oh wait, they're placed at the bottom of the screen and they're practically invisible. Maybe it is time to read the documentation... but who has time for that?

In any event, I went ahead and tested a "Bonjour y'all!" code and it worked. but I could not locate the executable file in the project's directory. Are you serious? It turns out that XCode defaults to some location in your library. Fortunately, I just found a way to go back to standard operation and place your executable where it BELONGS:

  1. Open XCODE
  2. go to: Preferences
  3. Click on the "Locations" tab
  4. Change the path for "Derived Data" to relative and that should do it.
  5. If you want to be a bit more picky, click on Advanced
    1. select "Custom"
      1. Select "Relative to Workspace"
That last step will place your executable in its normal location.

Hope that helps.

Cite as:
Saad, T. "XCode 4 Build Locations (Lion, Mountain Lion)". Weblog entry from Please Make A Note. https://pleasemakeanote.blogspot.com/2012/09/xcode-4-build-locations-lion-mountain.html

Friday, September 14, 2012

Calling gnuplot from C/C++ on Mac OS X

Here's another way of calling gnuplot from Mac OS X.

First install gnuplot either from their website or using macports. I like the macports model because it installs all dependencies for you automatically.
  1. Install macports from: http://www.macports.org/ 
  2. Open up your terminal
  3. type: sudo port selfupdate (to update port names)
  4. type: sudo port install gnuplot
and Voila! you now have gnuplot installed on your mac. To test it type: gnuplot and you should enter the gnuplot environment. Another caveat that you have to bear in mind when using gnuplot on mac is that you have to tell gnuplot to use x11. You do this as follows:
  1. Open up your terminal
  2. type: gnuplot
  3. type: set terminal x11
Now to the fun stuff. Here's the code that I used before to call gnuplot for windows, but modified to work on Unix based systems such as Mac.

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
void plotResults(double* xData, double* yData, int dataSize);
int main() {
  int i = 0;
  int nIntervals = 100;
  double intervalSize = 1.0;
  double stepSize = intervalSize/nIntervals;
  double* xData = (double*) malloc((nIntervals+1)*sizeof(double));
  double* yData = (double*) malloc((nIntervals+1)*sizeof(double));
  xData[0] = 0.0;
  double x0 = 0.0;
  for (i = 0; i < nIntervals; i++) {
      x0 = xData[i];
      xData[i+1] = x0 + stepSize;
  }
  for (i = 0; i <= nIntervals; i++) {
      x0 = xData[i];
      yData[i] = sin(x0)*cos(10*x0);
  }
  plotResults(xData,yData,nIntervals);
  return 0;
}
void plotResults(double* xData, double* yData, int dataSize) {
  FILE *gnuplotPipe,*tempDataFile;
  char *tempDataFileName;
  double x,y;
  int i;
  tempDataFileName = "tempData";
  gnuplotPipe = popen("gnuplot","w");
  if (gnuplotPipe) {
      fprintf(gnuplotPipe,"plot \"%s\" with lines\n",tempDataFileName);
      fflush(gnuplotPipe);
      tempDataFile = fopen(tempDataFileName,"w");
      for (i=0; i <= dataSize; i++) {
          x = xData[i];
          y = yData[i];            
          fprintf(tempDataFile,"%lf %lf\n",x,y);        
      }        
      fclose(tempDataFile);        
      printf("press enter to continue...");        
      getchar();        
      remove(tempDataFileName);        
      fprintf(gnuplotPipe,"exit \n");    
  } else {        
      printf("gnuplot not found...");    
  }
} 


This code should run as is. Of course, feel free to take the plot function and use it in your own codes.

Cite as:
Saad, T. "Calling gnuplot from C/C++ on Mac OS X". Weblog entry from Please Make A Note. https://pleasemakeanote.blogspot.com/2012/09/calling-gnuplot-from-cc-on-mac-os-x.html

Thursday, June 23, 2011

The Maximum Entropy Method for Reconstructing Density Distriubtions

A summary of using the maximum entropy principle from information theory to reconstruct a PDF (or other distributions) given a finite number of moments. This is quite useful especially when using the method of moments in population balances or related stochastic transport processes. The document also includes some results from my code for reconstructing some bimodal and trimodal Gaussian distributions, beta, and log-normal distributions.

Download PDF

Cite as:
Saad, T. "The Maximum Entropy Method for Reconstructing Density Distriubtions". Weblog entry from Please Make A Note. https://pleasemakeanote.blogspot.com/2011/06/maximum-entropy-method-for.html

Monday, April 11, 2011

Quadrature Methods for Numerical Integration

A review of Gaussian quadrature for numerical integration. Discusses Lagrange's interpolation and the theory of orthogonal polynomials.

Download PDF.

Cite as:
Saad, T. "Quadrature Methods for Numerical Integration". Weblog entry from Please Make A Note. https://pleasemakeanote.blogspot.com/2011/04/quadrature-methods-for-numerical.html

Saturday, April 2, 2011

Endnote Auto-formatting parentheses

I do not use EndNote. And most likely never will. But here's an annoyance that you may have encountered  while working on your word documents.

Sometimes, in your word document, if you write certain acronyms between parentheses, EndNote may think that this is a reference. To prevent this from happening, in EndNote, do the following:

Files->Preferences->Autoformat

and change the delimiters from parentheses to something else.

Cite as:
Saad, T. "Endnote Auto-formatting parentheses". Weblog entry from Please Make A Note. https://pleasemakeanote.blogspot.com/2011/04/endnote-auto-formatting-parentheses.html