/*
 * point_recovery.c
 *
 *  Created on: Feb 14, 2014
 *      Author: havock
 */
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <iterative_point_recovery.clh>

int32_t main(void) {
    flt32_t pCenters[6]={ -0.976f,  0.401f,        /* the first  centre */
                          -0.251f, -0.506f,        /* the second centre */
                           0.368f,  0.327f },      /* the third  centre */
            pRadiuses[3]={ 0.98f, 0.653f, 0.816f },/* radiuses */
            pResult[2]={ 0.0f, 0.0f },             /* result  */
            Quality=0.0;                           /* quality */
    const _PTRC_INDAT in={
        .u64D=2ul,                                 /* dimensionality */
        .pfCnt=pCenters, .pfRds=pRadiuses,
        .u64NofS=3ul                            /* number of known spheres */ };
    int32_t err=0;                                 /* error */
    {
        uint64_t i,j;
        printf("At the beginning were\n");
        for(i=0ul;i<in.u64NofS;i++) {
            printf("\tc%lu={ ",i);
            for(j=0ul;j<in.u64D;j++) printf("%f ",in.pfCnt[i*in.u64D+j]);
            printf("}\n");
        }
        printf("\tR={ ");
        for(i=0ul;i<in.u64NofS;i++) printf("%f ",in.pfRds[i]);
        printf("}\n");
    }
    err=_ptrc_recoverPoint(pResult,&Quality,in,in.u64NofS); /* function call */
    if(!err) {
        uint64_t i;
        printf("and the result is\n\tp={ ");
        for(i=0ul;i<in.u64D;i++) printf("%f ",pResult[i]);
        printf("}; Lambda = %f\n",Quality);
    } else printf("Error %d\n",err);
    return(0);
}
