~ubuntu-branches/ubuntu/raring/scilab/raring-proposed

« back to all changes in this revision

Viewing changes to modules/fftw/sci_gateway/c/sci_fftw.c

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2012-08-30 14:42:38 UTC
  • mfrom: (1.4.7)
  • Revision ID: package-import@ubuntu.com-20120830144238-c1y2og7dbm7m9nig
Tags: 5.4.0-beta-3-1~exp1
* New upstream release
* Update the scirenderer dep
* Get ride of libjhdf5-java dependency

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3
 
 * Copyright (C) 2006/2007 - INRIA - Alan LAYEC
4
 
 * Copyright (C) 2007 - INRIA - Allan CORNET
5
 
 * Copyright (C) 2012 - DIGITEO - Allan CORNET
6
 
 * Copyright (C) 2012 - INRIA - Serge STEER
7
 
 *
8
 
 * This file must be used under the terms of the CeCILL.
9
 
 * This source file is licensed as described in the file COPYING, which
10
 
 * you should have received as part of this distribution.  The terms
11
 
 * are also available at
12
 
 * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
13
 
 *
14
 
 */
 
2
* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
 
3
* Copyright (C) 2006/2007 - INRIA - Alan LAYEC
 
4
* Copyright (C) 2007 - INRIA - Allan CORNET
 
5
* Copyright (C) 2012 - DIGITEO - Allan CORNET
 
6
* Copyright (C) 2012 - INRIA - Serge STEER
 
7
*
 
8
* This file must be used under the terms of the CeCILL.
 
9
* This source file is licensed as described in the file COPYING, which
 
10
* you should have received as part of this distribution.  The terms
 
11
* are also available at
 
12
* http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
 
13
*
 
14
*/
15
15
/*--------------------------------------------------------------------------*/
16
16
#include "stack-c.h"
17
17
#include "fftw_utilities.h"
39
39
static SciErr getScalarIntArg(void* _pvCtx, int _iVar, char *fname, int *value);
40
40
static SciErr getVectorIntArg(void* _pvCtx, int _iVar, char *fname, int *pndims, int **pDim);
41
41
static BOOL isHyperMatrixMlist(void* _pvCtx, int *piAddressVar);
42
 
static int sci_fft_gen(char *fname, int ndimsA, int *dimsA, double *Ar,  double *Ai, int isn, int iopt, guru_dim_struct gdim);
43
 
static int sci_fft_2args(char *fname, int ndimsA, int *dimsA, double *Ar,  double *Ai, int isn, int iopt);
44
 
static int sci_fft_3args(char *fname, int ndimsA, int *dimsA, double *Ar,  double *Ai, int isn, int iopt);
45
 
static int sci_fft_4args(char *fname, int ndimsA, int *dimsA, double *Ar,  double *Ai, int isn, int iopt);
 
42
static int sci_fft_gen(void* _pvCtx, char *fname, int ndimsA, int *dimsA, double *Ar,  double *Ai, int isn, int iopt, guru_dim_struct gdim);
 
43
static int sci_fft_2args(void* _pvCtx, char *fname, int ndimsA, int *dimsA, double *Ar,  double *Ai, int isn, int iopt);
 
44
static int sci_fft_3args(void* _pvCtx, char *fname, int ndimsA, int *dimsA, double *Ar,  double *Ai, int isn, int iopt);
 
45
static int sci_fft_4args(void* _pvCtx, char *fname, int ndimsA, int *dimsA, double *Ar,  double *Ai, int isn, int iopt);
46
46
/*--------------------------------------------------------------------------*/
47
47
 
