Install on Mac.

We assume that there are two folders "OX-1.3.2" and "non-central-prog" 
generated by unzip.

*Your Mac setting.
    Check your system preferences so that you allow to execute
    applications which are not installed by AppStore.

    System Preferences > Security & Privacy > 
    General > Allow applications downloaded from > Anywhere

    See https://discussions.apple.com/thread/4180691 for details.

*Outer software systems 

1. Install "Xcode" (developer tools including the C compiler) 
   from the App Store (Xcode is free)

2. Install "X11" from www.xquartz.org
   See https://support.apple.com/en-gb/HT201314 for details.

3. Install "homebrew"  from https://brew.sh

4. Install emacs with GUI by homebrew
   by following http://wikemacs.org/wiki/Installing_Emacs_on_OS_X
   (brew install emacs --with-cocoa)

5. Install GSL by homebrew 
   by following  http://macappstore.org/gsl/
   (brew install gsl)

*Installing OX-1.3.2 and non-central-prog
Open the terminal and execute the following commands
under the folder where you have OX-1.3.2 and non-central-prog

1. (cd OX4/OpenXM/rc ; make clean ; make)  

2. source ./OX-1.3.2/OpenXM/rc/dot.bashrc
   use-asir-mode.sh --local-yes

3. (cd non-central-prog; make all ; make install )

------------------------------
*Quick test.
1. start the terminal.
2. source ./OX-1.3.2/OpenXM/rc/dot.bashrc 
  [ This command builds an enviroment to execute OpenXM tools 
    not beeing affected by other software systems. ]  
3. cd non-central-prog
4. make a38-test
-----------------------------
*Test step by step
1. start the terminal.
2. source ./OX-1.3.2/OpenXM/rc/dot.bashrc 
  [ This command builds an enviroment to execute OpenXM tools 
    not beeing affected by other software systems. ]  
3. cd non-central-prog
4. emacs a36d-validate.rr &
5. start asir by the "asir -> start asir" menu.
6. load the current file a36d-validate.rr to asir
   by the "asir -> execute current buffer on asir" menu.
