-
Notifications
You must be signed in to change notification settings - Fork 0
/
hw2mod2module.c
1195 lines (1105 loc) · 38 KB
/
hw2mod2module.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* File: hw2mod2module.c
* This file is auto-generated with f2py (version:2).
* f2py is a Fortran to Python Interface Generator (FPIG), Second Edition,
* written by Pearu Peterson <pearu@cens.ioc.ee>.
* See http://cens.ioc.ee/projects/f2py2e/
* Generation date: Mon Nov 13 19:25:24 2017
* $Revision:$
* $Date:$
* Do not edit this file directly unless you know what you are doing!!!
*/
#ifdef __cplusplus
extern "C" {
#endif
/*********************** See f2py2e/cfuncs.py: includes ***********************/
#include "Python.h"
#include <stdarg.h>
#include "fortranobject.h"
#include <math.h>
/**************** See f2py2e/rules.py: mod_rules['modulebody'] ****************/
static PyObject *hw2mod2_error;
static PyObject *hw2mod2_module;
/*********************** See f2py2e/cfuncs.py: typedefs ***********************/
/*need_typedefs*/
/****************** See f2py2e/cfuncs.py: typedefs_generated ******************/
/*need_typedefs_generated*/
/********************** See f2py2e/cfuncs.py: cppmacros **********************/
#define PRINTPYOBJERR(obj)\
fprintf(stderr,"hw2mod2.error is related to ");\
PyObject_Print((PyObject *)obj,stderr,Py_PRINT_RAW);\
fprintf(stderr,"\n");
#define pyobj_from_double1(v) (PyFloat_FromDouble(v))
#define rank(var) var ## _Rank
#define shape(var,dim) var ## _Dims[dim]
#define old_rank(var) (((PyArrayObject *)(capi_ ## var ## _tmp))->nd)
#define old_shape(var,dim) (((PyArrayObject *)(capi_ ## var ## _tmp))->dimensions[dim])
#define fshape(var,dim) shape(var,rank(var)-dim-1)
#define len(var) shape(var,0)
#define flen(var) fshape(var,0)
#define old_size(var) PyArray_SIZE((PyArrayObject *)(capi_ ## var ## _tmp))
/* #define index(i) capi_i ## i */
#define slen(var) capi_ ## var ## _len
#define size(var, ...) f2py_size((PyArrayObject *)(capi_ ## var ## _tmp), ## __VA_ARGS__, -1)
#ifdef DEBUGCFUNCS
#define CFUNCSMESS(mess) fprintf(stderr,"debug-capi:"mess);
#define CFUNCSMESSPY(mess,obj) CFUNCSMESS(mess) \
PyObject_Print((PyObject *)obj,stderr,Py_PRINT_RAW);\
fprintf(stderr,"\n");
#else
#define CFUNCSMESS(mess)
#define CFUNCSMESSPY(mess,obj)
#endif
#ifndef max
#define max(a,b) ((a > b) ? (a) : (b))
#endif
#ifndef min
#define min(a,b) ((a < b) ? (a) : (b))
#endif
#ifndef MAX
#define MAX(a,b) ((a > b) ? (a) : (b))
#endif
#ifndef MIN
#define MIN(a,b) ((a < b) ? (a) : (b))
#endif
#if defined(PREPEND_FORTRAN)
#if defined(NO_APPEND_FORTRAN)
#if defined(UPPERCASE_FORTRAN)
#define F_FUNC(f,F) _##F
#else
#define F_FUNC(f,F) _##f
#endif
#else
#if defined(UPPERCASE_FORTRAN)
#define F_FUNC(f,F) _##F##_
#else
#define F_FUNC(f,F) _##f##_
#endif
#endif
#else
#if defined(NO_APPEND_FORTRAN)
#if defined(UPPERCASE_FORTRAN)
#define F_FUNC(f,F) F
#else
#define F_FUNC(f,F) f
#endif
#else
#if defined(UPPERCASE_FORTRAN)
#define F_FUNC(f,F) F##_
#else
#define F_FUNC(f,F) f##_
#endif
#endif
#endif
#if defined(UNDERSCORE_G77)
#define F_FUNC_US(f,F) F_FUNC(f##_,F##_)
#else
#define F_FUNC_US(f,F) F_FUNC(f,F)
#endif
/* New SciPy */
#define TRYPYARRAYTEMPLATECHAR case NPY_STRING: *(char *)(arr->data)=*v; break;
#define TRYPYARRAYTEMPLATELONG case NPY_LONG: *(long *)(arr->data)=*v; break;
#define TRYPYARRAYTEMPLATEOBJECT case NPY_OBJECT: (arr->descr->f->setitem)(pyobj_from_ ## ctype ## 1(*v),arr->data); break;
#define TRYPYARRAYTEMPLATE(ctype,typecode) \
PyArrayObject *arr = NULL;\
if (!obj) return -2;\
if (!PyArray_Check(obj)) return -1;\
if (!(arr=(PyArrayObject *)obj)) {fprintf(stderr,"TRYPYARRAYTEMPLATE:");PRINTPYOBJERR(obj);return 0;}\
if (arr->descr->type==typecode) {*(ctype *)(arr->data)=*v; return 1;}\
switch (arr->descr->type_num) {\
case NPY_DOUBLE: *(double *)(arr->data)=*v; break;\
case NPY_INT: *(int *)(arr->data)=*v; break;\
case NPY_LONG: *(long *)(arr->data)=*v; break;\
case NPY_FLOAT: *(float *)(arr->data)=*v; break;\
case NPY_CDOUBLE: *(double *)(arr->data)=*v; break;\
case NPY_CFLOAT: *(float *)(arr->data)=*v; break;\
case NPY_BOOL: *(npy_bool *)(arr->data)=(*v!=0); break;\
case NPY_UBYTE: *(unsigned char *)(arr->data)=*v; break;\
case NPY_BYTE: *(signed char *)(arr->data)=*v; break;\
case NPY_SHORT: *(short *)(arr->data)=*v; break;\
case NPY_USHORT: *(npy_ushort *)(arr->data)=*v; break;\
case NPY_UINT: *(npy_uint *)(arr->data)=*v; break;\
case NPY_ULONG: *(npy_ulong *)(arr->data)=*v; break;\
case NPY_LONGLONG: *(npy_longlong *)(arr->data)=*v; break;\
case NPY_ULONGLONG: *(npy_ulonglong *)(arr->data)=*v; break;\
case NPY_LONGDOUBLE: *(npy_longdouble *)(arr->data)=*v; break;\
case NPY_CLONGDOUBLE: *(npy_longdouble *)(arr->data)=*v; break;\
case NPY_OBJECT: (arr->descr->f->setitem)(pyobj_from_ ## ctype ## 1(*v),arr->data, arr); break;\
default: return -2;\
};\
return 1
/************************ See f2py2e/cfuncs.py: cfuncs ************************/
static int f2py_size(PyArrayObject* var, ...)
{
npy_int sz = 0;
npy_int dim;
npy_int rank;
va_list argp;
va_start(argp, var);
dim = va_arg(argp, npy_int);
if (dim==-1)
{
sz = PyArray_SIZE(var);
}
else
{
rank = PyArray_NDIM(var);
if (dim>=1 && dim<=rank)
sz = PyArray_DIM(var, dim-1);
else
fprintf(stderr, "f2py_size: 2nd argument value=%d fails to satisfy 1<=value<=%d. Result will be 0.\n", dim, rank);
}
va_end(argp);
return sz;
}
static int try_pyarr_from_double(PyObject* obj,double* v) {
TRYPYARRAYTEMPLATE(double,'d');
}
static int double_from_pyobj(double* v,PyObject *obj,const char *errmess) {
PyObject* tmp = NULL;
if (PyFloat_Check(obj)) {
#ifdef __sgi
*v = PyFloat_AsDouble(obj);
#else
*v = PyFloat_AS_DOUBLE(obj);
#endif
return 1;
}
tmp = PyNumber_Float(obj);
if (tmp) {
#ifdef __sgi
*v = PyFloat_AsDouble(tmp);
#else
*v = PyFloat_AS_DOUBLE(tmp);
#endif
Py_DECREF(tmp);
return 1;
}
if (PyComplex_Check(obj))
tmp = PyObject_GetAttrString(obj,"real");
else if (PyString_Check(obj) || PyUnicode_Check(obj))
/*pass*/;
else if (PySequence_Check(obj))
tmp = PySequence_GetItem(obj,0);
if (tmp) {
PyErr_Clear();
if (double_from_pyobj(v,tmp,errmess)) {Py_DECREF(tmp); return 1;}
Py_DECREF(tmp);
}
{
PyObject* err = PyErr_Occurred();
if (err==NULL) err = hw2mod2_error;
PyErr_SetString(err,errmess);
}
return 0;
}
/********************* See f2py2e/cfuncs.py: userincludes *********************/
/*need_userincludes*/
/********************* See f2py2e/capi_rules.py: usercode *********************/
/* See f2py2e/rules.py */
/*eof externroutines*/
/******************** See f2py2e/capi_rules.py: usercode1 ********************/
/******************* See f2py2e/cb_rules.py: buildcallback *******************/
/*need_callbacks*/
/*********************** See f2py2e/rules.py: buildapi ***********************/
/*********************************** costj ***********************************/
static char doc_f2py_rout_hw2mod2_cost_costj[] = "\
j = costj(x)\n\nWrapper for ``costj``.\
\n\nParameters\n----------\n"
"x : input rank-1 array('d') with bounds (f2py_x_d0)\n"
"\nReturns\n-------\n"
"j : float";
/* #declfortranroutine# */
static PyObject *f2py_rout_hw2mod2_cost_costj(const PyObject *capi_self,
PyObject *capi_args,
PyObject *capi_keywds,
void (*f2py_func)(double*,double*,int*)) {
PyObject * volatile capi_buildvalue = NULL;
volatile int f2py_success = 1;
/*decl*/
double *x = NULL;
npy_intp x_Dims[1] = {-1};
const int x_Rank = 1;
PyArrayObject *capi_x_tmp = NULL;
int capi_x_intent = 0;
PyObject *x_capi = Py_None;
double j = 0;
int f2py_x_d0 = 0;
static char *capi_kwlist[] = {"x",NULL};
/*routdebugenter*/
#ifdef F2PY_REPORT_ATEXIT
f2py_start_clock();
#endif
if (!PyArg_ParseTupleAndKeywords(capi_args,capi_keywds,\
"O:hw2mod2.cost.costj",\
capi_kwlist,&x_capi))
return NULL;
/*frompyobj*/
/* Processing variable x */
;
capi_x_intent |= F2PY_INTENT_IN;
capi_x_tmp = array_from_pyobj(NPY_DOUBLE,x_Dims,x_Rank,capi_x_intent,x_capi);
if (capi_x_tmp == NULL) {
if (!PyErr_Occurred())
PyErr_SetString(hw2mod2_error,"failed in converting 1st argument `x' of hw2mod2.cost.costj to C/Fortran array" );
} else {
x = (double *)(capi_x_tmp->data);
/* Processing variable j */
/* Processing variable f2py_x_d0 */
f2py_x_d0 = shape(x, 0);
/*end of frompyobj*/
#ifdef F2PY_REPORT_ATEXIT
f2py_start_call_clock();
#endif
/*callfortranroutine*/
(*f2py_func)(x,&j,&f2py_x_d0);
if (PyErr_Occurred())
f2py_success = 0;
#ifdef F2PY_REPORT_ATEXIT
f2py_stop_call_clock();
#endif
/*end of callfortranroutine*/
if (f2py_success) {
/*pyobjfrom*/
/*end of pyobjfrom*/
CFUNCSMESS("Building return value.\n");
capi_buildvalue = Py_BuildValue("d",j);
/*closepyobjfrom*/
/*end of closepyobjfrom*/
} /*if (f2py_success) after callfortranroutine*/
/*cleanupfrompyobj*/
/* End of cleaning variable f2py_x_d0 */
/* End of cleaning variable j */
if((PyObject *)capi_x_tmp!=x_capi) {
Py_XDECREF(capi_x_tmp); }
} /*if (capi_x_tmp == NULL) ... else of x*/
/* End of cleaning variable x */
/*end of cleanupfrompyobj*/
if (capi_buildvalue == NULL) {
/*routdebugfailure*/
} else {
/*routdebugleave*/
}
CFUNCSMESS("Freeing memory.\n");
/*freemem*/
#ifdef F2PY_REPORT_ATEXIT
f2py_stop_clock();
#endif
return capi_buildvalue;
}
/******************************** end of costj ********************************/
/******************************** costj_grad2d ********************************/
static char doc_f2py_rout_hw2mod2_cost_costj_grad2d[] = "\
j_grad = costj_grad2d(x)\n\nWrapper for ``costj_grad2d``.\
\n\nParameters\n----------\n"
"x : input rank-1 array('d') with bounds (f2py_x_d0)\n"
"\nReturns\n-------\n"
"j_grad : rank-1 array('d') with bounds (size(x))";
/* #declfortranroutine# */
static PyObject *f2py_rout_hw2mod2_cost_costj_grad2d(const PyObject *capi_self,
PyObject *capi_args,
PyObject *capi_keywds,
void (*f2py_func)(double*,double*,int*)) {
PyObject * volatile capi_buildvalue = NULL;
volatile int f2py_success = 1;
/*decl*/
double *x = NULL;
npy_intp x_Dims[1] = {-1};
const int x_Rank = 1;
PyArrayObject *capi_x_tmp = NULL;
int capi_x_intent = 0;
PyObject *x_capi = Py_None;
double *j_grad = NULL;
npy_intp j_grad_Dims[1] = {-1};
const int j_grad_Rank = 1;
PyArrayObject *capi_j_grad_tmp = NULL;
int capi_j_grad_intent = 0;
int f2py_x_d0 = 0;
static char *capi_kwlist[] = {"x",NULL};
/*routdebugenter*/
#ifdef F2PY_REPORT_ATEXIT
f2py_start_clock();
#endif
if (!PyArg_ParseTupleAndKeywords(capi_args,capi_keywds,\
"O:hw2mod2.cost.costj_grad2d",\
capi_kwlist,&x_capi))
return NULL;
/*frompyobj*/
/* Processing variable x */
;
capi_x_intent |= F2PY_INTENT_IN;
capi_x_tmp = array_from_pyobj(NPY_DOUBLE,x_Dims,x_Rank,capi_x_intent,x_capi);
if (capi_x_tmp == NULL) {
if (!PyErr_Occurred())
PyErr_SetString(hw2mod2_error,"failed in converting 1st argument `x' of hw2mod2.cost.costj_grad2d to C/Fortran array" );
} else {
x = (double *)(capi_x_tmp->data);
/* Processing variable j_grad */
j_grad_Dims[0]=size(x);
capi_j_grad_intent |= F2PY_INTENT_OUT|F2PY_INTENT_HIDE;
capi_j_grad_tmp = array_from_pyobj(NPY_DOUBLE,j_grad_Dims,j_grad_Rank,capi_j_grad_intent,Py_None);
if (capi_j_grad_tmp == NULL) {
if (!PyErr_Occurred())
PyErr_SetString(hw2mod2_error,"failed in converting hidden `j_grad' of hw2mod2.cost.costj_grad2d to C/Fortran array" );
} else {
j_grad = (double *)(capi_j_grad_tmp->data);
/* Processing variable f2py_x_d0 */
f2py_x_d0 = shape(x, 0);
/*end of frompyobj*/
#ifdef F2PY_REPORT_ATEXIT
f2py_start_call_clock();
#endif
/*callfortranroutine*/
(*f2py_func)(x,j_grad,&f2py_x_d0);
if (PyErr_Occurred())
f2py_success = 0;
#ifdef F2PY_REPORT_ATEXIT
f2py_stop_call_clock();
#endif
/*end of callfortranroutine*/
if (f2py_success) {
/*pyobjfrom*/
/*end of pyobjfrom*/
CFUNCSMESS("Building return value.\n");
capi_buildvalue = Py_BuildValue("N",capi_j_grad_tmp);
/*closepyobjfrom*/
/*end of closepyobjfrom*/
} /*if (f2py_success) after callfortranroutine*/
/*cleanupfrompyobj*/
/* End of cleaning variable f2py_x_d0 */
} /*if (capi_j_grad_tmp == NULL) ... else of j_grad*/
/* End of cleaning variable j_grad */
if((PyObject *)capi_x_tmp!=x_capi) {
Py_XDECREF(capi_x_tmp); }
} /*if (capi_x_tmp == NULL) ... else of x*/
/* End of cleaning variable x */
/*end of cleanupfrompyobj*/
if (capi_buildvalue == NULL) {
/*routdebugfailure*/
} else {
/*routdebugleave*/
}
CFUNCSMESS("Freeing memory.\n");
/*freemem*/
#ifdef F2PY_REPORT_ATEXIT
f2py_stop_clock();
#endif
return capi_buildvalue;
}
/**************************** end of costj_grad2d ****************************/
/******************************** costj_hess2d ********************************/
static char doc_f2py_rout_hw2mod2_cost_costj_hess2d[] = "\
j_hess = costj_hess2d(x)\n\nWrapper for ``costj_hess2d``.\
\n\nParameters\n----------\n"
"x : input rank-1 array('d') with bounds (f2py_x_d0)\n"
"\nReturns\n-------\n"
"j_hess : rank-2 array('d') with bounds (size(x),size(x))";
/* #declfortranroutine# */
static PyObject *f2py_rout_hw2mod2_cost_costj_hess2d(const PyObject *capi_self,
PyObject *capi_args,
PyObject *capi_keywds,
void (*f2py_func)(double*,double*,int*)) {
PyObject * volatile capi_buildvalue = NULL;
volatile int f2py_success = 1;
/*decl*/
double *x = NULL;
npy_intp x_Dims[1] = {-1};
const int x_Rank = 1;
PyArrayObject *capi_x_tmp = NULL;
int capi_x_intent = 0;
PyObject *x_capi = Py_None;
double *j_hess = NULL;
npy_intp j_hess_Dims[2] = {-1, -1};
const int j_hess_Rank = 2;
PyArrayObject *capi_j_hess_tmp = NULL;
int capi_j_hess_intent = 0;
int f2py_x_d0 = 0;
static char *capi_kwlist[] = {"x",NULL};
/*routdebugenter*/
#ifdef F2PY_REPORT_ATEXIT
f2py_start_clock();
#endif
if (!PyArg_ParseTupleAndKeywords(capi_args,capi_keywds,\
"O:hw2mod2.cost.costj_hess2d",\
capi_kwlist,&x_capi))
return NULL;
/*frompyobj*/
/* Processing variable x */
;
capi_x_intent |= F2PY_INTENT_IN;
capi_x_tmp = array_from_pyobj(NPY_DOUBLE,x_Dims,x_Rank,capi_x_intent,x_capi);
if (capi_x_tmp == NULL) {
if (!PyErr_Occurred())
PyErr_SetString(hw2mod2_error,"failed in converting 1st argument `x' of hw2mod2.cost.costj_hess2d to C/Fortran array" );
} else {
x = (double *)(capi_x_tmp->data);
/* Processing variable j_hess */
j_hess_Dims[0]=size(x),j_hess_Dims[1]=size(x);
capi_j_hess_intent |= F2PY_INTENT_OUT|F2PY_INTENT_HIDE;
capi_j_hess_tmp = array_from_pyobj(NPY_DOUBLE,j_hess_Dims,j_hess_Rank,capi_j_hess_intent,Py_None);
if (capi_j_hess_tmp == NULL) {
if (!PyErr_Occurred())
PyErr_SetString(hw2mod2_error,"failed in converting hidden `j_hess' of hw2mod2.cost.costj_hess2d to C/Fortran array" );
} else {
j_hess = (double *)(capi_j_hess_tmp->data);
/* Processing variable f2py_x_d0 */
f2py_x_d0 = shape(x, 0);
/*end of frompyobj*/
#ifdef F2PY_REPORT_ATEXIT
f2py_start_call_clock();
#endif
/*callfortranroutine*/
(*f2py_func)(x,j_hess,&f2py_x_d0);
if (PyErr_Occurred())
f2py_success = 0;
#ifdef F2PY_REPORT_ATEXIT
f2py_stop_call_clock();
#endif
/*end of callfortranroutine*/
if (f2py_success) {
/*pyobjfrom*/
/*end of pyobjfrom*/
CFUNCSMESS("Building return value.\n");
capi_buildvalue = Py_BuildValue("N",capi_j_hess_tmp);
/*closepyobjfrom*/
/*end of closepyobjfrom*/
} /*if (f2py_success) after callfortranroutine*/
/*cleanupfrompyobj*/
/* End of cleaning variable f2py_x_d0 */
} /*if (capi_j_hess_tmp == NULL) ... else of j_hess*/
/* End of cleaning variable j_hess */
if((PyObject *)capi_x_tmp!=x_capi) {
Py_XDECREF(capi_x_tmp); }
} /*if (capi_x_tmp == NULL) ... else of x*/
/* End of cleaning variable x */
/*end of cleanupfrompyobj*/
if (capi_buildvalue == NULL) {
/*routdebugfailure*/
} else {
/*routdebugleave*/
}
CFUNCSMESS("Freeing memory.\n");
/*freemem*/
#ifdef F2PY_REPORT_ATEXIT
f2py_stop_clock();
#endif
return capi_buildvalue;
}
/**************************** end of costj_hess2d ****************************/
/********************************* add_noise *********************************/
static char doc_f2py_rout_hw2mod2_cost_add_noise[] = "\
add_noise(x,j)\n\nWrapper for ``add_noise``.\
\n\nParameters\n----------\n"
"x : input rank-1 array('d') with bounds (f2py_x_d0)\n"
"j : in/output rank-0 array(float,'d')";
/* #declfortranroutine# */
static PyObject *f2py_rout_hw2mod2_cost_add_noise(const PyObject *capi_self,
PyObject *capi_args,
PyObject *capi_keywds,
void (*f2py_func)(double*,double*,int*)) {
PyObject * volatile capi_buildvalue = NULL;
volatile int f2py_success = 1;
/*decl*/
double *x = NULL;
npy_intp x_Dims[1] = {-1};
const int x_Rank = 1;
PyArrayObject *capi_x_tmp = NULL;
int capi_x_intent = 0;
PyObject *x_capi = Py_None;
double j = 0;
PyObject *j_capi = Py_None;
int f2py_x_d0 = 0;
static char *capi_kwlist[] = {"x","j",NULL};
/*routdebugenter*/
#ifdef F2PY_REPORT_ATEXIT
f2py_start_clock();
#endif
if (!PyArg_ParseTupleAndKeywords(capi_args,capi_keywds,\
"OO:hw2mod2.cost.add_noise",\
capi_kwlist,&x_capi,&j_capi))
return NULL;
/*frompyobj*/
/* Processing variable x */
;
capi_x_intent |= F2PY_INTENT_IN;
capi_x_tmp = array_from_pyobj(NPY_DOUBLE,x_Dims,x_Rank,capi_x_intent,x_capi);
if (capi_x_tmp == NULL) {
if (!PyErr_Occurred())
PyErr_SetString(hw2mod2_error,"failed in converting 1st argument `x' of hw2mod2.cost.add_noise to C/Fortran array" );
} else {
x = (double *)(capi_x_tmp->data);
/* Processing variable j */
f2py_success = double_from_pyobj(&j,j_capi,"hw2mod2.cost.add_noise() 2nd argument (j) can't be converted to double");
if (f2py_success) {
/* Processing variable f2py_x_d0 */
f2py_x_d0 = shape(x, 0);
/*end of frompyobj*/
#ifdef F2PY_REPORT_ATEXIT
f2py_start_call_clock();
#endif
/*callfortranroutine*/
(*f2py_func)(x,&j,&f2py_x_d0);
if (PyErr_Occurred())
f2py_success = 0;
#ifdef F2PY_REPORT_ATEXIT
f2py_stop_call_clock();
#endif
/*end of callfortranroutine*/
if (f2py_success) {
/*pyobjfrom*/
f2py_success = try_pyarr_from_double(j_capi,&j);
if (f2py_success) {
/*end of pyobjfrom*/
CFUNCSMESS("Building return value.\n");
capi_buildvalue = Py_BuildValue("");
/*closepyobjfrom*/
} /*if (f2py_success) of j pyobjfrom*/
/*end of closepyobjfrom*/
} /*if (f2py_success) after callfortranroutine*/
/*cleanupfrompyobj*/
/* End of cleaning variable f2py_x_d0 */
} /*if (f2py_success) of j*/
/* End of cleaning variable j */
if((PyObject *)capi_x_tmp!=x_capi) {
Py_XDECREF(capi_x_tmp); }
} /*if (capi_x_tmp == NULL) ... else of x*/
/* End of cleaning variable x */
/*end of cleanupfrompyobj*/
if (capi_buildvalue == NULL) {
/*routdebugfailure*/
} else {
/*routdebugleave*/
}
CFUNCSMESS("Freeing memory.\n");
/*freemem*/
#ifdef F2PY_REPORT_ATEXIT
f2py_stop_clock();
#endif
return capi_buildvalue;
}
/****************************** end of add_noise ******************************/
/*********************************** newton ***********************************/
static char doc_f2py_rout_hw2mod2_hw2_newton[] = "\
xf,jf,i2 = newton(xguess)\n\nWrapper for ``newton``.\
\n\nParameters\n----------\n"
"xguess : input rank-2 array('d') with bounds (f2py_xguess_d0,f2py_xguess_d1)\n"
"\nReturns\n-------\n"
"xf : rank-2 array('d') with bounds (size(xguess),1)\n"
"jf : float\n"
"i2 : int";
/* #declfortranroutine# */
static PyObject *f2py_rout_hw2mod2_hw2_newton(const PyObject *capi_self,
PyObject *capi_args,
PyObject *capi_keywds,
void (*f2py_func)(double*,double*,double*,int*,int*,int*)) {
PyObject * volatile capi_buildvalue = NULL;
volatile int f2py_success = 1;
/*decl*/
double *xguess = NULL;
npy_intp xguess_Dims[2] = {-1, -1};
const int xguess_Rank = 2;
PyArrayObject *capi_xguess_tmp = NULL;
int capi_xguess_intent = 0;
PyObject *xguess_capi = Py_None;
double *xf = NULL;
npy_intp xf_Dims[2] = {-1, -1};
const int xf_Rank = 2;
PyArrayObject *capi_xf_tmp = NULL;
int capi_xf_intent = 0;
double jf = 0;
int i2 = 0;
int f2py_xguess_d0 = 0;
int f2py_xguess_d1 = 0;
static char *capi_kwlist[] = {"xguess",NULL};
/*routdebugenter*/
#ifdef F2PY_REPORT_ATEXIT
f2py_start_clock();
#endif
if (!PyArg_ParseTupleAndKeywords(capi_args,capi_keywds,\
"O:hw2mod2.hw2.newton",\
capi_kwlist,&xguess_capi))
return NULL;
/*frompyobj*/
/* Processing variable i2 */
/* Processing variable jf */
/* Processing variable xguess */
;
capi_xguess_intent |= F2PY_INTENT_IN;
capi_xguess_tmp = array_from_pyobj(NPY_DOUBLE,xguess_Dims,xguess_Rank,capi_xguess_intent,xguess_capi);
if (capi_xguess_tmp == NULL) {
if (!PyErr_Occurred())
PyErr_SetString(hw2mod2_error,"failed in converting 1st argument `xguess' of hw2mod2.hw2.newton to C/Fortran array" );
} else {
xguess = (double *)(capi_xguess_tmp->data);
/* Processing variable xf */
xf_Dims[0]=size(xguess),xf_Dims[1]=1;
capi_xf_intent |= F2PY_INTENT_OUT|F2PY_INTENT_HIDE;
capi_xf_tmp = array_from_pyobj(NPY_DOUBLE,xf_Dims,xf_Rank,capi_xf_intent,Py_None);
if (capi_xf_tmp == NULL) {
if (!PyErr_Occurred())
PyErr_SetString(hw2mod2_error,"failed in converting hidden `xf' of hw2mod2.hw2.newton to C/Fortran array" );
} else {
xf = (double *)(capi_xf_tmp->data);
/* Processing variable f2py_xguess_d0 */
f2py_xguess_d0 = shape(xguess, 0);
/* Processing variable f2py_xguess_d1 */
f2py_xguess_d1 = shape(xguess, 1);
/*end of frompyobj*/
#ifdef F2PY_REPORT_ATEXIT
f2py_start_call_clock();
#endif
/*callfortranroutine*/
(*f2py_func)(xguess,xf,&jf,&i2,&f2py_xguess_d0,&f2py_xguess_d1);
if (PyErr_Occurred())
f2py_success = 0;
#ifdef F2PY_REPORT_ATEXIT
f2py_stop_call_clock();
#endif
/*end of callfortranroutine*/
if (f2py_success) {
/*pyobjfrom*/
/*end of pyobjfrom*/
CFUNCSMESS("Building return value.\n");
capi_buildvalue = Py_BuildValue("Ndi",capi_xf_tmp,jf,i2);
/*closepyobjfrom*/
/*end of closepyobjfrom*/
} /*if (f2py_success) after callfortranroutine*/
/*cleanupfrompyobj*/
/* End of cleaning variable f2py_xguess_d1 */
/* End of cleaning variable f2py_xguess_d0 */
} /*if (capi_xf_tmp == NULL) ... else of xf*/
/* End of cleaning variable xf */
if((PyObject *)capi_xguess_tmp!=xguess_capi) {
Py_XDECREF(capi_xguess_tmp); }
} /*if (capi_xguess_tmp == NULL) ... else of xguess*/
/* End of cleaning variable xguess */
/* End of cleaning variable jf */
/* End of cleaning variable i2 */
/*end of cleanupfrompyobj*/
if (capi_buildvalue == NULL) {
/*routdebugfailure*/
} else {
/*routdebugleave*/
}
CFUNCSMESS("Freeing memory.\n");
/*freemem*/
#ifdef F2PY_REPORT_ATEXIT
f2py_stop_clock();
#endif
return capi_buildvalue;
}
/******************************* end of newton *******************************/
/****************************** bracket_descent ******************************/
static char doc_f2py_rout_hw2mod2_hw2_bracket_descent[] = "\
xf,jf,i2 = bracket_descent(xguess)\n\nWrapper for ``bracket_descent``.\
\n\nParameters\n----------\n"
"xguess : input rank-1 array('d') with bounds (2)\n"
"\nReturns\n-------\n"
"xf : rank-1 array('d') with bounds (2)\n"
"jf : float\n"
"i2 : int";
/* */
static PyObject *f2py_rout_hw2mod2_hw2_bracket_descent(const PyObject *capi_self,
PyObject *capi_args,
PyObject *capi_keywds,
void (*f2py_func)(double*,double*,double*,int*)) {
PyObject * volatile capi_buildvalue = NULL;
volatile int f2py_success = 1;
/*decl*/
double *xguess = NULL;
npy_intp xguess_Dims[1] = {-1};
const int xguess_Rank = 1;
PyArrayObject *capi_xguess_tmp = NULL;
int capi_xguess_intent = 0;
PyObject *xguess_capi = Py_None;
double *xf = NULL;
npy_intp xf_Dims[1] = {-1};
const int xf_Rank = 1;
PyArrayObject *capi_xf_tmp = NULL;
int capi_xf_intent = 0;
double jf = 0;
int i2 = 0;
static char *capi_kwlist[] = {"xguess",NULL};
/*routdebugenter*/
#ifdef F2PY_REPORT_ATEXIT
f2py_start_clock();
#endif
if (!PyArg_ParseTupleAndKeywords(capi_args,capi_keywds,\
"O:hw2mod2.hw2.bracket_descent",\
capi_kwlist,&xguess_capi))
return NULL;
/*frompyobj*/
/* Processing variable i2 */
/* Processing variable xf */
xf_Dims[0]=2;
capi_xf_intent |= F2PY_INTENT_OUT|F2PY_INTENT_HIDE;
capi_xf_tmp = array_from_pyobj(NPY_DOUBLE,xf_Dims,xf_Rank,capi_xf_intent,Py_None);
if (capi_xf_tmp == NULL) {
if (!PyErr_Occurred())
PyErr_SetString(hw2mod2_error,"failed in converting hidden `xf' of hw2mod2.hw2.bracket_descent to C/Fortran array" );
} else {
xf = (double *)(capi_xf_tmp->data);
/* Processing variable jf */
/* Processing variable xguess */
xguess_Dims[0]=2;
capi_xguess_intent |= F2PY_INTENT_IN;
capi_xguess_tmp = array_from_pyobj(NPY_DOUBLE,xguess_Dims,xguess_Rank,capi_xguess_intent,xguess_capi);
if (capi_xguess_tmp == NULL) {
if (!PyErr_Occurred())
PyErr_SetString(hw2mod2_error,"failed in converting 1st argument `xguess' of hw2mod2.hw2.bracket_descent to C/Fortran array" );
} else {
xguess = (double *)(capi_xguess_tmp->data);
/*end of frompyobj*/
#ifdef F2PY_REPORT_ATEXIT
f2py_start_call_clock();
#endif
/*callfortranroutine*/
(*f2py_func)(xguess,xf,&jf,&i2);
if (PyErr_Occurred())
f2py_success = 0;
#ifdef F2PY_REPORT_ATEXIT
f2py_stop_call_clock();
#endif
/*end of callfortranroutine*/
if (f2py_success) {
/*pyobjfrom*/
/*end of pyobjfrom*/
CFUNCSMESS("Building return value.\n");
capi_buildvalue = Py_BuildValue("Ndi",capi_xf_tmp,jf,i2);
/*closepyobjfrom*/
/*end of closepyobjfrom*/
} /*if (f2py_success) after callfortranroutine*/
/*cleanupfrompyobj*/
if((PyObject *)capi_xguess_tmp!=xguess_capi) {
Py_XDECREF(capi_xguess_tmp); }
} /*if (capi_xguess_tmp == NULL) ... else of xguess*/
/* End of cleaning variable xguess */
/* End of cleaning variable jf */
} /*if (capi_xf_tmp == NULL) ... else of xf*/
/* End of cleaning variable xf */
/* End of cleaning variable i2 */
/*end of cleanupfrompyobj*/
if (capi_buildvalue == NULL) {
/*routdebugfailure*/
} else {
/*routdebugleave*/
}
CFUNCSMESS("Freeing memory.\n");
/*freemem*/
#ifdef F2PY_REPORT_ATEXIT
f2py_stop_clock();
#endif
return capi_buildvalue;
}
/*************************** end of bracket_descent ***************************/
/******************************* bd_initialize *******************************/
static char doc_f2py_rout_hw2mod2_hw2_bd_initialize[] = "\
x3,j3 = bd_initialize(xguess)\n\nWrapper for ``bd_initialize``.\
\n\nParameters\n----------\n"
"xguess : input rank-1 array('d') with bounds (2)\n"
"\nReturns\n-------\n"
"x3 : rank-2 array('d') with bounds (3,2)\n"
"j3 : rank-1 array('d') with bounds (3)";
/* */
static PyObject *f2py_rout_hw2mod2_hw2_bd_initialize(const PyObject *capi_self,
PyObject *capi_args,
PyObject *capi_keywds,
void (*f2py_func)(double*,double*,double*)) {
PyObject * volatile capi_buildvalue = NULL;
volatile int f2py_success = 1;
/*decl*/
double *xguess = NULL;
npy_intp xguess_Dims[1] = {-1};
const int xguess_Rank = 1;
PyArrayObject *capi_xguess_tmp = NULL;
int capi_xguess_intent = 0;
PyObject *xguess_capi = Py_None;
double *x3 = NULL;
npy_intp x3_Dims[2] = {-1, -1};
const int x3_Rank = 2;
PyArrayObject *capi_x3_tmp = NULL;
int capi_x3_intent = 0;
double *j3 = NULL;
npy_intp j3_Dims[1] = {-1};
const int j3_Rank = 1;
PyArrayObject *capi_j3_tmp = NULL;
int capi_j3_intent = 0;
static char *capi_kwlist[] = {"xguess",NULL};
/*routdebugenter*/
#ifdef F2PY_REPORT_ATEXIT
f2py_start_clock();
#endif
if (!PyArg_ParseTupleAndKeywords(capi_args,capi_keywds,\
"O:hw2mod2.hw2.bd_initialize",\
capi_kwlist,&xguess_capi))
return NULL;
/*frompyobj*/
/* Processing variable xguess */
xguess_Dims[0]=2;
capi_xguess_intent |= F2PY_INTENT_IN;
capi_xguess_tmp = array_from_pyobj(NPY_DOUBLE,xguess_Dims,xguess_Rank,capi_xguess_intent,xguess_capi);
if (capi_xguess_tmp == NULL) {
if (!PyErr_Occurred())
PyErr_SetString(hw2mod2_error,"failed in converting 1st argument `xguess' of hw2mod2.hw2.bd_initialize to C/Fortran array" );
} else {
xguess = (double *)(capi_xguess_tmp->data);
/* Processing variable j3 */
j3_Dims[0]=3;
capi_j3_intent |= F2PY_INTENT_OUT|F2PY_INTENT_HIDE;
capi_j3_tmp = array_from_pyobj(NPY_DOUBLE,j3_Dims,j3_Rank,capi_j3_intent,Py_None);
if (capi_j3_tmp == NULL) {
if (!PyErr_Occurred())
PyErr_SetString(hw2mod2_error,"failed in converting hidden `j3' of hw2mod2.hw2.bd_initialize to C/Fortran array" );
} else {
j3 = (double *)(capi_j3_tmp->data);
/* Processing variable x3 */
x3_Dims[0]=3,x3_Dims[1]=2;
capi_x3_intent |= F2PY_INTENT_OUT|F2PY_INTENT_HIDE;
capi_x3_tmp = array_from_pyobj(NPY_DOUBLE,x3_Dims,x3_Rank,capi_x3_intent,Py_None);
if (capi_x3_tmp == NULL) {
if (!PyErr_Occurred())
PyErr_SetString(hw2mod2_error,"failed in converting hidden `x3' of hw2mod2.hw2.bd_initialize to C/Fortran array" );
} else {
x3 = (double *)(capi_x3_tmp->data);
/*end of frompyobj*/
#ifdef F2PY_REPORT_ATEXIT
f2py_start_call_clock();
#endif
/*callfortranroutine*/
(*f2py_func)(xguess,x3,j3);
if (PyErr_Occurred())
f2py_success = 0;
#ifdef F2PY_REPORT_ATEXIT
f2py_stop_call_clock();
#endif
/*end of callfortranroutine*/
if (f2py_success) {
/*pyobjfrom*/
/*end of pyobjfrom*/
CFUNCSMESS("Building return value.\n");
capi_buildvalue = Py_BuildValue("NN",capi_x3_tmp,capi_j3_tmp);
/*closepyobjfrom*/
/*end of closepyobjfrom*/
} /*if (f2py_success) after callfortranroutine*/
/*cleanupfrompyobj*/
} /*if (capi_x3_tmp == NULL) ... else of x3*/
/* End of cleaning variable x3 */
} /*if (capi_j3_tmp == NULL) ... else of j3*/
/* End of cleaning variable j3 */
if((PyObject *)capi_xguess_tmp!=xguess_capi) {
Py_XDECREF(capi_xguess_tmp); }
} /*if (capi_xguess_tmp == NULL) ... else of xguess*/
/* End of cleaning variable xguess */
/*end of cleanupfrompyobj*/
if (capi_buildvalue == NULL) {
/*routdebugfailure*/
} else {
/*routdebugleave*/
}
CFUNCSMESS("Freeing memory.\n");
/*freemem*/
#ifdef F2PY_REPORT_ATEXIT
f2py_stop_clock();
#endif
return capi_buildvalue;
}
/**************************** end of bd_initialize ****************************/
/***************************** convergence_check *****************************/
static char doc_f2py_rout_hw2mod2_hw2_convergence_check[] = "\
flag_converged = convergence_check(j1,j2)\n\nWrapper for ``convergence_check``.\
\n\nParameters\n----------\n"
"j1 : input float\n"
"j2 : input float\n"
"\nReturns\n-------\n"
"flag_converged : int";
/* */
static PyObject *f2py_rout_hw2mod2_hw2_convergence_check(const PyObject *capi_self,
PyObject *capi_args,
PyObject *capi_keywds,
void (*f2py_func)(double*,double*,int*)) {
PyObject * volatile capi_buildvalue = NULL;
volatile int f2py_success = 1;
/*decl*/
double j1 = 0;
PyObject *j1_capi = Py_None;
double j2 = 0;
PyObject *j2_capi = Py_None;
int flag_converged = 0;
static char *capi_kwlist[] = {"j1","j2",NULL};
/*routdebugenter*/
#ifdef F2PY_REPORT_ATEXIT
f2py_start_clock();
#endif
if (!PyArg_ParseTupleAndKeywords(capi_args,capi_keywds,\
"OO:hw2mod2.hw2.convergence_check",\
capi_kwlist,&j1_capi,&j2_capi))
return NULL;
/*frompyobj*/
/* Processing variable flag_converged */
/* Processing variable j1 */
f2py_success = double_from_pyobj(&j1,j1_capi,"hw2mod2.hw2.convergence_check() 1st argument (j1) can't be converted to double");