48
48
int WITHMKL = 0;
49
49
/* fftw function.
50
 
 *
51
 
 * Scilab Calling sequence :
52
 
 *   fftw(A [,option])
53
 
 *   fftw(A,sign [,option])
54
 
 *   fftw(A,sel,sign [,option])
55
 
 *   fftw(A,sign,dim,incr [,option])
56
 
 *
57
 
 * Input : A : a scilab double complex or real vector, matrix or hypermatrix
58
 
 *
59
 
 *         sign : a scilab double or integer scalar (-1 or 1): the sign
60
 
 *                  in the exponential component
61
 
 *
62
 
 *         sel : a scilab double or integer vector, the selection of dimensions
 
50
*
 
51
* Scilab Calling sequence :
 
52
*   fftw(A [,option])
 
53
*   fftw(A,sign [,option])
 
54
*   fftw(A,sel,sign [,option])
 
55
*   fftw(A,sign,dim,incr [,option])
 
56
*
 
57
* Input : A : a scilab double complex or real vector, matrix or hypermatrix
 
58
*
 
59
*         sign : a scilab double or integer scalar (-1 or 1): the sign
 
60
*                  in the exponential component
 
61
*
 
62
*         sel : a scilab double or integer vector, the selection of dimensions
63
63
 
64
 
 *         dim : a scilab double or integer vector: the dimensions
65
 
 *                  of the Fast Fourier Transform to perform
66
 
 *
67
 
 *         incr : a scilab double or integer vector: the increments
68
 
 *                  of the Fast Fourier Transform to perform
69
 
 *
70
 
 * Output : a scilab double complex or real array with same shape as A that
71
 
 *          gives the result of the transform.
72
 
 *
73
 
 */
 
64
*         dim : a scilab double or integer vector: the dimensions
 
65
*                  of the Fast Fourier Transform to perform
 
66
*
 
67
*         incr : a scilab double or integer vector: the increments
 
68
*                  of the Fast Fourier Transform to perform
 
69
*
 
70
* Output : a scilab double complex or real array with same shape as A that
 
71
*          gives the result of the transform.
 
72
*
 
73
*/
74
74
int sci_fftw(char *fname, unsigned long fname_len)
75
75
{
76
76
    SciErr sciErr;
87
87
    int isn = FFTW_FORWARD;
88
88
    WITHMKL = withMKL();
89
89
    /****************************************
90
 
     * Basic constraints on rhs arguments  *
91
 
     ****************************************/
 
90
    * Basic constraints on rhs arguments  *
 
91
    ****************************************/
92
92
 
93
93
    /* check min/max lhs/rhs arguments of scilab function */
94
94
    CheckRhs(1, 5);
111
111
    }
112
112
 
113
113
    if ((iTypeOne == sci_list) ||
114
 
            (iTypeOne == sci_tlist))
 
114
        (iTypeOne == sci_tlist))
115
115
    {
116
116
        OverLoad(1);
117
117
        return 0;
147
147
                else
148
148
                {
149
149
                    Scierror(999, _("%s: Wrong value for input argument #%d: '%s' or '%s' expected.\n"),
150
 
                             fname, Rhs, "\"symmetric\"", "\"nonsymmetric\"");
 
150
                        fname, Rhs, "\"symmetric\"", "\"nonsymmetric\"");
151
151
                    freeAllocatedSingleString(option);
152
152
                    option = NULL;
153
153
                    return 0;
159
159
            else
160
160
            {
161
161
                Scierror(999, _("%s: Wrong value for input argument #%d: '%s' or '%s' expected.\n"),
162
 
                         fname, Rhs, "\"full\", \"same\"", "\"valid\"");
 
162
                    fname, Rhs, "\"full\", \"same\"", "\"valid\"");
163
163
                return 0;
164
164
            }
165
165
        }
183
183
        if ((isn !=  FFTW_FORWARD) && (isn !=  FFTW_BACKWARD))
184
184
        {
185
185
            Scierror(53, _("%s: Wrong value for input argument #%d: %d or %d expected.\n"),
186
 
                     fname, 2, FFTW_FORWARD, FFTW_BACKWARD);
 
186
                fname, 2, FFTW_FORWARD, FFTW_BACKWARD);
187
187
            return(0);
188
188
        }
189
189
    }