7. Execute
     setup_process(3|x=1);  [Enter]
   on the *asir-cmd* window.
  [We execute the Runge-Kutta method on 3 processes.
   If you have many CPU's, you can increase the number 3 to larger numbers.]

8. Execute
     auto_ppp(3,3);
   on the *asir-cmd* window.
   for a test.  If you get the following output without error, 
   it seems to work fine.

Prob(210)=0.28787884955765132107459345979525985569
cddr(A26_error)=[[Sig_digits,8],[Valid_digits,[6,6,6,6,5,5,6,6,6,5,5,6,6,6,6]],[Assume Sig_digits,14],[then Valid_digits,[12,12,12,12,11,11,12,12,12,12,12,12,11,12,11]]]
Note: Terminate and restart asir to evalute other cases (Perhapas a bug ...).0
[1959] 

   This test function evaluates outage probability for the case s=3, t=3,
   and lambda = [90,150,210] and store data in the files
   tmp-Hkn-auto-3x3-*

9. Terminate asir and emacs.

10. gen-ab --s 3 --t 3 >tt.sh
11. sh ./tt.sh
   [It translates the data into asir binary form to make the next steps faster.]

12. emacs a37d2-auto-ppp-file.rr &
13. start asir by the "asir -> start asir" menu.
14. load the current file a37d2-auto-ppp-file.rr to asir
   by the "asir -> execute current buffer on asir" menu.
15. Execute
     setup_auto(3,3);  [Enter]
   on the *asir-cmd* window.
16. Execute
     auto_ppp_from_file(200); [Enter]
   on the *asir-cmd* window to obtain the prob at x=200 from the data in the 
   files tmp-Hkn-auto-3x3-*
17. Execute
     auto_gencsv(3,3,"sample"|table_fromx=100,table_tox=200); [Enter]
   on the *asir_cmd* window to obtain a csv file of x and the outage probability
   for x in [100,200] with the name sample-3-3.csv
   It also outputs sample-3-3.m, in which f[x] is the outage probability.

--------------------------
*Quck run with given s, t and lambda and generate csv file and mathematica file.
1. start the terminal.
2. source ./OX-1.3.2/OpenXM/rc/dot.bashrc 
  [ This command builds an enviroment to execute OpenXM tools 
    not beeing affected by other software systems. ]  
3. cd non-central-prog
4. emacs a38-ncwishart.rr &
5. start asir by the "asir -> start asir" menu.
6. load the current file a38-ncwishart.rr to asir
   by the "asir -> execute current buffer on asir" menu.
7. Execute
      A38_execute=1;
      ncwishart(2,3,140,[90,110]|stop=1,n_proc=2,auto_prefix="sample");
   on the *asir-cmd* window
   where s=2, t=3, xmax=140, lambda=[90,110], number of processes is 2.
   With the stop=1 option, the system asks if it proceeds on the step 2.
   After finishing the steps 2 and 3,
   you will have a csv file and Mathematica file with the name sample*.csv
   and sample*.m
   Starting point t0=(x0)^(1/2) is automatically set. It can be set by the option with the key word t0.

R
  a<-read.csv("sample-2-3.csv");
  plot(a)

Mathematica
  <<sample-2-3.m
  f[100]
  f'[100]

Usage:  S<=T.
ncwishart(S,T,Xmax,[Lambda1,Lambda2,...,LambdaS]|
         stop=1,n_proc=2,t0=5,auto_prefix="sample");
X range is [t0^2,Xmax].

Options:
 auto_prefix=getpid()  File name for work files and data files.
 use_math=1   Mathematica is used to evaluate initial values.
 use_math_strictly=1  If 1, retry the evaluation by Mathematica with 
    different parameters when precision error is reported.
 stop=0  If 1, the function confirms if it proceeds on the step 2.
    If the significant digits are less than 3 after the step 1, 
    it is recommended to abort the computation.
 err (automatically set, err=[abs_err,rel_err]) 
     Error control for the Runge-Kutta method for a27d-x.c
     Example: err=[1e-20,1e-10]

 table_step=1
 table_fromx=t0^2+1 
 table_tox=xmax+1
    These parameters control the format of the tables of the outage probability
    in the csv format and Mathematica format.
    If the options table_fromx and table_tox are not given, 
    an adaptive step size control will be used and table_step is ignored.
    Example: ncwishart(2,3,140,[90,110]|stop=1,auto_prefix="sample",table_step=0.5, table_fromx=80, table_tox=120);

Examples: example.txt   generates data in our paper.

Note for a developper (test on a system without Mathematica).
    ncwishart(2,3,140,[90,110]|stop=1,n_proc=2,auto_prefix="sample",use_math=0);

------------
*Step by step: run with given s, t and lambda and save data in files tmp-Hkn-"given name"*
 (1--9) and generate a csv file of outage probability (10--17).
1. start the terminal.
2. source ./OX-1.3.2/OpenXM/rc/dot.bashrc 
  [ This command builds an enviroment to execute OpenXM tools 
    not beeing affected by other software systems. ]  
3. cd non-central-prog
4. emacs a36d-validate.rr &
5. start asir by the "asir -> start asir" menu.
6. load the current file a36d-validate.rr to asir
   by the "asir -> execute current buffer on asir" menu.
7. Execute
     setup_process(3|x=1);  [Enter]
   on the *asir-cmd* window.
  [We execute the Runge-Kutta method on 3 processes.
   If you have many CPU's, you can increase the number 3 to larger numbers.]

8. Execute
     auto_ppp(3,4 | lam=[150,180,200],auto_prefix="abc");
   on the *asir-cmd* window.

   --This test function evaluates outage probability for the case s=3, t=4,
     and lambda = [150,180,200] and store data in the files
     tmp-Hkn-abc-3x4-*
   --Other options to auto_ppp are t0 (starting t=sqrt(x) for HGM), xmax (x max of HGM),
     and err ([abs err,rel err] of the adaptive Runge-Kutta method),

     show_param=1 is for displaying parameters without executing HGM.

     file_max, file_from, file_step to reduce the size of the data file.
      With these options, auto_ppp stores data
      for x=file_from ; x <= file_from+file_max*file_step ; x = x+file_step
   --Example of the option parameter for 5x5 case with large parameter
     in our paper.
     auto_ppp(5,5|show_param=1,
      lam=[2*10^8*(1/5),2*10^8*(2/5),2*10^8*(3/5),2*10^8*(4/5),2*10^8],
      xmax=2*10^8*(13/10),
      t0=1000,   file_step=10^4, file_max=2*10^4, file_from=10^8,
      xmax=2*10^8*(13/10),auto_prefix="large");
   

9. Terminate asir and emacs.

10. gen-ab --s 3 --t 4 --auto_prefix abc >tt.sh
11. sh ./tt.sh
   [It translates the data into asir binary form to make the next steps faster.]

12. emacs a37d2-auto-ppp-file.rr &
13. start asir by the "asir -> start asir" menu.
14. load the current file a37d2-auto-ppp-file.rr to asir
   by the "asir -> execute current buffer on asir" menu.
15. Execute
     setup_auto(3,4|auto_prefix="abc");  [Enter]
   on the *asir-cmd* window.
   [It loads data by the HGM.]
16. Execute
     auto_ppp_from_file(180); [Enter]
   on the *asir-cmd* window to obtain the prob at x=180 from the data in the 
   files tmp-Hkn-abc-3x4-*
17. Execute
     auto_gencsv(3,4,"sample"|auto_prefix="abc",table_fromx=101,table_tox=190); [Enter]
   on the *asir_cmd* window to obtain a csv file of x and the outage probability
   for x in [101,190] with the name sample-3-4.csv
   It also outputs sample-3-4.m, in which f[x] is the outage probability.


-----
If you upgrade non-central-prog by downloading outage-prob-small.tar.gz,
do not forget 
cd non-central-prog ; make install
to upgrade binary files under OX*/OpenXM/bin


=========
Note for developper.
    When non-central/Prog  is upgraded,
    make -f Makefile.dist copy-for-zip
    (cd non-central-prog; make all)
    make -f Makefile.dist build-tar-small
    make -f Makefile.dist copy-web
