#NEWLINE# def c_code( self , node , name , inputs , out_ , sub ) : #NEWLINE# #INDENT# copy_to_list = [ ] #NEWLINE# restype = pygpu . gpuarray . dtype_to_typecode ( node . outputs [ 0 ] . dtype ) #NEWLINE# for ( i , inp ) in enumerate ( inputs [ 1 : ] ) : #NEWLINE# #INDENT# copy_to_list . append ( ( 'als[%s] = &%s->ga;' % ( i , inp ) ) ) #NEWLINE# #UNINDENT# return ( '\nconst GpuArray **als = (const GpuArray **)PyMem_Malloc(sizeof(GpuArray *) *\n                                                       %(n)s);\nif (als == NULL) {\n  PyErr_NoMemory();\n  %(fail)s\n}\n%(copy_inputs_to_list)s\nPy_XDECREF(%(out)s);\n{\nint axis = PyInt_AsLong((PyObject *)%(axis)s);\nif (axis < 0) {\n  if (axis == -1 && PyErr_Occurred()) {\n    %(fail)s\n  }\n  axis += als[0]->nd;\n  if (axis < 0) {\n    PyErr_SetString(PyExc_IndexError, "invalid axis");\n    %(fail)s\n  }\n}\n%(out)s = pygpu_concatenate(als, %(n)s, axis,\n                            %(restype)s, (PyObject *)&PyGpuArrayType,\n                            %(ctx)s);\n}\nPyMem_Free(als);\nif (%(out)s == NULL)\n  %(fail)s\n        ' % dict ( n = len ( inputs [ 1 : ] ) , fail = sub [ 'fail' ] , out = out_ [ 0 ] , axis = inputs [ 0 ] , copy_inputs_to_list = '\n' . join ( copy_to_list ) , restype = restype , ctx = sub [ 'params' ] ) )