193
193
    if (!getArrayOfDouble(pvApiCtx, piAddr, &ndimsA, &dimsA, &Ar, &Ai))
194
194
    {
195
195
        Scierror(999, _("%s: Wrong type for argument #%d: Array of floating point numbers expected.\n"),
196
 
                 fname, 1);
 
196
            fname, 1);
197
197
        return 0;
198
198
    }
199
199
 
202
202
    if (rhs < 3)
203
203
    {
204
204
        /* fftw(A ,sign [,option])*/
205
 
        sci_fft_2args(fname, ndimsA, dimsA, Ar, Ai, isn, iopt);
 
205
        sci_fft_2args(pvApiCtx, fname, ndimsA, dimsA, Ar, Ai, isn, iopt);
206
206
    }
207
207
    else if (rhs == 3)
208
208
    {
209
209
        /* fftw(A ,sign ,sel [,option])*/
210
 
        sci_fft_3args(fname, ndimsA, dimsA, Ar, Ai, isn, iopt);
 
210
        sci_fft_3args(pvApiCtx, fname, ndimsA, dimsA, Ar, Ai, isn, iopt);
211
211
    }
212
212
    else if (rhs == 4)
213
213
    {
214
214
        /* fftw(A ,sign ,dim,incr [option])*/
215
 
        sci_fft_4args(fname, ndimsA, dimsA, Ar, Ai, isn, iopt);
 
215
        sci_fft_4args(pvApiCtx, fname, ndimsA, dimsA, Ar, Ai, isn, iopt);
216
216
    }
217
217
 
218
218
    return 0;
406
406
 
407
407
        switch (iPrec)
408
408
        {
409
 
            case SCI_INT8 :
 
409
        case SCI_INT8 :
410
410
            {
411
411
                getScalarInteger8(_pvCtx, piAddr, &t_c);
412
412
                *value = (int)t_c;
413
413
            }
414
 
            case SCI_INT16 :
 
414
        case SCI_INT16 :
415
415
            {
416
416
                getScalarInteger16(_pvCtx, piAddr, &t_s);
417
417
                *value = (int)t_s;
418
418
            }
419
 
            case SCI_INT32 :
 
419
        case SCI_INT32 :
420
420
            {
421
421
                getScalarInteger32(_pvCtx, piAddr, &t_i);
422
422
                *value = (int)t_i;
423
423
            }
424
 
            case SCI_UINT8 :
 
424
        case SCI_UINT8 :
425
425
            {
426
426
                getScalarUnsignedInteger8(_pvCtx, piAddr, &t_uc);
427
427
                *value = (int)t_uc;
428
428
            }
429
 
            case SCI_UINT16 :
 
429
        case SCI_UINT16 :
430
430
            {
431
431
                getScalarUnsignedInteger16(_pvCtx, piAddr, &t_us);
432
432
                *value = (int)t_us;
433
433
            }
434
 
            case SCI_UINT32 :
 
434
        case SCI_UINT32 :
435
435
            {
436
436
                getScalarUnsignedInteger32(_pvCtx, piAddr, &t_ui);
437
437
                *value = (int)t_ui;
441
441
    else
442
442
    {
443
443
        addErrorMessage(&sciErr, API_ERROR_GET_INT,
444
 
                        _("%s: Wrong type for argument #%d: An integer or a floating point number expected.\n"),
445
 
                        fname, _iVar);
 
444
            _("%s: Wrong type for argument #%d: An integer or a floating point number expected.\n"),
 
445
            fname, _iVar);
446
446
        return sciErr;
447
447
    }
448
448
    return sciErr;
489
489
    if (ndims <= 0)
490
490
    {
491
491
        addErrorMessage(&sciErr, API_ERROR_GET_INT,
492
 
                        _("%s: Wrong size for input argument #%d.\n"), fname, _iVar);
 
492
            _("%s: Wrong size for input argument #%d.\n"), fname, _iVar);
493
493
        return sciErr;
494
494
    }
