#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "gmp.h"



int main
(
   int   iArgs    ,
   char *apsArgs[]
)
{
    int   i = 0;
    char *pcArgI = NULL;
    char *pcArgR = NULL;
    char *pcArgW = NULL;
    char *pcArgH = NULL;
    char *pcArgX = NULL;
    char *pcArgY = NULL;
    long  lN     = 0L;
    long  lR     = 0L;
    long  lW     = 0L;
    long  lH     = 0L;
    long  lX     = 0L;
    long  lY     = 0L;
    long  lPx    = 0L;
    long  lPixels= 0L;


    mpz_t mTC;
    mpz_t mValue;
    mpz_t mPerm;
    mpz_t mN;
    mpz_t mR;
    mpz_t mP;
    mpz_t mTCD;
    mpz_t mDivisor;
    mpz_t mUnit;
    mpz_t mX;
    mpz_t mY;

    printf ("-i=image\n");

    for (i = 0; i < iArgs; i++)
    {
       if (0 == strncmp ("-i=", apsArgs[i], 3))         // -i
       {
          pcArgI = apsArgs[i] + 3;
       }

    }

   //

   lPixels = lW * lH;

   //printf ("pcArgN=[%s] lN=%ld\n", pcArgN, lN);
   //printf ("pcArgR=[%s] lR=%ld\n", pcArgR, lR);
   printf ("lW=%ld lH=%ld lPixels=%ld\n", lW, lH, lPixels);

   // permutation  (order important, repetition allowed)          = n^r
   // permutation  (order NOT important, repetition allowed)      = (n+r-1)!/r!(n-1)!
   // permutation  (order NOT important, repetition NOT allowed)  = n!/(n-r)!(r!)      (NOTE: n > r)
   // permutation  (order important, repetition NOT allowed)      = n!/(n-r)!          (NOTE: n > r)

   // n = the number in the set. ie colors
   // r = the number to choose. ie width*height

   mpz_init (mPerm);
   mpz_init (mN);
   mpz_init (mR);

   mpz_set_ui (mPerm, 0);
   mpz_set_ui (mN   , lN);
   mpz_set_ui (mR   , lR);
  // gmp_printf ("lNa=%Zd\n", lNa);
  // gmp_printf ("lNb=%Zd\n", lNb);
  // gmp_printf ("lRa=%Zd\n", lRa);


   mpz_pow_ui (mPerm, mN, lR);
   gmp_printf ("mN (Colours) = %Zd\n", mN);
   gmp_printf ("lR (Pixels)  = %ld\n", lR);
   gmp_printf ("Permutations = %Zd\n", mPerm);

   // Work out the range of 1 unit in the X axis of a graph.
   // e.g If set the divisor to 100 this would return the number of keys in 1 percent.

   mpz_init   (mUnit);
   mpz_fdiv_q (mUnit, mPerm, mX);
   gmp_printf ("X Axis:\nmX=%Zd\nmUnit=%Zd\n\n", mX, mUnit);

   // Work out the range of 1 unit in the Y (which is a fraction of the X unit)

   mpz_fdiv_q (mUnit, mUnit, mY);

   gmp_printf ("Y Axis:\nmY=%Zd\nmUnit=%Zd\n\n", mY, mUnit);

   mpz_clear (mX);
   mpz_clear (mY);
   mpz_clear (mUnit);

   return (0);
}