495
495
    if ((Dim = (int *)MALLOC(ndims * sizeof(int))) == NULL)
496
496
    {
497
497
        addErrorMessage(&sciErr, API_ERROR_GET_INT,
498
 
                        _("%s: Cannot allocate more memory.\n"), fname);
 
498
            _("%s: Cannot allocate more memory.\n"), fname);
499
499
        return sciErr;
500
500
    }
501
501
    *pDim = Dim;
509
509
        getMatrixOfIntegerPrecision(_pvCtx, piAddr, &iPrec);
510
510
        switch (iPrec)
511
511
        {
512
 
            case SCI_INT8 :
513
 
                getMatrixOfInteger8(_pvCtx, piAddr, &mDim, &nDim, &p_c);
514
 
                for (i = 0; i < ndims; i++) Dim[i]  = (int)(p_c[i]);
515
 
                break;
516
 
            case SCI_INT16 :
517
 
                getMatrixOfInteger16(_pvCtx, piAddr, &mDim, &nDim, &p_s);
518
 
                for (i = 0; i < ndims; i++) Dim[i]  = (int)(p_s[i]);
519
 
                break;
520
 
            case SCI_INT32 :
521
 
                getMatrixOfInteger32(_pvCtx, piAddr, &mDim, &nDim, &p_i);
522
 
                for (i = 0; i < ndims; i++)  Dim[i]  = (int)(p_i[i]);
523
 
                break;
524
 
            case SCI_UINT8 :
525
 
                getMatrixOfUnsignedInteger8(_pvCtx, piAddr, &mDim, &nDim, &p_uc);
526
 
                for (i = 0; i < ndims; i++) Dim[i]  = (int)(p_uc[i]);
527
 
                break;
528
 
            case SCI_UINT16 :
529
 
                getMatrixOfUnsignedInteger16(_pvCtx, piAddr, &mDim, &nDim, &p_us);
530
 
                for (i = 0; i < ndims; i++) Dim[i]  = (int) p_us[i];
531
 
                break;
532
 
            case SCI_UINT32 :
533
 
                getMatrixOfUnsignedInteger32(_pvCtx, piAddr, &mDim, &nDim, &p_ui);
534
 
                for (i = 0; i < ndims; i++) Dim[i]  = (int)(p_ui[i]);
535
 
                break;
 
512
        case SCI_INT8 :
 
513
            getMatrixOfInteger8(_pvCtx, piAddr, &mDim, &nDim, &p_c);
 
514
            for (i = 0; i < ndims; i++) Dim[i]  = (int)(p_c[i]);
 
515
            break;
 
516
        case SCI_INT16 :
 
517
            getMatrixOfInteger16(_pvCtx, piAddr, &mDim, &nDim, &p_s);
 
518
            for (i = 0; i < ndims; i++) Dim[i]  = (int)(p_s[i]);
 
519
            break;
 
520
        case SCI_INT32 :
 
521
            getMatrixOfInteger32(_pvCtx, piAddr, &mDim, &nDim, &p_i);
 
522
            for (i = 0; i < ndims; i++)  Dim[i]  = (int)(p_i[i]);
 
523
            break;
 
524
        case SCI_UINT8 :
 
525
            getMatrixOfUnsignedInteger8(_pvCtx, piAddr, &mDim, &nDim, &p_uc);
 
526
            for (i = 0; i < ndims; i++) Dim[i]  = (int)(p_uc[i]);
 
527
            break;
 
528
        case SCI_UINT16 :
 
529
            getMatrixOfUnsignedInteger16(_pvCtx, piAddr, &mDim, &nDim, &p_us);
 
530
            for (i = 0; i < ndims; i++) Dim[i]  = (int) p_us[i];
 
531
            break;
 
532
        case SCI_UINT32 :
 
533
            getMatrixOfUnsignedInteger32(_pvCtx, piAddr, &mDim, &nDim, &p_ui);
 
534
            for (i = 0; i < ndims; i++) Dim[i]  = (int)(p_ui[i]);
 
535
            break;
536
536
        }
537
537
    }
538
538
    else
540
540
        FREE(Dim);
541
541
        Dim = NULL;
542
542
        addErrorMessage(&sciErr, API_ERROR_GET_INT,
543
 
                        _("%s: Wrong type for argument #%d: An array of floating point or integer numbers expected.\n"), fname, _iVar);
 
543
            _("%s: Wrong type for argument #%d: An array of floating point or integer numbers expected.\n"), fname, _iVar);
544
544
        return sciErr;
545
545
    }
546
546
    return sciErr;
547
547
}
548
548
 
549
 
int sci_fft_2args(char *fname, int ndimsA, int *dimsA, double *Ar,  double *Ai, int isn, int iopt)
 
549
int sci_fft_2args(void* _pvCtx, char *fname, int ndimsA, int *dimsA, double *Ar,  double *Ai, int isn, int iopt)
550
550
{
551
551
    /*FFTW specific library variable */
552
552
    guru_dim_struct gdim = {0, NULL, 0, NULL};
572
572
    /* void or scalar input gives void output or scalar*/
573
573
    if (ndims == 0 )
574
574
    {
575
 
        LhsVar(1) =  1;
576
 
        PutLhsVar();
 
575
        AssignOutputVariable(_pvCtx, 1) =  1;
 
576
        ReturnArguments(_pvCtx);
577
577
        return(0);
578
578
    }
579
579
 
601
601
    gdim.howmany_dims = NULL;
602
602
 
603
603
 
604
 
    if (!sci_fft_gen(fname, ndimsA, dimsA,  Ar,  Ai, isn, iopt, gdim))  goto ERR;
 
604
    if (!sci_fft_gen(_pvCtx, fname, ndimsA, dimsA,  Ar,  Ai, isn, iopt, gdim))  goto ERR;
605
605
 
606
606
 
607
607
    /***********************************
608
 
     * Return results in lhs argument *
609
 
     ***********************************/
 
608
    * Return results in lhs argument *
 
609
    ***********************************/
610
610
 
611
 
    PutLhsVar();
 
611
    ReturnArguments(_pvCtx);
612
612
ERR:
613
613
    FREE(gdim.dims);
614
614
    FREE(gdim.howmany_dims);
616
616
}
617
617
 
618
618
 
619
 
int  sci_fft_3args(char *fname, int ndimsA, int *dimsA, double *Ar,  double *Ai, int isn, int iopt)
 
619
int  sci_fft_3args(void* _pvCtx, char *fname, int ndimsA, int *dimsA, double *Ar,  double *Ai, int isn, int iopt)
620
620
{
621
621
    /* API variables */
622
622
    SciErr sciErr;
650
650
    /* void or scalar input gives void output or scalar*/
651
651
    if (ndims == 0 )
652
652
    {
653
 
        LhsVar(1) =  1;
654
 
        PutLhsVar();
 
653
        AssignOutputVariable(_pvCtx, 1) =  1;
 
654
        ReturnArguments(_pvCtx);
655
655
        return(0);
656
656
    }
657
657
 
783
783
        }
784
784
    }
785
785
 
786
 
    if (!sci_fft_gen(fname, ndimsA, dimsA, Ar,  Ai, isn, iopt, gdim))  goto ERR;
 
786
    if (!sci_fft_gen(_pvCtx, fname, ndimsA, dimsA, Ar,  Ai, isn, iopt, gdim))  goto ERR;
787
787
    /***********************************
788
 
     * Return results in lhs argument *
789
 
     ***********************************/
 
788
    * Return results in lhs argument *
 
789
    ***********************************/
790
790
 
791
 
    PutLhsVar();
 
791
    ReturnArguments(_pvCtx);
792
792
ERR:
793
793
    FREE(gdim.dims);
794
794
    FREE(gdim.howmany_dims);
795
795
    return(0);
796
796
}
797
797
 
798
 
int sci_fft_4args(char *fname, int ndimsA, int *dimsA, double *Ar,  double *Ai, int isn, int iopt)
 
798
int sci_fft_4args(void* _pvCtx, char *fname, int ndimsA, int *dimsA, double *Ar,  double *Ai, int isn, int iopt)
799
799
{
800
800
    /* API variables */
801
801
    SciErr sciErr;
827
827
    /* void or scalar input gives void output or scalar*/
828
828
    if (lA <= 1 )
829
829
    {
830
 
        LhsVar(1) =  1;
831
 
        PutLhsVar();
 
830
        AssignOutputVariable(_pvCtx, 1) =  1;
 
831
        ReturnArguments(_pvCtx);
832
832
        return(0);
833
833
    }
834
834
 
1041
1041
            ih++;
1042
1042
        }
1043
1043
    }
1044
 
    if (!sci_fft_gen(fname, ndimsA, dimsA, Ar,  Ai, isn, iopt, gdim))  goto ERR;
 
1044
    if (!sci_fft_gen(_pvCtx, fname, ndimsA, dimsA, Ar,  Ai, isn, iopt, gdim))  goto ERR;
1045
1045
 
1046
1046
    /***********************************
1047
 
     * Return results in lhs argument *
1048
 
     ***********************************/
 
1047
    * Return results in lhs argument *
 
1048
    ***********************************/
1049
1049
 
1050
 
    PutLhsVar();
 
1050
    ReturnArguments(_pvCtx);
1051
1051
ERR:
1052
1052
    FREE(Dim1);
1053
1053
    FREE(Incr);
1118
1118
    return FALSE;
1119
1119
}
1120
1120
/*--------------------------------------------------------------------------*/
1121
 
int sci_fft_gen(char *fname, int ndimsA, int *dimsA, double *Ar,  double *Ai, int isn, int iopt, guru_dim_struct gdim)
 
1121
int sci_fft_gen(void* _pvCtx, char *fname, int ndimsA, int *dimsA, double *Ar,  double *Ai, int isn, int iopt, guru_dim_struct gdim)
1122
1122
{
1123
1123
    /* API variables */
1124
1124
    SciErr sciErr;
1167
1167
    {
1168
1168
        issymA = 0;
1169
1169
    }
1170
 
    LhsVar(1) = 1; /* assume inplace transform*/
 
1170
 
 
1171
    AssignOutputVariable(_pvCtx, 1) =  1;/* assume inplace transform*/
1171
1172
 
1172
1173
    if (WITHMKL)
1173
1174
    {
1178
1179
            if (issymA)
1179
1180
            {
1180
1181
                /* result will be real, the imaginary part of A can be allocated alone */
1181
 
                sciErr = allocMatrixOfDouble(pvApiCtx, Rhs + 1, 1, lA, &Ai);
 
1182
                sciErr = allocMatrixOfDouble(pvApiCtx, *getNbInputArgument(_pvCtx) + 1, 1, lA, &Ai);
1182
1183
                if (sciErr.iErr)
1183
1184
                {
1184
1185
                    Scierror(999, _("%s: Cannot allocate more memory.\n"), fname);
1189
1190
            else
1190
1191
            {
1191
1192
                /* result will be complex, realloc A for inplace computation */
1192
 
                sciErr = allocComplexArrayOfDouble(pvApiCtx, Rhs + 1, ndimsA, dimsA, &ri, &Ai);
 
1193
                sciErr = allocComplexArrayOfDouble(pvApiCtx, *getNbInputArgument(_pvCtx) + 1, ndimsA, dimsA, &ri, &Ai);
1193
1194
                if (sciErr.iErr)
1194
1195
                {
1195
1196
                    Scierror(999, _("%s: Cannot allocate more memory.\n"), fname);
1198
1199
                C2F(dcopy)(&lA, Ar, &one, ri, &one);
1199
1200
                Ar = ri;
1200
1201
                C2F(dset)(&lA, &dzero, Ai, &one);
1201
 
                LhsVar(1) = Rhs + 1;
 
1202
                AssignOutputVariable(_pvCtx, 1) =  nbInputArgument(_pvCtx) + 1;
1202
1203
                isrealA = 0;
1203
1204
            }
1204
1205
        }
1207
1208
    if (!isrealA && issymA) /* A is complex but result is real */
1208
1209
    {
1209
1210
        /* result will be complex, realloc real part of A for real part inplace computation */
1210
 
        sciErr = allocArrayOfDouble(pvApiCtx, Rhs + 1, ndimsA, dimsA, &ri);
 
1211
        sciErr = allocArrayOfDouble(pvApiCtx, *getNbInputArgument(_pvCtx) + 1, ndimsA, dimsA, &ri);
1211
1212
        if (sciErr.iErr)
1212
1213
        {
1213
1214
            Scierror(999, _("%s: Cannot allocate more memory.\n"), fname);
1215
1216
        }
1216
1217
        C2F(dcopy)(&lA, Ar, &one, ri, &one);
1217
1218
        Ar = ri;
1218
 
        LhsVar(1) = Rhs + 1;
 
1219
        AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(_pvCtx) + 1;
1219
1220
    }
1220
1221
 
1221
1222
    /* Set pointers on real and imaginary part of the input */
1224
1225
 
1225
1226
    scale = None; /*no scaling needed */
1226
1227
    if (isn == FFTW_BACKWARD) scale = Divide;
1227
 
    if (isrealA)
 
1228
    if (isrealA & !WITHMKL) /* To have type = C2C_PLAN*/
1228
1229
    {
1229
1230
        /*A is real */
1230
1231
        if (issymA)
1231
1232
        {
1232
1233
            /*r2r =  isrealA &&  issymA*/
1233
1234
            /* there is no general plan able to compute r2r transform so it is tranformed into
1234
 
               a R2c plan. The computed imaginary part will be zero*/
1235
 
            sciErr = allocMatrixOfDouble(pvApiCtx, Rhs + 1, 1, lA,  &io);
 
1235
            a R2c plan. The computed imaginary part will be zero*/
 
1236
            sciErr = allocMatrixOfDouble(pvApiCtx, *getNbInputArgument(_pvCtx) + 1, 1, lA,  &io);
1236
1237
            if (sciErr.iErr)
1237
1238
            {
1238
1239
                Scierror(999, _("%s: Cannot allocate more memory.\n"), fname);
1245
1246
        {
1246
1247
            /*r2c =  isrealA && ~issymA;*/
1247
1248
            /* transform cannot be done in place */
1248
 
            sciErr = allocComplexArrayOfDouble(pvApiCtx, Rhs + 1, ndimsA, dimsA, &ro, &io);
 
1249
            sciErr = allocComplexArrayOfDouble(pvApiCtx, *getNbInputArgument(_pvCtx) + 1, ndimsA, dimsA, &ro, &io);
1249
1250
            if (sciErr.iErr)
1250
1251
            {
1251
1252
                Scierror(999, _("%s: Cannot allocate more memory.\n"), fname);
1252
1253
                goto ERR;
1253
1254
            }
1254
 
            LhsVar(1) = Rhs + 1;
 
1255
            AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(_pvCtx) + 1;
1255
1256
            type = R2C_PLAN; /* fftw_plan_guru_split_dft_r2c plans for an FFTW_FORWARD transform*/
1256
1257
            if (isn == FFTW_BACKWARD)
1257
1258
            {
1283
1284
        {
1284
1285
            /*c2c =  ~isrealA && ~issymA;*/
1285
1286
            /* use inplace transform*/
 
1287
            isrealA = 0;
1286
1288
            type = C2C_PLAN; /*  fftw_plan_guru_split_dft plans for an FFTW_FORWARD transform*/
1287
1289
            if (isn == FFTW_BACKWARD)
1288
1290
            {
1323
1325
    /* Post treatment */
1324
1326
    switch (type)
1325
1327
    {
1326
 
        case R2R_PLAN:
 
1328
    case R2R_PLAN:
 
1329
        if (complete_array(ro, NULL, gdim) == -1)
 
1330
        {
 
1331
            Scierror(999, _("%s: Cannot allocate more memory.\n"), fname);
 
1332
            goto ERR;
 
1333
        }
 
1334
        break;
 
1335
    case C2R_PLAN:
 
1336
        break;
 
1337
    case R2C_PLAN:
 
1338
        if (issymA)
 
1339
        {
 
1340
            /*R2C has been used to solve an r2r problem*/
1327
1341
            if (complete_array(ro, NULL, gdim) == -1)
1328
1342
            {
1329
1343
                Scierror(999, _("%s: Cannot allocate more memory.\n"), fname);
1330
1344
                goto ERR;
1331
1345
            }
1332
 
            break;
1333
 
        case C2R_PLAN:
1334
 
            break;
1335
 
        case R2C_PLAN:
1336
 
            if (issymA)
1337
 
            {
1338
 
                /*R2C has been used to solve an r2r problem*/
1339
 
                if (complete_array(ro, NULL, gdim) == -1)
1340
 
                {
1341
 
                    Scierror(999, _("%s: Cannot allocate more memory.\n"), fname);
1342
 
                    goto ERR;
1343
 
                }
1344
 
            }
1345
 
            else
 
1346
        }
 
1347
        else
 
1348
        {
 
1349
            if (complete_array(ro, io, gdim) == -1)
 
1350
            {
 
1351
                Scierror(999, _("%s: Cannot allocate more memory.\n"), fname);
 
1352
                goto ERR;
 
1353
            }
 
1354
            if (isn == FFTW_BACKWARD)
 
1355
            {
 
1356
                /*conjugate result */
 
1357
                double ak = -1.0;
 
1358
                C2F(dscal)(&lA, &ak, io, &one);
 
1359
            }
 
1360
        }
 
1361
        break;
 
1362
    case C2C_PLAN:
 
1363
        if (WITHMKL && isrealA_save)
 
1364
        {
 
1365
            if (isn == FFTW_FORWARD)
1346
1366
            {
1347
1367
                if (complete_array(ro, io, gdim) == -1)
1348
1368
                {
1349
1369
                    Scierror(999, _("%s: Cannot allocate more memory.\n"), fname);
1350
1370
                    goto ERR;
1351
1371
                }
1352
 
                if (isn == FFTW_BACKWARD)
1353
 
                {
1354
 
                    /*conjugate result */
1355
 
                    double ak = -1.0;
1356
 
                    C2F(dscal)(&lA, &ak, io, &one);
1357
 
                }
1358
1372
            }
1359
 
            break;
1360
 
        case C2C_PLAN:
1361
 
            if (WITHMKL && isrealA_save)
 
1373
            else
1362
1374
            {
1363
 
                if (isn == FFTW_FORWARD)
1364
 
                {
1365
 
                    if (complete_array(ro, io, gdim) == -1)
1366
 
                    {
1367
 
                        Scierror(999, _("%s: Cannot allocate more memory.\n"), fname);
1368
 
                        goto ERR;
1369
 
                    }
1370
 
                }
1371
 
                else
1372
 
                {
1373
 
                    if (complete_array(io, ro, gdim) == -1)
1374
 
                    {
1375
 
                        Scierror(999, _("%s: Cannot allocate more memory.\n"), fname);
1376
 
                        goto ERR;
1377
 
                    }
 
1375
                if (complete_array(io, ro, gdim) == -1)
 
1376
                {
 
1377
                    Scierror(999, _("%s: Cannot allocate more memory.\n"), fname);
 
1378
                    goto ERR;
1378
1379
                }
1379
1380
            }
1380
 
            break;
 
1381
        }
 
1382
        break;
1381
1383
    }
1382
1384
 
1383
1385
    return(1);