/* matrix.c generated by valac 0.56.19, the Vala compiler
 * generated from matrix.vala, do not modify */

/*
 * Copyright (c) 2025 focus-timer contributors
 *
 * SPDX-License-Identifier: GPL-3.0-or-later
 */

#include "ft_core.h"
#include <glib.h>
#include <float.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>

#define FT_MATRIX_DIMENSIONS 2
#define FT_MATRIX3_D_DIMENSIONS 3
#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif

#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_string_free0(var) ((var == NULL) ? NULL : (var = (g_string_free (var, TRUE), NULL)))
#define _ft_vector_free0(var) ((var == NULL) ? NULL : (var = (ft_vector_free (var), NULL)))
#define _ft_matrix_free0(var) ((var == NULL) ? NULL : (var = (ft_matrix_free (var), NULL)))
#define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);
#define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return; }
#define _vala_return_val_if_fail(expr, msg, val) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return val; }
#define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);

static void ft_vector_instance_init (FtVector * self);
static gdouble* _vala_array_dup13 (gdouble* self,
                            gssize length);
static inline gboolean ft_vector_validate_index (FtVector* self,
                                   gint* i);
static void ft_matrix_instance_init (FtMatrix * self);
static gdouble* _vala_array_dup14 (gdouble* self,
                            gssize length);
static inline gboolean ft_matrix_validate_axis (FtMatrix* self,
                                  gint* axis);
static inline gboolean ft_matrix_validate_indices (FtMatrix* self,
                                     gint* i,
                                     gint* j);
static inline gboolean ft_matrix_validate_index (FtMatrix* self,
                                   gint* axis,
                                   gint* index);
static gdouble* _vala_array_dup15 (gdouble* self,
                            gssize length);
static void ft_matrix3_d_instance_init (FtMatrix3D * self);
static gdouble* _vala_array_dup16 (gdouble* self,
                            gssize length);
static inline gboolean ft_matrix3_d_validate_axis (FtMatrix3D* self,
                                     gint* axis);
static inline gboolean ft_matrix3_d_validate_indices (FtMatrix3D* self,
                                        gint* i,
                                        gint* j,
                                        gint* k);
static inline gboolean ft_matrix3_d_validate_index (FtMatrix3D* self,
                                      gint* axis,
                                      gint* index);
static gdouble* _vala_array_dup17 (gdouble* self,
                            gssize length);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

FtVector*
ft_vector_new (guint length)
{
	FtVector* self;
	gdouble* _tmp0_;
	self = g_slice_new0 (FtVector);
	ft_vector_instance_init (self);
	_tmp0_ = g_new0 (gdouble, length);
	self->data = (g_free (self->data), NULL);
	self->data = _tmp0_;
	self->data_length1 = length;
	return self;
}

static gdouble*
_vala_array_dup13 (gdouble* self,
                   gssize length)
{
	if (length > 0) {
		return _vala_memdup2 (self, length * sizeof (gdouble));
	}
	return NULL;
}

FtVector*
ft_vector_new_from_array (gdouble* array,
                          gint array_length1)
{
	FtVector* self;
	gdouble* _tmp0_;
	gint _tmp0__length1;
	self = g_slice_new0 (FtVector);
	ft_vector_instance_init (self);
	_tmp0_ = (array != NULL) ? _vala_array_dup13 (array, array_length1) : array;
	_tmp0__length1 = array_length1;
	self->data = (g_free (self->data), NULL);
	self->data = _tmp0_;
	self->data_length1 = _tmp0__length1;
	return self;
}

FtVector*
ft_vector_copy (FtVector* self)
{
	FtVector* _result_ = NULL;
	gdouble* _tmp0_;
	gint _tmp0__length1;
	FtVector* _tmp1_;
	FtVector* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->data;
	_tmp0__length1 = self->data_length1;
	_tmp1_ = ft_vector_new ((guint) _tmp0__length1);
	_result_ = _tmp1_;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp2_ = FALSE;
			_tmp2_ = TRUE;
			while (TRUE) {
				gdouble* _tmp4_;
				gint _tmp4__length1;
				FtVector* _tmp5_;
				gdouble* _tmp6_;
				gint _tmp6__length1;
				gdouble* _tmp7_;
				gint _tmp7__length1;
				gdouble _tmp8_;
				if (!_tmp2_) {
					gint _tmp3_;
					_tmp3_ = i;
					i = _tmp3_ + 1;
				}
				_tmp2_ = FALSE;
				_tmp4_ = self->data;
				_tmp4__length1 = self->data_length1;
				if (!(i < _tmp4__length1)) {
					break;
				}
				_tmp5_ = _result_;
				_tmp6_ = _tmp5_->data;
				_tmp6__length1 = _tmp5_->data_length1;
				_tmp7_ = self->data;
				_tmp7__length1 = self->data_length1;
				_tmp8_ = _tmp7_[i];
				_tmp6_[i] = _tmp8_;
			}
		}
	}
	result = _result_;
	return result;
}

static inline gboolean
ft_vector_validate_index (FtVector* self,
                          gint* i)
{
	gdouble* _tmp1_;
	gint _tmp1__length1;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	if ((*i) < 0) {
		gdouble* _tmp0_;
		gint _tmp0__length1;
		_tmp0_ = self->data;
		_tmp0__length1 = self->data_length1;
		*i = _tmp0__length1 + (*i);
	}
	_tmp1_ = self->data;
	_tmp1__length1 = self->data_length1;
	result = (*i) < _tmp1__length1;
	return result;
}

gdouble
ft_vector_get (FtVector* self,
               gint i,
               gdouble default_value)
{
	gdouble _tmp0_ = 0.0;
	gboolean _tmp1_;
	gdouble result;
	g_return_val_if_fail (self != NULL, -1.0);
	_tmp1_ = ft_vector_validate_index (self, &i);
	if (_tmp1_) {
		gdouble* _tmp2_;
		gint _tmp2__length1;
		gdouble _tmp3_;
		_tmp2_ = self->data;
		_tmp2__length1 = self->data_length1;
		_tmp3_ = _tmp2_[i];
		_tmp0_ = _tmp3_;
	} else {
		_tmp0_ = default_value;
	}
	result = _tmp0_;
	return result;
}

void
ft_vector_set (FtVector* self,
               gint i,
               gdouble value)
{
	gboolean _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = ft_vector_validate_index (self, &i);
	if (_tmp0_) {
		gdouble* _tmp1_;
		gint _tmp1__length1;
		_tmp1_ = self->data;
		_tmp1__length1 = self->data_length1;
		_tmp1_[i] = value;
	} else {
		g_warning ("matrix.vala:72: Vector index %u is out of bounds", (guint) i);
	}
}

gboolean
ft_vector_equals (FtVector* self,
                  FtVector* other)
{
	gdouble* _tmp0_;
	gint _tmp0__length1;
	gdouble* _tmp1_;
	gint _tmp1__length1;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (other != NULL, FALSE);
	_tmp0_ = self->data;
	_tmp0__length1 = self->data_length1;
	_tmp1_ = self->data;
	_tmp1__length1 = self->data_length1;
	if (_tmp0__length1 != _tmp1__length1) {
		result = FALSE;
		return result;
	}
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp2_ = FALSE;
			_tmp2_ = TRUE;
			while (TRUE) {
				gdouble* _tmp4_;
				gint _tmp4__length1;
				gdouble* _tmp5_;
				gint _tmp5__length1;
				gdouble _tmp6_;
				gdouble* _tmp7_;
				gint _tmp7__length1;
				gdouble _tmp8_;
				if (!_tmp2_) {
					gint _tmp3_;
					_tmp3_ = i;
					i = _tmp3_ + 1;
				}
				_tmp2_ = FALSE;
				_tmp4_ = self->data;
				_tmp4__length1 = self->data_length1;
				if (!(i < _tmp4__length1)) {
					break;
				}
				_tmp5_ = self->data;
				_tmp5__length1 = self->data_length1;
				_tmp6_ = _tmp5_[i];
				_tmp7_ = other->data;
				_tmp7__length1 = other->data_length1;
				_tmp8_ = _tmp7_[i];
				if (fabs (_tmp6_ - _tmp8_) > DBL_EPSILON) {
					result = FALSE;
					return result;
				}
			}
		}
	}
	result = TRUE;
	return result;
}

gboolean
ft_vector_add (FtVector* self,
               FtVector* other)
{
	gdouble* _tmp0_;
	gint _tmp0__length1;
	gdouble* _tmp1_;
	gint _tmp1__length1;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (other != NULL, FALSE);
	_tmp0_ = other->data;
	_tmp0__length1 = other->data_length1;
	_tmp1_ = self->data;
	_tmp1__length1 = self->data_length1;
	if (_tmp0__length1 != _tmp1__length1) {
		result = FALSE;
		return result;
	}
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp2_ = FALSE;
			_tmp2_ = TRUE;
			while (TRUE) {
				gdouble* _tmp4_;
				gint _tmp4__length1;
				gdouble* _tmp5_;
				gint _tmp5__length1;
				gdouble* _tmp6_;
				gint _tmp6__length1;
				gdouble _tmp7_;
				if (!_tmp2_) {
					gint _tmp3_;
					_tmp3_ = i;
					i = _tmp3_ + 1;
				}
				_tmp2_ = FALSE;
				_tmp4_ = self->data;
				_tmp4__length1 = self->data_length1;
				if (!(i < _tmp4__length1)) {
					break;
				}
				_tmp5_ = self->data;
				_tmp5__length1 = self->data_length1;
				_tmp6_ = other->data;
				_tmp6__length1 = other->data_length1;
				_tmp7_ = _tmp6_[i];
				_tmp5_[i] += _tmp7_;
			}
		}
	}
	result = TRUE;
	return result;
}

gdouble
ft_vector_sum (FtVector* self)
{
	gdouble _result_ = 0.0;
	gdouble result;
	g_return_val_if_fail (self != NULL, -1.0);
	_result_ = 0.0;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp0_ = FALSE;
			_tmp0_ = TRUE;
			while (TRUE) {
				gdouble* _tmp2_;
				gint _tmp2__length1;
				gdouble* _tmp3_;
				gint _tmp3__length1;
				gdouble _tmp4_;
				if (!_tmp0_) {
					gint _tmp1_;
					_tmp1_ = i;
					i = _tmp1_ + 1;
				}
				_tmp0_ = FALSE;
				_tmp2_ = self->data;
				_tmp2__length1 = self->data_length1;
				if (!(i < _tmp2__length1)) {
					break;
				}
				_tmp3_ = self->data;
				_tmp3__length1 = self->data_length1;
				_tmp4_ = _tmp3_[i];
				_result_ += _tmp4_;
			}
		}
	}
	result = _result_;
	return result;
}

gdouble
ft_vector_min (FtVector* self)
{
	gdouble _result_ = 0.0;
	gdouble* _tmp0_;
	gint _tmp0__length1;
	gdouble _tmp1_;
	gdouble result;
	g_return_val_if_fail (self != NULL, -1.0);
	_tmp0_ = self->data;
	_tmp0__length1 = self->data_length1;
	_tmp1_ = _tmp0_[0];
	_result_ = _tmp1_;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp2_ = FALSE;
			_tmp2_ = TRUE;
			while (TRUE) {
				gdouble* _tmp4_;
				gint _tmp4__length1;
				gdouble* _tmp5_;
				gint _tmp5__length1;
				gdouble _tmp6_;
				if (!_tmp2_) {
					gint _tmp3_;
					_tmp3_ = i;
					i = _tmp3_ + 1;
				}
				_tmp2_ = FALSE;
				_tmp4_ = self->data;
				_tmp4__length1 = self->data_length1;
				if (!(i < _tmp4__length1)) {
					break;
				}
				_tmp5_ = self->data;
				_tmp5__length1 = self->data_length1;
				_tmp6_ = _tmp5_[i];
				if (_result_ > _tmp6_) {
					gdouble* _tmp7_;
					gint _tmp7__length1;
					gdouble _tmp8_;
					_tmp7_ = self->data;
					_tmp7__length1 = self->data_length1;
					_tmp8_ = _tmp7_[i];
					_result_ = _tmp8_;
				}
			}
		}
	}
	result = _result_;
	return result;
}

gdouble
ft_vector_max (FtVector* self)
{
	gdouble _result_ = 0.0;
	gdouble* _tmp0_;
	gint _tmp0__length1;
	gdouble _tmp1_;
	gdouble result;
	g_return_val_if_fail (self != NULL, -1.0);
	_tmp0_ = self->data;
	_tmp0__length1 = self->data_length1;
	_tmp1_ = _tmp0_[0];
	_result_ = _tmp1_;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp2_ = FALSE;
			_tmp2_ = TRUE;
			while (TRUE) {
				gdouble* _tmp4_;
				gint _tmp4__length1;
				gdouble* _tmp5_;
				gint _tmp5__length1;
				gdouble _tmp6_;
				if (!_tmp2_) {
					gint _tmp3_;
					_tmp3_ = i;
					i = _tmp3_ + 1;
				}
				_tmp2_ = FALSE;
				_tmp4_ = self->data;
				_tmp4__length1 = self->data_length1;
				if (!(i < _tmp4__length1)) {
					break;
				}
				_tmp5_ = self->data;
				_tmp5__length1 = self->data_length1;
				_tmp6_ = _tmp5_[i];
				if (_result_ < _tmp6_) {
					gdouble* _tmp7_;
					gint _tmp7__length1;
					gdouble _tmp8_;
					_tmp7_ = self->data;
					_tmp7__length1 = self->data_length1;
					_tmp8_ = _tmp7_[i];
					_result_ = _tmp8_;
				}
			}
		}
	}
	result = _result_;
	return result;
}

gchar*
ft_vector_to_representation (FtVector* self)
{
	GString* string_builder = NULL;
	GString* _tmp0_;
	GString* _tmp1_;
	GString* _tmp11_;
	GString* _tmp12_;
	const gchar* _tmp13_;
	gchar* _tmp14_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_string_new ("");
	string_builder = _tmp0_;
	_tmp1_ = string_builder;
	g_string_append (_tmp1_, "{ ");
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp2_ = FALSE;
			_tmp2_ = TRUE;
			while (TRUE) {
				gdouble* _tmp4_;
				gint _tmp4__length1;
				GString* _tmp6_;
				gdouble* _tmp7_;
				gint _tmp7__length1;
				gdouble _tmp8_;
				gchar* _tmp9_;
				gchar* _tmp10_;
				if (!_tmp2_) {
					gint _tmp3_;
					_tmp3_ = i;
					i = _tmp3_ + 1;
				}
				_tmp2_ = FALSE;
				_tmp4_ = self->data;
				_tmp4__length1 = self->data_length1;
				if (!(i < _tmp4__length1)) {
					break;
				}
				if (i > 0) {
					GString* _tmp5_;
					_tmp5_ = string_builder;
					g_string_append (_tmp5_, ", ");
				}
				_tmp6_ = string_builder;
				_tmp7_ = self->data;
				_tmp7__length1 = self->data_length1;
				_tmp8_ = _tmp7_[i];
				_tmp9_ = g_strdup_printf ("%.3g", _tmp8_);
				_tmp10_ = _tmp9_;
				g_string_append (_tmp6_, _tmp10_);
				_g_free0 (_tmp10_);
			}
		}
	}
	_tmp11_ = string_builder;
	g_string_append (_tmp11_, " }");
	_tmp12_ = string_builder;
	_tmp13_ = _tmp12_->str;
	_tmp14_ = g_strdup (_tmp13_);
	result = _tmp14_;
	_g_string_free0 (string_builder);
	return result;
}

static void
ft_vector_instance_init (FtVector * self)
{
}

void
ft_vector_free (FtVector * self)
{
	self->data = (g_free (self->data), NULL);
	self->data = NULL;
	self->data_length1 = 0;
	self->data = (g_free (self->data), NULL);
	g_slice_free (FtVector, self);
}

FtMatrix*
ft_matrix_new (guint shape_0,
               guint shape_1)
{
	FtMatrix* self;
	guint* _tmp0_;
	gdouble* _tmp1_;
	self = g_slice_new0 (FtMatrix);
	ft_matrix_instance_init (self);
	_tmp0_ = g_new0 (guint, 2);
	_tmp0_[0] = shape_0;
	_tmp0_[1] = shape_1;
	self->shape = (g_free (self->shape), NULL);
	self->shape = _tmp0_;
	self->shape_length1 = 2;
	_tmp1_ = g_new0 (gdouble, shape_0 * shape_1);
	self->data = (g_free (self->data), NULL);
	self->data = _tmp1_;
	self->data_length1 = shape_0;
	self->data_length2 = shape_1;
	return self;
}

static gdouble*
_vala_array_dup14 (gdouble* self,
                   gssize length)
{
	if (length > 0) {
		return _vala_memdup2 (self, length * sizeof (gdouble));
	}
	return NULL;
}

FtMatrix*
ft_matrix_new_from_array (gdouble* array,
                          gint array_length1,
                          gint array_length2)
{
	FtMatrix* self;
	gint _tmp0_;
	gint _tmp1_;
	guint* _tmp2_;
	gdouble* _tmp3_;
	gint _tmp3__length1;
	gint _tmp3__length2;
	self = g_slice_new0 (FtMatrix);
	ft_matrix_instance_init (self);
	_tmp0_ = array_length1;
	_tmp1_ = array_length2;
	_tmp2_ = g_new0 (guint, 2);
	_tmp2_[0] = (guint) _tmp0_;
	_tmp2_[1] = (guint) _tmp1_;
	self->shape = (g_free (self->shape), NULL);
	self->shape = _tmp2_;
	self->shape_length1 = 2;
	_tmp3_ = (array != NULL) ? _vala_array_dup14 (array, array_length1 * array_length2) : array;
	_tmp3__length1 = array_length1;
	_tmp3__length2 = array_length2;
	self->data = (g_free (self->data), NULL);
	self->data = _tmp3_;
	self->data_length1 = _tmp3__length1;
	self->data_length2 = _tmp3__length2;
	return self;
}

FtMatrix*
ft_matrix_copy (FtMatrix* self)
{
	FtMatrix* _result_ = NULL;
	guint* _tmp0_;
	gint _tmp0__length1;
	guint _tmp1_;
	guint* _tmp2_;
	gint _tmp2__length1;
	guint _tmp3_;
	FtMatrix* _tmp4_;
	FtMatrix* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->shape;
	_tmp0__length1 = self->shape_length1;
	_tmp1_ = _tmp0_[0];
	_tmp2_ = self->shape;
	_tmp2__length1 = self->shape_length1;
	_tmp3_ = _tmp2_[1];
	_tmp4_ = ft_matrix_new (_tmp1_, _tmp3_);
	_result_ = _tmp4_;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp5_ = FALSE;
			_tmp5_ = TRUE;
			while (TRUE) {
				guint* _tmp7_;
				gint _tmp7__length1;
				guint _tmp8_;
				if (!_tmp5_) {
					gint _tmp6_;
					_tmp6_ = i;
					i = _tmp6_ + 1;
				}
				_tmp5_ = FALSE;
				_tmp7_ = self->shape;
				_tmp7__length1 = self->shape_length1;
				_tmp8_ = _tmp7_[0];
				if (!(((guint) i) < _tmp8_)) {
					break;
				}
				{
					gint j = 0;
					j = 0;
					{
						gboolean _tmp9_ = FALSE;
						_tmp9_ = TRUE;
						while (TRUE) {
							guint* _tmp11_;
							gint _tmp11__length1;
							guint _tmp12_;
							FtMatrix* _tmp13_;
							gdouble* _tmp14_;
							gint _tmp14__length1;
							gint _tmp14__length2;
							gdouble* _tmp15_;
							gint _tmp15__length1;
							gint _tmp15__length2;
							gdouble _tmp16_;
							if (!_tmp9_) {
								gint _tmp10_;
								_tmp10_ = j;
								j = _tmp10_ + 1;
							}
							_tmp9_ = FALSE;
							_tmp11_ = self->shape;
							_tmp11__length1 = self->shape_length1;
							_tmp12_ = _tmp11_[1];
							if (!(((guint) j) < _tmp12_)) {
								break;
							}
							_tmp13_ = _result_;
							_tmp14_ = _tmp13_->data;
							_tmp14__length1 = _tmp13_->data_length1;
							_tmp14__length2 = _tmp13_->data_length2;
							_tmp15_ = self->data;
							_tmp15__length1 = self->data_length1;
							_tmp15__length2 = self->data_length2;
							_tmp16_ = _tmp15_[(i * _tmp15__length2) + j];
							_tmp14_[(i * _tmp14__length2) + j] = _tmp16_;
						}
					}
				}
			}
		}
	}
	result = _result_;
	return result;
}

static inline gboolean
ft_matrix_validate_axis (FtMatrix* self,
                         gint* axis)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	if ((*axis) < 0) {
		*axis = FT_MATRIX_DIMENSIONS + (*axis);
	}
	result = (*axis) < FT_MATRIX_DIMENSIONS;
	return result;
}

static inline gboolean
ft_matrix_validate_indices (FtMatrix* self,
                            gint* i,
                            gint* j)
{
	gboolean _tmp4_ = FALSE;
	gdouble* _tmp5_;
	gint _tmp5__length1;
	gint _tmp5__length2;
	gint _tmp6_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	if ((*i) < 0) {
		gdouble* _tmp0_;
		gint _tmp0__length1;
		gint _tmp0__length2;
		gint _tmp1_;
		_tmp0_ = self->data;
		_tmp0__length1 = self->data_length1;
		_tmp0__length2 = self->data_length2;
		_tmp1_ = _tmp0__length1;
		*i = _tmp1_ + (*i);
	}
	if ((*j) < 0) {
		gdouble* _tmp2_;
		gint _tmp2__length1;
		gint _tmp2__length2;
		gint _tmp3_;
		_tmp2_ = self->data;
		_tmp2__length1 = self->data_length1;
		_tmp2__length2 = self->data_length2;
		_tmp3_ = _tmp2__length2;
		*j = _tmp3_ + (*j);
	}
	_tmp5_ = self->data;
	_tmp5__length1 = self->data_length1;
	_tmp5__length2 = self->data_length2;
	_tmp6_ = _tmp5__length1;
	if ((*i) < _tmp6_) {
		gdouble* _tmp7_;
		gint _tmp7__length1;
		gint _tmp7__length2;
		gint _tmp8_;
		_tmp7_ = self->data;
		_tmp7__length1 = self->data_length1;
		_tmp7__length2 = self->data_length2;
		_tmp8_ = _tmp7__length2;
		_tmp4_ = (*j) < _tmp8_;
	} else {
		_tmp4_ = FALSE;
	}
	result = _tmp4_;
	return result;
}

static inline gboolean
ft_matrix_validate_index (FtMatrix* self,
                          gint* axis,
                          gint* index)
{
	gboolean _tmp0_;
	guint* _tmp3_;
	gint _tmp3__length1;
	guint _tmp4_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = ft_matrix_validate_axis (self, axis);
	if (!_tmp0_) {
		result = FALSE;
		return result;
	}
	if ((*index) < 0) {
		guint* _tmp1_;
		gint _tmp1__length1;
		guint _tmp2_;
		_tmp1_ = self->shape;
		_tmp1__length1 = self->shape_length1;
		_tmp2_ = _tmp1_[*axis];
		*index = ((gint) _tmp2_) + (*index);
	}
	_tmp3_ = self->shape;
	_tmp3__length1 = self->shape_length1;
	_tmp4_ = _tmp3_[*axis];
	result = (*index) < ((gint) _tmp4_);
	return result;
}

static gdouble*
_vala_array_dup15 (gdouble* self,
                   gssize length)
{
	if (length > 0) {
		return _vala_memdup2 (self, length * sizeof (gdouble));
	}
	return NULL;
}

void
ft_matrix_resize (FtMatrix* self,
                  guint shape_0,
                  guint shape_1,
                  gdouble default_value)
{
	guint intersect_0 = 0U;
	guint* _tmp0_;
	gint _tmp0__length1;
	guint _tmp1_;
	guint intersect_1 = 0U;
	guint* _tmp2_;
	gint _tmp2__length1;
	guint _tmp3_;
	gdouble* data = NULL;
	gdouble* _tmp4_;
	gint data_length1;
	gint data_length2;
	gdouble* _tmp17_;
	gint _tmp17__length1;
	gint _tmp17__length2;
	gdouble* _tmp18_;
	gint _tmp18__length1;
	gint _tmp18__length2;
	guint* _tmp19_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->shape;
	_tmp0__length1 = self->shape_length1;
	_tmp1_ = _tmp0_[0];
	intersect_0 = MIN (shape_0, _tmp1_);
	_tmp2_ = self->shape;
	_tmp2__length1 = self->shape_length1;
	_tmp3_ = _tmp2_[1];
	intersect_1 = MIN (shape_1, _tmp3_);
	_tmp4_ = g_new0 (gdouble, shape_0 * shape_1);
	data = _tmp4_;
	data_length1 = shape_0;
	data_length2 = shape_1;
	if (default_value != 0.0) {
		{
			gint i = 0;
			i = 0;
			{
				gboolean _tmp5_ = FALSE;
				_tmp5_ = TRUE;
				while (TRUE) {
					if (!_tmp5_) {
						gint _tmp6_;
						_tmp6_ = i;
						i = _tmp6_ + 1;
					}
					_tmp5_ = FALSE;
					if (!(((guint) i) < shape_0)) {
						break;
					}
					{
						gint j = 0;
						j = 0;
						{
							gboolean _tmp7_ = FALSE;
							_tmp7_ = TRUE;
							while (TRUE) {
								gdouble* _tmp9_;
								gint _tmp9__length1;
								gint _tmp9__length2;
								if (!_tmp7_) {
									gint _tmp8_;
									_tmp8_ = j;
									j = _tmp8_ + 1;
								}
								_tmp7_ = FALSE;
								if (!(((guint) j) < shape_1)) {
									break;
								}
								_tmp9_ = data;
								_tmp9__length1 = data_length1;
								_tmp9__length2 = data_length2;
								_tmp9_[(i * _tmp9__length2) + j] = default_value;
							}
						}
					}
				}
			}
		}
	}
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp10_ = FALSE;
			_tmp10_ = TRUE;
			while (TRUE) {
				if (!_tmp10_) {
					gint _tmp11_;
					_tmp11_ = i;
					i = _tmp11_ + 1;
				}
				_tmp10_ = FALSE;
				if (!(((guint) i) < intersect_0)) {
					break;
				}
				{
					gint j = 0;
					j = 0;
					{
						gboolean _tmp12_ = FALSE;
						_tmp12_ = TRUE;
						while (TRUE) {
							gdouble* _tmp14_;
							gint _tmp14__length1;
							gint _tmp14__length2;
							gdouble* _tmp15_;
							gint _tmp15__length1;
							gint _tmp15__length2;
							gdouble _tmp16_;
							if (!_tmp12_) {
								gint _tmp13_;
								_tmp13_ = j;
								j = _tmp13_ + 1;
							}
							_tmp12_ = FALSE;
							if (!(((guint) j) < intersect_1)) {
								break;
							}
							_tmp14_ = data;
							_tmp14__length1 = data_length1;
							_tmp14__length2 = data_length2;
							_tmp15_ = self->data;
							_tmp15__length1 = self->data_length1;
							_tmp15__length2 = self->data_length2;
							_tmp16_ = _tmp15_[(i * _tmp15__length2) + j];
							_tmp14_[(i * _tmp14__length2) + j] = _tmp16_;
						}
					}
				}
			}
		}
	}
	_tmp17_ = data;
	_tmp17__length1 = data_length1;
	_tmp17__length2 = data_length2;
	_tmp18_ = (_tmp17_ != NULL) ? _vala_array_dup15 (_tmp17_, _tmp17__length1 * _tmp17__length2) : _tmp17_;
	_tmp18__length1 = _tmp17__length1;
	_tmp18__length2 = _tmp17__length2;
	self->data = (g_free (self->data), NULL);
	self->data = _tmp18_;
	self->data_length1 = _tmp18__length1;
	self->data_length2 = _tmp18__length2;
	_tmp19_ = g_new0 (guint, 2);
	_tmp19_[0] = shape_0;
	_tmp19_[1] = shape_1;
	self->shape = (g_free (self->shape), NULL);
	self->shape = _tmp19_;
	self->shape_length1 = 2;
	data = (g_free (data), NULL);
}

gdouble
ft_matrix_get (FtMatrix* self,
               gint i,
               gint j,
               gdouble default_value)
{
	gdouble _tmp0_ = 0.0;
	gboolean _tmp1_;
	gdouble result;
	g_return_val_if_fail (self != NULL, -1.0);
	_tmp1_ = ft_matrix_validate_indices (self, &i, &j);
	if (_tmp1_) {
		gdouble* _tmp2_;
		gint _tmp2__length1;
		gint _tmp2__length2;
		gdouble _tmp3_;
		_tmp2_ = self->data;
		_tmp2__length1 = self->data_length1;
		_tmp2__length2 = self->data_length2;
		_tmp3_ = _tmp2_[(i * _tmp2__length2) + j];
		_tmp0_ = _tmp3_;
	} else {
		_tmp0_ = default_value;
	}
	result = _tmp0_;
	return result;
}

void
ft_matrix_set (FtMatrix* self,
               gint i,
               gint j,
               gdouble value)
{
	gboolean _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = ft_matrix_validate_indices (self, &i, &j);
	if (_tmp0_) {
		gdouble* _tmp1_;
		gint _tmp1__length1;
		gint _tmp1__length2;
		_tmp1_ = self->data;
		_tmp1__length1 = self->data_length1;
		_tmp1__length2 = self->data_length2;
		_tmp1_[(i * _tmp1__length2) + j] = value;
	} else {
		g_warning ("matrix.vala:298: Matrix indices %u, %u are out of bounds", (guint) i, (guint) j);
	}
}

void
ft_matrix_fill (FtMatrix* self,
                gdouble value)
{
	g_return_if_fail (self != NULL);
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp0_ = FALSE;
			_tmp0_ = TRUE;
			while (TRUE) {
				guint* _tmp2_;
				gint _tmp2__length1;
				guint _tmp3_;
				if (!_tmp0_) {
					gint _tmp1_;
					_tmp1_ = i;
					i = _tmp1_ + 1;
				}
				_tmp0_ = FALSE;
				_tmp2_ = self->shape;
				_tmp2__length1 = self->shape_length1;
				_tmp3_ = _tmp2_[0];
				if (!(((guint) i) < _tmp3_)) {
					break;
				}
				{
					gint j = 0;
					j = 0;
					{
						gboolean _tmp4_ = FALSE;
						_tmp4_ = TRUE;
						while (TRUE) {
							guint* _tmp6_;
							gint _tmp6__length1;
							guint _tmp7_;
							gdouble* _tmp8_;
							gint _tmp8__length1;
							gint _tmp8__length2;
							if (!_tmp4_) {
								gint _tmp5_;
								_tmp5_ = j;
								j = _tmp5_ + 1;
							}
							_tmp4_ = FALSE;
							_tmp6_ = self->shape;
							_tmp6__length1 = self->shape_length1;
							_tmp7_ = _tmp6_[1];
							if (!(((guint) j) < _tmp7_)) {
								break;
							}
							_tmp8_ = self->data;
							_tmp8__length1 = self->data_length1;
							_tmp8__length2 = self->data_length2;
							_tmp8_[(i * _tmp8__length2) + j] = value;
						}
					}
				}
			}
		}
	}
}

gboolean
ft_matrix_equals (FtMatrix* self,
                  FtMatrix* other)
{
	gboolean _tmp0_ = FALSE;
	guint* _tmp1_;
	gint _tmp1__length1;
	guint _tmp2_;
	guint* _tmp3_;
	gint _tmp3__length1;
	guint _tmp4_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (other != NULL, FALSE);
	_tmp1_ = self->shape;
	_tmp1__length1 = self->shape_length1;
	_tmp2_ = _tmp1_[0];
	_tmp3_ = other->shape;
	_tmp3__length1 = other->shape_length1;
	_tmp4_ = _tmp3_[0];
	if (_tmp2_ != _tmp4_) {
		_tmp0_ = TRUE;
	} else {
		guint* _tmp5_;
		gint _tmp5__length1;
		guint _tmp6_;
		guint* _tmp7_;
		gint _tmp7__length1;
		guint _tmp8_;
		_tmp5_ = self->shape;
		_tmp5__length1 = self->shape_length1;
		_tmp6_ = _tmp5_[1];
		_tmp7_ = other->shape;
		_tmp7__length1 = other->shape_length1;
		_tmp8_ = _tmp7_[1];
		_tmp0_ = _tmp6_ != _tmp8_;
	}
	if (_tmp0_) {
		result = FALSE;
		return result;
	}
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp9_ = FALSE;
			_tmp9_ = TRUE;
			while (TRUE) {
				gdouble* _tmp11_;
				gint _tmp11__length1;
				gint _tmp11__length2;
				gint _tmp12_;
				if (!_tmp9_) {
					gint _tmp10_;
					_tmp10_ = i;
					i = _tmp10_ + 1;
				}
				_tmp9_ = FALSE;
				_tmp11_ = self->data;
				_tmp11__length1 = self->data_length1;
				_tmp11__length2 = self->data_length2;
				_tmp12_ = _tmp11__length1;
				if (!(i < _tmp12_)) {
					break;
				}
				{
					gint j = 0;
					j = 0;
					{
						gboolean _tmp13_ = FALSE;
						_tmp13_ = TRUE;
						while (TRUE) {
							gdouble* _tmp15_;
							gint _tmp15__length1;
							gint _tmp15__length2;
							gint _tmp16_;
							gdouble* _tmp17_;
							gint _tmp17__length1;
							gint _tmp17__length2;
							gdouble _tmp18_;
							gdouble* _tmp19_;
							gint _tmp19__length1;
							gint _tmp19__length2;
							gdouble _tmp20_;
							if (!_tmp13_) {
								gint _tmp14_;
								_tmp14_ = j;
								j = _tmp14_ + 1;
							}
							_tmp13_ = FALSE;
							_tmp15_ = self->data;
							_tmp15__length1 = self->data_length1;
							_tmp15__length2 = self->data_length2;
							_tmp16_ = _tmp15__length2;
							if (!(j < _tmp16_)) {
								break;
							}
							_tmp17_ = self->data;
							_tmp17__length1 = self->data_length1;
							_tmp17__length2 = self->data_length2;
							_tmp18_ = _tmp17_[(i * _tmp17__length2) + j];
							_tmp19_ = other->data;
							_tmp19__length1 = other->data_length1;
							_tmp19__length2 = other->data_length2;
							_tmp20_ = _tmp19_[(i * _tmp19__length2) + j];
							if (fabs (_tmp18_ - _tmp20_) > DBL_EPSILON) {
								result = FALSE;
								return result;
							}
						}
					}
				}
			}
		}
	}
	result = TRUE;
	return result;
}

gboolean
ft_matrix_add (FtMatrix* self,
               FtMatrix* other)
{
	gboolean _tmp0_ = FALSE;
	guint* _tmp1_;
	gint _tmp1__length1;
	guint _tmp2_;
	guint* _tmp3_;
	gint _tmp3__length1;
	guint _tmp4_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (other != NULL, FALSE);
	_tmp1_ = other->shape;
	_tmp1__length1 = other->shape_length1;
	_tmp2_ = _tmp1_[0];
	_tmp3_ = self->shape;
	_tmp3__length1 = self->shape_length1;
	_tmp4_ = _tmp3_[0];
	if (_tmp2_ != _tmp4_) {
		_tmp0_ = TRUE;
	} else {
		guint* _tmp5_;
		gint _tmp5__length1;
		guint _tmp6_;
		guint* _tmp7_;
		gint _tmp7__length1;
		guint _tmp8_;
		_tmp5_ = other->shape;
		_tmp5__length1 = other->shape_length1;
		_tmp6_ = _tmp5_[1];
		_tmp7_ = self->shape;
		_tmp7__length1 = self->shape_length1;
		_tmp8_ = _tmp7_[1];
		_tmp0_ = _tmp6_ != _tmp8_;
	}
	if (_tmp0_) {
		result = FALSE;
		return result;
	}
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp9_ = FALSE;
			_tmp9_ = TRUE;
			while (TRUE) {
				guint* _tmp11_;
				gint _tmp11__length1;
				guint _tmp12_;
				if (!_tmp9_) {
					gint _tmp10_;
					_tmp10_ = i;
					i = _tmp10_ + 1;
				}
				_tmp9_ = FALSE;
				_tmp11_ = self->shape;
				_tmp11__length1 = self->shape_length1;
				_tmp12_ = _tmp11_[0];
				if (!(((guint) i) < _tmp12_)) {
					break;
				}
				{
					gint j = 0;
					j = 0;
					{
						gboolean _tmp13_ = FALSE;
						_tmp13_ = TRUE;
						while (TRUE) {
							guint* _tmp15_;
							gint _tmp15__length1;
							guint _tmp16_;
							gdouble* _tmp17_;
							gint _tmp17__length1;
							gint _tmp17__length2;
							gdouble* _tmp18_;
							gint _tmp18__length1;
							gint _tmp18__length2;
							gdouble _tmp19_;
							if (!_tmp13_) {
								gint _tmp14_;
								_tmp14_ = j;
								j = _tmp14_ + 1;
							}
							_tmp13_ = FALSE;
							_tmp15_ = self->shape;
							_tmp15__length1 = self->shape_length1;
							_tmp16_ = _tmp15_[1];
							if (!(((guint) j) < _tmp16_)) {
								break;
							}
							_tmp17_ = self->data;
							_tmp17__length1 = self->data_length1;
							_tmp17__length2 = self->data_length2;
							_tmp18_ = other->data;
							_tmp18__length1 = other->data_length1;
							_tmp18__length2 = other->data_length2;
							_tmp19_ = _tmp18_[(i * _tmp18__length2) + j];
							_tmp17_[(i * _tmp17__length2) + j] += _tmp19_;
						}
					}
				}
			}
		}
	}
	result = TRUE;
	return result;
}

void
ft_matrix_add_value (FtMatrix* self,
                     gint i,
                     gint j,
                     gdouble value)
{
	gboolean _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = ft_matrix_validate_indices (self, &i, &j);
	if (_tmp0_) {
		gdouble* _tmp1_;
		gint _tmp1__length1;
		gint _tmp1__length2;
		_tmp1_ = self->data;
		_tmp1__length1 = self->data_length1;
		_tmp1__length2 = self->data_length2;
		_tmp1_[(i * _tmp1__length2) + j] += value;
	} else {
		g_warning ("matrix.vala:357: Matrix indices %u, %u are out of bounds", (guint) i, (guint) j);
	}
}

inline FtVector*
ft_matrix_get_vector_internal (FtMatrix* self,
                               gint axis,
                               gint index)
{
	FtVector* result;
	g_return_val_if_fail (self != NULL, NULL);
	switch (axis) {
		case 0:
		{
			gdouble* data = NULL;
			gdouble* _tmp0_;
			gint _tmp0__length1;
			gint _tmp0__length2;
			gint _tmp1_;
			gdouble* _tmp2_;
			gint data_length1;
			gint _data_size_;
			gdouble* _tmp10_;
			gint _tmp10__length1;
			FtVector* _tmp11_;
			_tmp0_ = self->data;
			_tmp0__length1 = self->data_length1;
			_tmp0__length2 = self->data_length2;
			_tmp1_ = _tmp0__length2;
			_tmp2_ = g_new0 (gdouble, _tmp1_);
			data = _tmp2_;
			data_length1 = _tmp1_;
			_data_size_ = data_length1;
			{
				gint j = 0;
				j = 0;
				{
					gboolean _tmp3_ = FALSE;
					_tmp3_ = TRUE;
					while (TRUE) {
						gdouble* _tmp5_;
						gint _tmp5__length1;
						gint _tmp5__length2;
						gint _tmp6_;
						gdouble* _tmp7_;
						gint _tmp7__length1;
						gdouble* _tmp8_;
						gint _tmp8__length1;
						gint _tmp8__length2;
						gdouble _tmp9_;
						if (!_tmp3_) {
							gint _tmp4_;
							_tmp4_ = j;
							j = _tmp4_ + 1;
						}
						_tmp3_ = FALSE;
						_tmp5_ = self->data;
						_tmp5__length1 = self->data_length1;
						_tmp5__length2 = self->data_length2;
						_tmp6_ = _tmp5__length2;
						if (!(j < _tmp6_)) {
							break;
						}
						_tmp7_ = data;
						_tmp7__length1 = data_length1;
						_tmp8_ = self->data;
						_tmp8__length1 = self->data_length1;
						_tmp8__length2 = self->data_length2;
						_tmp9_ = _tmp8_[(index * _tmp8__length2) + j];
						_tmp7_[j] = _tmp9_;
					}
				}
			}
			_tmp10_ = data;
			_tmp10__length1 = data_length1;
			_tmp11_ = ft_vector_new_from_array (_tmp10_, _tmp10__length1);
			result = _tmp11_;
			data = (g_free (data), NULL);
			return result;
		}
		case 1:
		{
			gdouble* data = NULL;
			gdouble* _tmp12_;
			gint _tmp12__length1;
			gint _tmp12__length2;
			gint _tmp13_;
			gdouble* _tmp14_;
			gint data_length1;
			gint _data_size_;
			gdouble* _tmp22_;
			gint _tmp22__length1;
			FtVector* _tmp23_;
			_tmp12_ = self->data;
			_tmp12__length1 = self->data_length1;
			_tmp12__length2 = self->data_length2;
			_tmp13_ = _tmp12__length1;
			_tmp14_ = g_new0 (gdouble, _tmp13_);
			data = _tmp14_;
			data_length1 = _tmp13_;
			_data_size_ = data_length1;
			{
				gint i = 0;
				i = 0;
				{
					gboolean _tmp15_ = FALSE;
					_tmp15_ = TRUE;
					while (TRUE) {
						gdouble* _tmp17_;
						gint _tmp17__length1;
						gint _tmp17__length2;
						gint _tmp18_;
						gdouble* _tmp19_;
						gint _tmp19__length1;
						gdouble* _tmp20_;
						gint _tmp20__length1;
						gint _tmp20__length2;
						gdouble _tmp21_;
						if (!_tmp15_) {
							gint _tmp16_;
							_tmp16_ = i;
							i = _tmp16_ + 1;
						}
						_tmp15_ = FALSE;
						_tmp17_ = self->data;
						_tmp17__length1 = self->data_length1;
						_tmp17__length2 = self->data_length2;
						_tmp18_ = _tmp17__length1;
						if (!(i < _tmp18_)) {
							break;
						}
						_tmp19_ = data;
						_tmp19__length1 = data_length1;
						_tmp20_ = self->data;
						_tmp20__length1 = self->data_length1;
						_tmp20__length2 = self->data_length2;
						_tmp21_ = _tmp20_[(i * _tmp20__length2) + index];
						_tmp19_[i] = _tmp21_;
					}
				}
			}
			_tmp22_ = data;
			_tmp22__length1 = data_length1;
			_tmp23_ = ft_vector_new_from_array (_tmp22_, _tmp22__length1);
			result = _tmp23_;
			data = (g_free (data), NULL);
			return result;
		}
		default:
		{
			g_assert_not_reached ();
		}
	}
}

FtVector*
ft_matrix_get_vector (FtMatrix* self,
                      gint axis,
                      gint index)
{
	gboolean _tmp0_;
	FtVector* _tmp1_;
	FtVector* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = ft_matrix_validate_index (self, &axis, &index);
	if (!_tmp0_) {
		result = NULL;
		return result;
	}
	_tmp1_ = ft_matrix_get_vector_internal (self, axis, index);
	result = _tmp1_;
	return result;
}

gdouble
ft_matrix_sum (FtMatrix* self)
{
	gdouble _result_ = 0.0;
	gdouble result;
	g_return_val_if_fail (self != NULL, -1.0);
	_result_ = 0.0;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp0_ = FALSE;
			_tmp0_ = TRUE;
			while (TRUE) {
				gdouble* _tmp2_;
				gint _tmp2__length1;
				gint _tmp2__length2;
				gint _tmp3_;
				if (!_tmp0_) {
					gint _tmp1_;
					_tmp1_ = i;
					i = _tmp1_ + 1;
				}
				_tmp0_ = FALSE;
				_tmp2_ = self->data;
				_tmp2__length1 = self->data_length1;
				_tmp2__length2 = self->data_length2;
				_tmp3_ = _tmp2__length1;
				if (!(i < _tmp3_)) {
					break;
				}
				{
					gint j = 0;
					j = 0;
					{
						gboolean _tmp4_ = FALSE;
						_tmp4_ = TRUE;
						while (TRUE) {
							gdouble* _tmp6_;
							gint _tmp6__length1;
							gint _tmp6__length2;
							gint _tmp7_;
							gdouble* _tmp8_;
							gint _tmp8__length1;
							gint _tmp8__length2;
							gdouble _tmp9_;
							if (!_tmp4_) {
								gint _tmp5_;
								_tmp5_ = j;
								j = _tmp5_ + 1;
							}
							_tmp4_ = FALSE;
							_tmp6_ = self->data;
							_tmp6__length1 = self->data_length1;
							_tmp6__length2 = self->data_length2;
							_tmp7_ = _tmp6__length2;
							if (!(j < _tmp7_)) {
								break;
							}
							_tmp8_ = self->data;
							_tmp8__length1 = self->data_length1;
							_tmp8__length2 = self->data_length2;
							_tmp9_ = _tmp8_[(i * _tmp8__length2) + j];
							_result_ += _tmp9_;
						}
					}
				}
			}
		}
	}
	result = _result_;
	return result;
}

gdouble
ft_matrix_min (FtMatrix* self)
{
	gdouble _tmp0_ = 0.0;
	gboolean _tmp1_ = FALSE;
	guint* _tmp2_;
	gint _tmp2__length1;
	guint _tmp3_;
	gdouble _result_ = 0.0;
	gdouble result;
	g_return_val_if_fail (self != NULL, -1.0);
	_tmp2_ = self->shape;
	_tmp2__length1 = self->shape_length1;
	_tmp3_ = _tmp2_[0];
	if (_tmp3_ > ((guint) 0)) {
		guint* _tmp4_;
		gint _tmp4__length1;
		guint _tmp5_;
		_tmp4_ = self->shape;
		_tmp4__length1 = self->shape_length1;
		_tmp5_ = _tmp4_[1];
		_tmp1_ = _tmp5_ > ((guint) 0);
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		gdouble* _tmp6_;
		gint _tmp6__length1;
		gint _tmp6__length2;
		gdouble _tmp7_;
		_tmp6_ = self->data;
		_tmp6__length1 = self->data_length1;
		_tmp6__length2 = self->data_length2;
		_tmp7_ = _tmp6_[(0 * _tmp6__length2) + 0];
		_tmp0_ = _tmp7_;
	} else {
		_tmp0_ = ((double) NAN);
	}
	_result_ = _tmp0_;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp8_ = FALSE;
			_tmp8_ = TRUE;
			while (TRUE) {
				gdouble* _tmp10_;
				gint _tmp10__length1;
				gint _tmp10__length2;
				gint _tmp11_;
				if (!_tmp8_) {
					gint _tmp9_;
					_tmp9_ = i;
					i = _tmp9_ + 1;
				}
				_tmp8_ = FALSE;
				_tmp10_ = self->data;
				_tmp10__length1 = self->data_length1;
				_tmp10__length2 = self->data_length2;
				_tmp11_ = _tmp10__length1;
				if (!(i < _tmp11_)) {
					break;
				}
				{
					gint j = 0;
					j = 0;
					{
						gboolean _tmp12_ = FALSE;
						_tmp12_ = TRUE;
						while (TRUE) {
							gdouble* _tmp14_;
							gint _tmp14__length1;
							gint _tmp14__length2;
							gint _tmp15_;
							gdouble* _tmp16_;
							gint _tmp16__length1;
							gint _tmp16__length2;
							gdouble _tmp17_;
							if (!_tmp12_) {
								gint _tmp13_;
								_tmp13_ = j;
								j = _tmp13_ + 1;
							}
							_tmp12_ = FALSE;
							_tmp14_ = self->data;
							_tmp14__length1 = self->data_length1;
							_tmp14__length2 = self->data_length2;
							_tmp15_ = _tmp14__length2;
							if (!(j < _tmp15_)) {
								break;
							}
							_tmp16_ = self->data;
							_tmp16__length1 = self->data_length1;
							_tmp16__length2 = self->data_length2;
							_tmp17_ = _tmp16_[(i * _tmp16__length2) + j];
							if (_result_ > _tmp17_) {
								gdouble* _tmp18_;
								gint _tmp18__length1;
								gint _tmp18__length2;
								gdouble _tmp19_;
								_tmp18_ = self->data;
								_tmp18__length1 = self->data_length1;
								_tmp18__length2 = self->data_length2;
								_tmp19_ = _tmp18_[(i * _tmp18__length2) + j];
								_result_ = _tmp19_;
							}
						}
					}
				}
			}
		}
	}
	result = _result_;
	return result;
}

gdouble
ft_matrix_max (FtMatrix* self)
{
	gdouble _tmp0_ = 0.0;
	gboolean _tmp1_ = FALSE;
	guint* _tmp2_;
	gint _tmp2__length1;
	guint _tmp3_;
	gdouble _result_ = 0.0;
	gdouble result;
	g_return_val_if_fail (self != NULL, -1.0);
	_tmp2_ = self->shape;
	_tmp2__length1 = self->shape_length1;
	_tmp3_ = _tmp2_[0];
	if (_tmp3_ > ((guint) 0)) {
		guint* _tmp4_;
		gint _tmp4__length1;
		guint _tmp5_;
		_tmp4_ = self->shape;
		_tmp4__length1 = self->shape_length1;
		_tmp5_ = _tmp4_[1];
		_tmp1_ = _tmp5_ > ((guint) 0);
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		gdouble* _tmp6_;
		gint _tmp6__length1;
		gint _tmp6__length2;
		gdouble _tmp7_;
		_tmp6_ = self->data;
		_tmp6__length1 = self->data_length1;
		_tmp6__length2 = self->data_length2;
		_tmp7_ = _tmp6_[(0 * _tmp6__length2) + 0];
		_tmp0_ = _tmp7_;
	} else {
		_tmp0_ = ((double) NAN);
	}
	_result_ = _tmp0_;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp8_ = FALSE;
			_tmp8_ = TRUE;
			while (TRUE) {
				gdouble* _tmp10_;
				gint _tmp10__length1;
				gint _tmp10__length2;
				gint _tmp11_;
				if (!_tmp8_) {
					gint _tmp9_;
					_tmp9_ = i;
					i = _tmp9_ + 1;
				}
				_tmp8_ = FALSE;
				_tmp10_ = self->data;
				_tmp10__length1 = self->data_length1;
				_tmp10__length2 = self->data_length2;
				_tmp11_ = _tmp10__length1;
				if (!(i < _tmp11_)) {
					break;
				}
				{
					gint j = 0;
					j = 0;
					{
						gboolean _tmp12_ = FALSE;
						_tmp12_ = TRUE;
						while (TRUE) {
							gdouble* _tmp14_;
							gint _tmp14__length1;
							gint _tmp14__length2;
							gint _tmp15_;
							gdouble* _tmp16_;
							gint _tmp16__length1;
							gint _tmp16__length2;
							gdouble _tmp17_;
							if (!_tmp12_) {
								gint _tmp13_;
								_tmp13_ = j;
								j = _tmp13_ + 1;
							}
							_tmp12_ = FALSE;
							_tmp14_ = self->data;
							_tmp14__length1 = self->data_length1;
							_tmp14__length2 = self->data_length2;
							_tmp15_ = _tmp14__length2;
							if (!(j < _tmp15_)) {
								break;
							}
							_tmp16_ = self->data;
							_tmp16__length1 = self->data_length1;
							_tmp16__length2 = self->data_length2;
							_tmp17_ = _tmp16_[(i * _tmp16__length2) + j];
							if (_result_ < _tmp17_) {
								gdouble* _tmp18_;
								gint _tmp18__length1;
								gint _tmp18__length2;
								gdouble _tmp19_;
								_tmp18_ = self->data;
								_tmp18__length1 = self->data_length1;
								_tmp18__length2 = self->data_length2;
								_tmp19_ = _tmp18_[(i * _tmp18__length2) + j];
								_result_ = _tmp19_;
							}
						}
					}
				}
			}
		}
	}
	result = _result_;
	return result;
}

/**
         * Split an array into multiple sub-vectors along given axis.
         */
FtVector**
ft_matrix_unstack (FtMatrix* self,
                   gint axis,
                   gint* result_length1)
{
	gboolean _tmp0_;
	FtVector** _result_ = NULL;
	guint* _tmp1_;
	gint _tmp1__length1;
	guint _tmp2_;
	FtVector** _tmp3_;
	gint _result__length1;
	gint __result__size_;
	FtVector** _tmp10_;
	gint _tmp10__length1;
	FtVector** result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = ft_matrix_validate_axis (self, &axis);
	_vala_assert (_tmp0_, "this.validate_axis (ref axis)");
	_tmp1_ = self->shape;
	_tmp1__length1 = self->shape_length1;
	_tmp2_ = _tmp1_[axis];
	_tmp3_ = g_new0 (FtVector*, _tmp2_ + 1);
	_result_ = _tmp3_;
	_result__length1 = _tmp2_;
	__result__size_ = _result__length1;
	{
		gint index = 0;
		index = 0;
		{
			gboolean _tmp4_ = FALSE;
			_tmp4_ = TRUE;
			while (TRUE) {
				guint* _tmp6_;
				gint _tmp6__length1;
				guint _tmp7_;
				FtVector** _tmp8_;
				gint _tmp8__length1;
				FtVector* _tmp9_;
				if (!_tmp4_) {
					gint _tmp5_;
					_tmp5_ = index;
					index = _tmp5_ + 1;
				}
				_tmp4_ = FALSE;
				_tmp6_ = self->shape;
				_tmp6__length1 = self->shape_length1;
				_tmp7_ = _tmp6_[axis];
				if (!(((guint) index) < _tmp7_)) {
					break;
				}
				_tmp8_ = _result_;
				_tmp8__length1 = _result__length1;
				_tmp9_ = ft_matrix_get_vector_internal (self, axis, index);
				_ft_vector_free0 (_tmp8_[index]);
				_tmp8_[index] = _tmp9_;
			}
		}
	}
	_tmp10_ = _result_;
	_tmp10__length1 = _result__length1;
	if (result_length1) {
		*result_length1 = _tmp10__length1;
	}
	result = _tmp10_;
	return result;
}

gchar*
ft_matrix_to_representation (FtMatrix* self)
{
	GString* string_builder = NULL;
	GString* _tmp0_;
	GString* _tmp1_;
	GString* _tmp19_;
	GString* _tmp20_;
	const gchar* _tmp21_;
	gchar* _tmp22_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_string_new ("");
	string_builder = _tmp0_;
	_tmp1_ = string_builder;
	g_string_append (_tmp1_, "{\n");
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp2_ = FALSE;
			_tmp2_ = TRUE;
			while (TRUE) {
				gdouble* _tmp4_;
				gint _tmp4__length1;
				gint _tmp4__length2;
				gint _tmp5_;
				GString* _tmp7_;
				GString* _tmp18_;
				if (!_tmp2_) {
					gint _tmp3_;
					_tmp3_ = i;
					i = _tmp3_ + 1;
				}
				_tmp2_ = FALSE;
				_tmp4_ = self->data;
				_tmp4__length1 = self->data_length1;
				_tmp4__length2 = self->data_length2;
				_tmp5_ = _tmp4__length1;
				if (!(i < _tmp5_)) {
					break;
				}
				if (i > 0) {
					GString* _tmp6_;
					_tmp6_ = string_builder;
					g_string_append (_tmp6_, ",\n");
				}
				_tmp7_ = string_builder;
				g_string_append (_tmp7_, "    { ");
				{
					gint j = 0;
					j = 0;
					{
						gboolean _tmp8_ = FALSE;
						_tmp8_ = TRUE;
						while (TRUE) {
							gdouble* _tmp10_;
							gint _tmp10__length1;
							gint _tmp10__length2;
							gint _tmp11_;
							GString* _tmp13_;
							gdouble* _tmp14_;
							gint _tmp14__length1;
							gint _tmp14__length2;
							gdouble _tmp15_;
							gchar* _tmp16_;
							gchar* _tmp17_;
							if (!_tmp8_) {
								gint _tmp9_;
								_tmp9_ = j;
								j = _tmp9_ + 1;
							}
							_tmp8_ = FALSE;
							_tmp10_ = self->data;
							_tmp10__length1 = self->data_length1;
							_tmp10__length2 = self->data_length2;
							_tmp11_ = _tmp10__length2;
							if (!(j < _tmp11_)) {
								break;
							}
							if (j > 0) {
								GString* _tmp12_;
								_tmp12_ = string_builder;
								g_string_append (_tmp12_, ", ");
							}
							_tmp13_ = string_builder;
							_tmp14_ = self->data;
							_tmp14__length1 = self->data_length1;
							_tmp14__length2 = self->data_length2;
							_tmp15_ = _tmp14_[(i * _tmp14__length2) + j];
							_tmp16_ = g_strdup_printf ("%.3g", _tmp15_);
							_tmp17_ = _tmp16_;
							g_string_append (_tmp13_, _tmp17_);
							_g_free0 (_tmp17_);
						}
					}
				}
				_tmp18_ = string_builder;
				g_string_append (_tmp18_, " }");
			}
		}
	}
	_tmp19_ = string_builder;
	g_string_append (_tmp19_, "\n}");
	_tmp20_ = string_builder;
	_tmp21_ = _tmp20_->str;
	_tmp22_ = g_strdup (_tmp21_);
	result = _tmp22_;
	_g_string_free0 (string_builder);
	return result;
}

static void
ft_matrix_instance_init (FtMatrix * self)
{
}

void
ft_matrix_free (FtMatrix * self)
{
	self->shape = (g_free (self->shape), NULL);
	self->shape = NULL;
	self->shape_length1 = 0;
	self->data = (g_free (self->data), NULL);
	self->data = NULL;
	self->data_length1 = 0;
	self->data_length2 = 0;
	self->shape = (g_free (self->shape), NULL);
	self->data = (g_free (self->data), NULL);
	g_slice_free (FtMatrix, self);
}

FtMatrix3D*
ft_matrix3_d_new (guint shape_0,
                  guint shape_1,
                  guint shape_2)
{
	FtMatrix3D* self;
	guint* _tmp0_;
	gdouble* _tmp1_;
	self = g_slice_new0 (FtMatrix3D);
	ft_matrix3_d_instance_init (self);
	_tmp0_ = g_new0 (guint, 3);
	_tmp0_[0] = shape_0;
	_tmp0_[1] = shape_1;
	_tmp0_[2] = shape_2;
	self->shape = (g_free (self->shape), NULL);
	self->shape = _tmp0_;
	self->shape_length1 = 3;
	_tmp1_ = g_new0 (gdouble, (shape_0 * shape_1) * shape_2);
	self->data = (g_free (self->data), NULL);
	self->data = _tmp1_;
	self->data_length1 = shape_0;
	self->data_length2 = shape_1;
	self->data_length3 = shape_2;
	return self;
}

static gdouble*
_vala_array_dup16 (gdouble* self,
                   gssize length)
{
	if (length > 0) {
		return _vala_memdup2 (self, length * sizeof (gdouble));
	}
	return NULL;
}

FtMatrix3D*
ft_matrix3_d_new_from_array (gdouble* array,
                             gint array_length1,
                             gint array_length2,
                             gint array_length3)
{
	FtMatrix3D* self;
	gint _tmp0_;
	gint _tmp1_;
	gint _tmp2_;
	guint* _tmp3_;
	gdouble* _tmp4_;
	gint _tmp4__length1;
	gint _tmp4__length2;
	gint _tmp4__length3;
	self = g_slice_new0 (FtMatrix3D);
	ft_matrix3_d_instance_init (self);
	_tmp0_ = array_length1;
	_tmp1_ = array_length2;
	_tmp2_ = array_length3;
	_tmp3_ = g_new0 (guint, 3);
	_tmp3_[0] = (guint) _tmp0_;
	_tmp3_[1] = (guint) _tmp1_;
	_tmp3_[2] = (guint) _tmp2_;
	self->shape = (g_free (self->shape), NULL);
	self->shape = _tmp3_;
	self->shape_length1 = 3;
	_tmp4_ = (array != NULL) ? _vala_array_dup16 (array, (array_length1 * array_length2) * array_length3) : array;
	_tmp4__length1 = array_length1;
	_tmp4__length2 = array_length2;
	_tmp4__length3 = array_length3;
	self->data = (g_free (self->data), NULL);
	self->data = _tmp4_;
	self->data_length1 = _tmp4__length1;
	self->data_length2 = _tmp4__length2;
	self->data_length3 = _tmp4__length3;
	return self;
}

static inline gboolean
ft_matrix3_d_validate_axis (FtMatrix3D* self,
                            gint* axis)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	if ((*axis) < 0) {
		*axis = FT_MATRIX3_D_DIMENSIONS + (*axis);
	}
	result = (*axis) < FT_MATRIX3_D_DIMENSIONS;
	return result;
}

static inline gboolean
ft_matrix3_d_validate_indices (FtMatrix3D* self,
                               gint* i,
                               gint* j,
                               gint* k)
{
	gboolean _tmp6_ = FALSE;
	gboolean _tmp7_ = FALSE;
	gdouble* _tmp8_;
	gint _tmp8__length1;
	gint _tmp8__length2;
	gint _tmp8__length3;
	gint _tmp9_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	if ((*i) < 0) {
		gdouble* _tmp0_;
		gint _tmp0__length1;
		gint _tmp0__length2;
		gint _tmp0__length3;
		gint _tmp1_;
		_tmp0_ = self->data;
		_tmp0__length1 = self->data_length1;
		_tmp0__length2 = self->data_length2;
		_tmp0__length3 = self->data_length3;
		_tmp1_ = _tmp0__length1;
		*i = _tmp1_ + (*i);
	}
	if ((*j) < 0) {
		gdouble* _tmp2_;
		gint _tmp2__length1;
		gint _tmp2__length2;
		gint _tmp2__length3;
		gint _tmp3_;
		_tmp2_ = self->data;
		_tmp2__length1 = self->data_length1;
		_tmp2__length2 = self->data_length2;
		_tmp2__length3 = self->data_length3;
		_tmp3_ = _tmp2__length2;
		*j = _tmp3_ + (*j);
	}
	if ((*k) < 0) {
		gdouble* _tmp4_;
		gint _tmp4__length1;
		gint _tmp4__length2;
		gint _tmp4__length3;
		gint _tmp5_;
		_tmp4_ = self->data;
		_tmp4__length1 = self->data_length1;
		_tmp4__length2 = self->data_length2;
		_tmp4__length3 = self->data_length3;
		_tmp5_ = _tmp4__length3;
		*k = _tmp5_ + (*k);
	}
	_tmp8_ = self->data;
	_tmp8__length1 = self->data_length1;
	_tmp8__length2 = self->data_length2;
	_tmp8__length3 = self->data_length3;
	_tmp9_ = _tmp8__length1;
	if ((*i) < _tmp9_) {
		gdouble* _tmp10_;
		gint _tmp10__length1;
		gint _tmp10__length2;
		gint _tmp10__length3;
		gint _tmp11_;
		_tmp10_ = self->data;
		_tmp10__length1 = self->data_length1;
		_tmp10__length2 = self->data_length2;
		_tmp10__length3 = self->data_length3;
		_tmp11_ = _tmp10__length2;
		_tmp7_ = (*j) < _tmp11_;
	} else {
		_tmp7_ = FALSE;
	}
	if (_tmp7_) {
		gdouble* _tmp12_;
		gint _tmp12__length1;
		gint _tmp12__length2;
		gint _tmp12__length3;
		gint _tmp13_;
		_tmp12_ = self->data;
		_tmp12__length1 = self->data_length1;
		_tmp12__length2 = self->data_length2;
		_tmp12__length3 = self->data_length3;
		_tmp13_ = _tmp12__length3;
		_tmp6_ = (*k) < _tmp13_;
	} else {
		_tmp6_ = FALSE;
	}
	result = _tmp6_;
	return result;
}

static inline gboolean
ft_matrix3_d_validate_index (FtMatrix3D* self,
                             gint* axis,
                             gint* index)
{
	gboolean _tmp0_;
	guint* _tmp3_;
	gint _tmp3__length1;
	guint _tmp4_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = ft_matrix3_d_validate_axis (self, axis);
	if (!_tmp0_) {
		result = FALSE;
		return result;
	}
	if ((*index) < 0) {
		guint* _tmp1_;
		gint _tmp1__length1;
		guint _tmp2_;
		_tmp1_ = self->shape;
		_tmp1__length1 = self->shape_length1;
		_tmp2_ = _tmp1_[*axis];
		*index = ((gint) _tmp2_) + (*index);
	}
	_tmp3_ = self->shape;
	_tmp3__length1 = self->shape_length1;
	_tmp4_ = _tmp3_[*axis];
	result = (*index) < ((gint) _tmp4_);
	return result;
}

static gdouble*
_vala_array_dup17 (gdouble* self,
                   gssize length)
{
	if (length > 0) {
		return _vala_memdup2 (self, length * sizeof (gdouble));
	}
	return NULL;
}

void
ft_matrix3_d_resize (FtMatrix3D* self,
                     guint shape_0,
                     guint shape_1,
                     guint shape_2,
                     gdouble default_value)
{
	guint intersect_0 = 0U;
	guint* _tmp0_;
	gint _tmp0__length1;
	guint _tmp1_;
	guint intersect_1 = 0U;
	guint* _tmp2_;
	gint _tmp2__length1;
	guint _tmp3_;
	guint intersect_2 = 0U;
	guint* _tmp4_;
	gint _tmp4__length1;
	guint _tmp5_;
	gdouble* data = NULL;
	gdouble* _tmp6_;
	gint data_length1;
	gint data_length2;
	gint data_length3;
	gdouble* _tmp23_;
	gint _tmp23__length1;
	gint _tmp23__length2;
	gint _tmp23__length3;
	gdouble* _tmp24_;
	gint _tmp24__length1;
	gint _tmp24__length2;
	gint _tmp24__length3;
	guint* _tmp25_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->shape;
	_tmp0__length1 = self->shape_length1;
	_tmp1_ = _tmp0_[0];
	intersect_0 = MIN (shape_0, _tmp1_);
	_tmp2_ = self->shape;
	_tmp2__length1 = self->shape_length1;
	_tmp3_ = _tmp2_[1];
	intersect_1 = MIN (shape_1, _tmp3_);
	_tmp4_ = self->shape;
	_tmp4__length1 = self->shape_length1;
	_tmp5_ = _tmp4_[2];
	intersect_2 = MIN (shape_2, _tmp5_);
	_tmp6_ = g_new0 (gdouble, (shape_0 * shape_1) * shape_2);
	data = _tmp6_;
	data_length1 = shape_0;
	data_length2 = shape_1;
	data_length3 = shape_2;
	if (default_value != 0.0) {
		{
			gint i = 0;
			i = 0;
			{
				gboolean _tmp7_ = FALSE;
				_tmp7_ = TRUE;
				while (TRUE) {
					if (!_tmp7_) {
						gint _tmp8_;
						_tmp8_ = i;
						i = _tmp8_ + 1;
					}
					_tmp7_ = FALSE;
					if (!(((guint) i) < shape_0)) {
						break;
					}
					{
						gint j = 0;
						j = 0;
						{
							gboolean _tmp9_ = FALSE;
							_tmp9_ = TRUE;
							while (TRUE) {
								if (!_tmp9_) {
									gint _tmp10_;
									_tmp10_ = j;
									j = _tmp10_ + 1;
								}
								_tmp9_ = FALSE;
								if (!(((guint) j) < shape_1)) {
									break;
								}
								{
									gint k = 0;
									k = 0;
									{
										gboolean _tmp11_ = FALSE;
										_tmp11_ = TRUE;
										while (TRUE) {
											gdouble* _tmp13_;
											gint _tmp13__length1;
											gint _tmp13__length2;
											gint _tmp13__length3;
											if (!_tmp11_) {
												gint _tmp12_;
												_tmp12_ = k;
												k = _tmp12_ + 1;
											}
											_tmp11_ = FALSE;
											if (!(((guint) k) < shape_2)) {
												break;
											}
											_tmp13_ = data;
											_tmp13__length1 = data_length1;
											_tmp13__length2 = data_length2;
											_tmp13__length3 = data_length3;
											_tmp13_[(((i * _tmp13__length2) + j) * _tmp13__length3) + k] = default_value;
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp14_ = FALSE;
			_tmp14_ = TRUE;
			while (TRUE) {
				if (!_tmp14_) {
					gint _tmp15_;
					_tmp15_ = i;
					i = _tmp15_ + 1;
				}
				_tmp14_ = FALSE;
				if (!(((guint) i) < intersect_0)) {
					break;
				}
				{
					gint j = 0;
					j = 0;
					{
						gboolean _tmp16_ = FALSE;
						_tmp16_ = TRUE;
						while (TRUE) {
							if (!_tmp16_) {
								gint _tmp17_;
								_tmp17_ = j;
								j = _tmp17_ + 1;
							}
							_tmp16_ = FALSE;
							if (!(((guint) j) < intersect_1)) {
								break;
							}
							{
								gint k = 0;
								k = 0;
								{
									gboolean _tmp18_ = FALSE;
									_tmp18_ = TRUE;
									while (TRUE) {
										gdouble* _tmp20_;
										gint _tmp20__length1;
										gint _tmp20__length2;
										gint _tmp20__length3;
										gdouble* _tmp21_;
										gint _tmp21__length1;
										gint _tmp21__length2;
										gint _tmp21__length3;
										gdouble _tmp22_;
										if (!_tmp18_) {
											gint _tmp19_;
											_tmp19_ = k;
											k = _tmp19_ + 1;
										}
										_tmp18_ = FALSE;
										if (!(((guint) k) < intersect_2)) {
											break;
										}
										_tmp20_ = data;
										_tmp20__length1 = data_length1;
										_tmp20__length2 = data_length2;
										_tmp20__length3 = data_length3;
										_tmp21_ = self->data;
										_tmp21__length1 = self->data_length1;
										_tmp21__length2 = self->data_length2;
										_tmp21__length3 = self->data_length3;
										_tmp22_ = _tmp21_[(((i * _tmp21__length2) + j) * _tmp21__length3) + k];
										_tmp20_[(((i * _tmp20__length2) + j) * _tmp20__length3) + k] = _tmp22_;
									}
								}
							}
						}
					}
				}
			}
		}
	}
	_tmp23_ = data;
	_tmp23__length1 = data_length1;
	_tmp23__length2 = data_length2;
	_tmp23__length3 = data_length3;
	_tmp24_ = (_tmp23_ != NULL) ? _vala_array_dup17 (_tmp23_, (_tmp23__length1 * _tmp23__length2) * _tmp23__length3) : _tmp23_;
	_tmp24__length1 = _tmp23__length1;
	_tmp24__length2 = _tmp23__length2;
	_tmp24__length3 = _tmp23__length3;
	self->data = (g_free (self->data), NULL);
	self->data = _tmp24_;
	self->data_length1 = _tmp24__length1;
	self->data_length2 = _tmp24__length2;
	self->data_length3 = _tmp24__length3;
	_tmp25_ = g_new0 (guint, 3);
	_tmp25_[0] = shape_0;
	_tmp25_[1] = shape_1;
	_tmp25_[2] = shape_2;
	self->shape = (g_free (self->shape), NULL);
	self->shape = _tmp25_;
	self->shape_length1 = 3;
	data = (g_free (data), NULL);
}

gdouble
ft_matrix3_d_get (FtMatrix3D* self,
                  gint i,
                  gint j,
                  gint k,
                  gdouble default_value)
{
	gdouble _tmp0_ = 0.0;
	gboolean _tmp1_;
	gdouble result;
	g_return_val_if_fail (self != NULL, -1.0);
	_tmp1_ = ft_matrix3_d_validate_indices (self, &i, &j, &k);
	if (_tmp1_) {
		gdouble* _tmp2_;
		gint _tmp2__length1;
		gint _tmp2__length2;
		gint _tmp2__length3;
		gdouble _tmp3_;
		_tmp2_ = self->data;
		_tmp2__length1 = self->data_length1;
		_tmp2__length2 = self->data_length2;
		_tmp2__length3 = self->data_length3;
		_tmp3_ = _tmp2_[(((i * _tmp2__length2) + j) * _tmp2__length3) + k];
		_tmp0_ = _tmp3_;
	} else {
		_tmp0_ = default_value;
	}
	result = _tmp0_;
	return result;
}

void
ft_matrix3_d_set (FtMatrix3D* self,
                  gint i,
                  gint j,
                  gint k,
                  gdouble value)
{
	gboolean _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = ft_matrix3_d_validate_indices (self, &i, &j, &k);
	if (_tmp0_) {
		gdouble* _tmp1_;
		gint _tmp1__length1;
		gint _tmp1__length2;
		gint _tmp1__length3;
		_tmp1_ = self->data;
		_tmp1__length1 = self->data_length1;
		_tmp1__length2 = self->data_length2;
		_tmp1__length3 = self->data_length3;
		_tmp1_[(((i * _tmp1__length2) + j) * _tmp1__length3) + k] = value;
	} else {
		g_warning ("matrix.vala:635: Matrix indices %u, %u, %u are out of bounds", (guint) i, (guint) j, (guint) k);
	}
}

void
ft_matrix3_d_fill (FtMatrix3D* self,
                   gdouble value)
{
	g_return_if_fail (self != NULL);
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp0_ = FALSE;
			_tmp0_ = TRUE;
			while (TRUE) {
				guint* _tmp2_;
				gint _tmp2__length1;
				guint _tmp3_;
				if (!_tmp0_) {
					gint _tmp1_;
					_tmp1_ = i;
					i = _tmp1_ + 1;
				}
				_tmp0_ = FALSE;
				_tmp2_ = self->shape;
				_tmp2__length1 = self->shape_length1;
				_tmp3_ = _tmp2_[0];
				if (!(((guint) i) < _tmp3_)) {
					break;
				}
				{
					gint j = 0;
					j = 0;
					{
						gboolean _tmp4_ = FALSE;
						_tmp4_ = TRUE;
						while (TRUE) {
							guint* _tmp6_;
							gint _tmp6__length1;
							guint _tmp7_;
							if (!_tmp4_) {
								gint _tmp5_;
								_tmp5_ = j;
								j = _tmp5_ + 1;
							}
							_tmp4_ = FALSE;
							_tmp6_ = self->shape;
							_tmp6__length1 = self->shape_length1;
							_tmp7_ = _tmp6_[1];
							if (!(((guint) j) < _tmp7_)) {
								break;
							}
							{
								gint k = 0;
								k = 0;
								{
									gboolean _tmp8_ = FALSE;
									_tmp8_ = TRUE;
									while (TRUE) {
										guint* _tmp10_;
										gint _tmp10__length1;
										guint _tmp11_;
										gdouble* _tmp12_;
										gint _tmp12__length1;
										gint _tmp12__length2;
										gint _tmp12__length3;
										if (!_tmp8_) {
											gint _tmp9_;
											_tmp9_ = k;
											k = _tmp9_ + 1;
										}
										_tmp8_ = FALSE;
										_tmp10_ = self->shape;
										_tmp10__length1 = self->shape_length1;
										_tmp11_ = _tmp10_[2];
										if (!(((guint) k) < _tmp11_)) {
											break;
										}
										_tmp12_ = self->data;
										_tmp12__length1 = self->data_length1;
										_tmp12__length2 = self->data_length2;
										_tmp12__length3 = self->data_length3;
										_tmp12_[(((i * _tmp12__length2) + j) * _tmp12__length3) + k] = value;
									}
								}
							}
						}
					}
				}
			}
		}
	}
}

gboolean
ft_matrix3_d_equals (FtMatrix3D* self,
                     FtMatrix3D* other)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	guint* _tmp2_;
	gint _tmp2__length1;
	guint _tmp3_;
	guint* _tmp4_;
	gint _tmp4__length1;
	guint _tmp5_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (other != NULL, FALSE);
	_tmp2_ = self->shape;
	_tmp2__length1 = self->shape_length1;
	_tmp3_ = _tmp2_[0];
	_tmp4_ = other->shape;
	_tmp4__length1 = other->shape_length1;
	_tmp5_ = _tmp4_[0];
	if (_tmp3_ != _tmp5_) {
		_tmp1_ = TRUE;
	} else {
		guint* _tmp6_;
		gint _tmp6__length1;
		guint _tmp7_;
		guint* _tmp8_;
		gint _tmp8__length1;
		guint _tmp9_;
		_tmp6_ = self->shape;
		_tmp6__length1 = self->shape_length1;
		_tmp7_ = _tmp6_[1];
		_tmp8_ = other->shape;
		_tmp8__length1 = other->shape_length1;
		_tmp9_ = _tmp8_[1];
		_tmp1_ = _tmp7_ != _tmp9_;
	}
	if (_tmp1_) {
		_tmp0_ = TRUE;
	} else {
		guint* _tmp10_;
		gint _tmp10__length1;
		guint _tmp11_;
		guint* _tmp12_;
		gint _tmp12__length1;
		guint _tmp13_;
		_tmp10_ = self->shape;
		_tmp10__length1 = self->shape_length1;
		_tmp11_ = _tmp10_[2];
		_tmp12_ = other->shape;
		_tmp12__length1 = other->shape_length1;
		_tmp13_ = _tmp12_[2];
		_tmp0_ = _tmp11_ != _tmp13_;
	}
	if (_tmp0_) {
		result = FALSE;
		return result;
	}
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp14_ = FALSE;
			_tmp14_ = TRUE;
			while (TRUE) {
				gdouble* _tmp16_;
				gint _tmp16__length1;
				gint _tmp16__length2;
				gint _tmp16__length3;
				gint _tmp17_;
				if (!_tmp14_) {
					gint _tmp15_;
					_tmp15_ = i;
					i = _tmp15_ + 1;
				}
				_tmp14_ = FALSE;
				_tmp16_ = self->data;
				_tmp16__length1 = self->data_length1;
				_tmp16__length2 = self->data_length2;
				_tmp16__length3 = self->data_length3;
				_tmp17_ = _tmp16__length1;
				if (!(i < _tmp17_)) {
					break;
				}
				{
					gint j = 0;
					j = 0;
					{
						gboolean _tmp18_ = FALSE;
						_tmp18_ = TRUE;
						while (TRUE) {
							gdouble* _tmp20_;
							gint _tmp20__length1;
							gint _tmp20__length2;
							gint _tmp20__length3;
							gint _tmp21_;
							if (!_tmp18_) {
								gint _tmp19_;
								_tmp19_ = j;
								j = _tmp19_ + 1;
							}
							_tmp18_ = FALSE;
							_tmp20_ = self->data;
							_tmp20__length1 = self->data_length1;
							_tmp20__length2 = self->data_length2;
							_tmp20__length3 = self->data_length3;
							_tmp21_ = _tmp20__length2;
							if (!(j < _tmp21_)) {
								break;
							}
							{
								gint k = 0;
								k = 0;
								{
									gboolean _tmp22_ = FALSE;
									_tmp22_ = TRUE;
									while (TRUE) {
										gdouble* _tmp24_;
										gint _tmp24__length1;
										gint _tmp24__length2;
										gint _tmp24__length3;
										gint _tmp25_;
										gdouble* _tmp26_;
										gint _tmp26__length1;
										gint _tmp26__length2;
										gint _tmp26__length3;
										gdouble _tmp27_;
										gdouble* _tmp28_;
										gint _tmp28__length1;
										gint _tmp28__length2;
										gint _tmp28__length3;
										gdouble _tmp29_;
										if (!_tmp22_) {
											gint _tmp23_;
											_tmp23_ = k;
											k = _tmp23_ + 1;
										}
										_tmp22_ = FALSE;
										_tmp24_ = self->data;
										_tmp24__length1 = self->data_length1;
										_tmp24__length2 = self->data_length2;
										_tmp24__length3 = self->data_length3;
										_tmp25_ = _tmp24__length3;
										if (!(k < _tmp25_)) {
											break;
										}
										_tmp26_ = self->data;
										_tmp26__length1 = self->data_length1;
										_tmp26__length2 = self->data_length2;
										_tmp26__length3 = self->data_length3;
										_tmp27_ = _tmp26_[(((i * _tmp26__length2) + j) * _tmp26__length3) + k];
										_tmp28_ = other->data;
										_tmp28__length1 = other->data_length1;
										_tmp28__length2 = other->data_length2;
										_tmp28__length3 = other->data_length3;
										_tmp29_ = _tmp28_[(((i * _tmp28__length2) + j) * _tmp28__length3) + k];
										if (fabs (_tmp27_ - _tmp29_) > DBL_EPSILON) {
											result = FALSE;
											return result;
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}
	result = TRUE;
	return result;
}

inline FtMatrix*
ft_matrix3_d_get_matrix_internal (FtMatrix3D* self,
                                  gint axis,
                                  gint index)
{
	FtMatrix* result;
	g_return_val_if_fail (self != NULL, NULL);
	switch (axis) {
		case 0:
		{
			gdouble* data = NULL;
			gdouble* _tmp0_;
			gint _tmp0__length1;
			gint _tmp0__length2;
			gint _tmp0__length3;
			gint _tmp1_;
			gdouble* _tmp2_;
			gint _tmp2__length1;
			gint _tmp2__length2;
			gint _tmp2__length3;
			gint _tmp3_;
			gdouble* _tmp4_;
			gint data_length1;
			gint data_length2;
			gdouble* _tmp16_;
			gint _tmp16__length1;
			gint _tmp16__length2;
			FtMatrix* _tmp17_;
			_tmp0_ = self->data;
			_tmp0__length1 = self->data_length1;
			_tmp0__length2 = self->data_length2;
			_tmp0__length3 = self->data_length3;
			_tmp1_ = _tmp0__length2;
			_tmp2_ = self->data;
			_tmp2__length1 = self->data_length1;
			_tmp2__length2 = self->data_length2;
			_tmp2__length3 = self->data_length3;
			_tmp3_ = _tmp2__length3;
			_tmp4_ = g_new0 (gdouble, _tmp1_ * _tmp3_);
			data = _tmp4_;
			data_length1 = _tmp1_;
			data_length2 = _tmp3_;
			{
				gint j = 0;
				j = 0;
				{
					gboolean _tmp5_ = FALSE;
					_tmp5_ = TRUE;
					while (TRUE) {
						gdouble* _tmp7_;
						gint _tmp7__length1;
						gint _tmp7__length2;
						gint _tmp7__length3;
						gint _tmp8_;
						if (!_tmp5_) {
							gint _tmp6_;
							_tmp6_ = j;
							j = _tmp6_ + 1;
						}
						_tmp5_ = FALSE;
						_tmp7_ = self->data;
						_tmp7__length1 = self->data_length1;
						_tmp7__length2 = self->data_length2;
						_tmp7__length3 = self->data_length3;
						_tmp8_ = _tmp7__length2;
						if (!(j < _tmp8_)) {
							break;
						}
						{
							gint k = 0;
							k = 0;
							{
								gboolean _tmp9_ = FALSE;
								_tmp9_ = TRUE;
								while (TRUE) {
									gdouble* _tmp11_;
									gint _tmp11__length1;
									gint _tmp11__length2;
									gint _tmp11__length3;
									gint _tmp12_;
									gdouble* _tmp13_;
									gint _tmp13__length1;
									gint _tmp13__length2;
									gdouble* _tmp14_;
									gint _tmp14__length1;
									gint _tmp14__length2;
									gint _tmp14__length3;
									gdouble _tmp15_;
									if (!_tmp9_) {
										gint _tmp10_;
										_tmp10_ = k;
										k = _tmp10_ + 1;
									}
									_tmp9_ = FALSE;
									_tmp11_ = self->data;
									_tmp11__length1 = self->data_length1;
									_tmp11__length2 = self->data_length2;
									_tmp11__length3 = self->data_length3;
									_tmp12_ = _tmp11__length3;
									if (!(k < _tmp12_)) {
										break;
									}
									_tmp13_ = data;
									_tmp13__length1 = data_length1;
									_tmp13__length2 = data_length2;
									_tmp14_ = self->data;
									_tmp14__length1 = self->data_length1;
									_tmp14__length2 = self->data_length2;
									_tmp14__length3 = self->data_length3;
									_tmp15_ = _tmp14_[(((index * _tmp14__length2) + j) * _tmp14__length3) + k];
									_tmp13_[(j * _tmp13__length2) + k] = _tmp15_;
								}
							}
						}
					}
				}
			}
			_tmp16_ = data;
			_tmp16__length1 = data_length1;
			_tmp16__length2 = data_length2;
			_tmp17_ = ft_matrix_new_from_array (_tmp16_, _tmp16__length1, _tmp16__length2);
			result = _tmp17_;
			data = (g_free (data), NULL);
			return result;
		}
		case 1:
		{
			gdouble* data = NULL;
			gdouble* _tmp18_;
			gint _tmp18__length1;
			gint _tmp18__length2;
			gint _tmp18__length3;
			gint _tmp19_;
			gdouble* _tmp20_;
			gint _tmp20__length1;
			gint _tmp20__length2;
			gint _tmp20__length3;
			gint _tmp21_;
			gdouble* _tmp22_;
			gint data_length1;
			gint data_length2;
			gdouble* _tmp34_;
			gint _tmp34__length1;
			gint _tmp34__length2;
			FtMatrix* _tmp35_;
			_tmp18_ = self->data;
			_tmp18__length1 = self->data_length1;
			_tmp18__length2 = self->data_length2;
			_tmp18__length3 = self->data_length3;
			_tmp19_ = _tmp18__length1;
			_tmp20_ = self->data;
			_tmp20__length1 = self->data_length1;
			_tmp20__length2 = self->data_length2;
			_tmp20__length3 = self->data_length3;
			_tmp21_ = _tmp20__length3;
			_tmp22_ = g_new0 (gdouble, _tmp19_ * _tmp21_);
			data = _tmp22_;
			data_length1 = _tmp19_;
			data_length2 = _tmp21_;
			{
				gint i = 0;
				i = 0;
				{
					gboolean _tmp23_ = FALSE;
					_tmp23_ = TRUE;
					while (TRUE) {
						gdouble* _tmp25_;
						gint _tmp25__length1;
						gint _tmp25__length2;
						gint _tmp25__length3;
						gint _tmp26_;
						if (!_tmp23_) {
							gint _tmp24_;
							_tmp24_ = i;
							i = _tmp24_ + 1;
						}
						_tmp23_ = FALSE;
						_tmp25_ = self->data;
						_tmp25__length1 = self->data_length1;
						_tmp25__length2 = self->data_length2;
						_tmp25__length3 = self->data_length3;
						_tmp26_ = _tmp25__length1;
						if (!(i < _tmp26_)) {
							break;
						}
						{
							gint k = 0;
							k = 0;
							{
								gboolean _tmp27_ = FALSE;
								_tmp27_ = TRUE;
								while (TRUE) {
									gdouble* _tmp29_;
									gint _tmp29__length1;
									gint _tmp29__length2;
									gint _tmp29__length3;
									gint _tmp30_;
									gdouble* _tmp31_;
									gint _tmp31__length1;
									gint _tmp31__length2;
									gdouble* _tmp32_;
									gint _tmp32__length1;
									gint _tmp32__length2;
									gint _tmp32__length3;
									gdouble _tmp33_;
									if (!_tmp27_) {
										gint _tmp28_;
										_tmp28_ = k;
										k = _tmp28_ + 1;
									}
									_tmp27_ = FALSE;
									_tmp29_ = self->data;
									_tmp29__length1 = self->data_length1;
									_tmp29__length2 = self->data_length2;
									_tmp29__length3 = self->data_length3;
									_tmp30_ = _tmp29__length3;
									if (!(k < _tmp30_)) {
										break;
									}
									_tmp31_ = data;
									_tmp31__length1 = data_length1;
									_tmp31__length2 = data_length2;
									_tmp32_ = self->data;
									_tmp32__length1 = self->data_length1;
									_tmp32__length2 = self->data_length2;
									_tmp32__length3 = self->data_length3;
									_tmp33_ = _tmp32_[(((i * _tmp32__length2) + index) * _tmp32__length3) + k];
									_tmp31_[(i * _tmp31__length2) + k] = _tmp33_;
								}
							}
						}
					}
				}
			}
			_tmp34_ = data;
			_tmp34__length1 = data_length1;
			_tmp34__length2 = data_length2;
			_tmp35_ = ft_matrix_new_from_array (_tmp34_, _tmp34__length1, _tmp34__length2);
			result = _tmp35_;
			data = (g_free (data), NULL);
			return result;
		}
		case 2:
		{
			gdouble* data = NULL;
			gdouble* _tmp36_;
			gint _tmp36__length1;
			gint _tmp36__length2;
			gint _tmp36__length3;
			gint _tmp37_;
			gdouble* _tmp38_;
			gint _tmp38__length1;
			gint _tmp38__length2;
			gint _tmp38__length3;
			gint _tmp39_;
			gdouble* _tmp40_;
			gint data_length1;
			gint data_length2;
			gdouble* _tmp52_;
			gint _tmp52__length1;
			gint _tmp52__length2;
			FtMatrix* _tmp53_;
			_tmp36_ = self->data;
			_tmp36__length1 = self->data_length1;
			_tmp36__length2 = self->data_length2;
			_tmp36__length3 = self->data_length3;
			_tmp37_ = _tmp36__length1;
			_tmp38_ = self->data;
			_tmp38__length1 = self->data_length1;
			_tmp38__length2 = self->data_length2;
			_tmp38__length3 = self->data_length3;
			_tmp39_ = _tmp38__length2;
			_tmp40_ = g_new0 (gdouble, _tmp37_ * _tmp39_);
			data = _tmp40_;
			data_length1 = _tmp37_;
			data_length2 = _tmp39_;
			{
				gint i = 0;
				i = 0;
				{
					gboolean _tmp41_ = FALSE;
					_tmp41_ = TRUE;
					while (TRUE) {
						gdouble* _tmp43_;
						gint _tmp43__length1;
						gint _tmp43__length2;
						gint _tmp43__length3;
						gint _tmp44_;
						if (!_tmp41_) {
							gint _tmp42_;
							_tmp42_ = i;
							i = _tmp42_ + 1;
						}
						_tmp41_ = FALSE;
						_tmp43_ = self->data;
						_tmp43__length1 = self->data_length1;
						_tmp43__length2 = self->data_length2;
						_tmp43__length3 = self->data_length3;
						_tmp44_ = _tmp43__length1;
						if (!(i < _tmp44_)) {
							break;
						}
						{
							gint j = 0;
							j = 0;
							{
								gboolean _tmp45_ = FALSE;
								_tmp45_ = TRUE;
								while (TRUE) {
									gdouble* _tmp47_;
									gint _tmp47__length1;
									gint _tmp47__length2;
									gint _tmp47__length3;
									gint _tmp48_;
									gdouble* _tmp49_;
									gint _tmp49__length1;
									gint _tmp49__length2;
									gdouble* _tmp50_;
									gint _tmp50__length1;
									gint _tmp50__length2;
									gint _tmp50__length3;
									gdouble _tmp51_;
									if (!_tmp45_) {
										gint _tmp46_;
										_tmp46_ = j;
										j = _tmp46_ + 1;
									}
									_tmp45_ = FALSE;
									_tmp47_ = self->data;
									_tmp47__length1 = self->data_length1;
									_tmp47__length2 = self->data_length2;
									_tmp47__length3 = self->data_length3;
									_tmp48_ = _tmp47__length2;
									if (!(j < _tmp48_)) {
										break;
									}
									_tmp49_ = data;
									_tmp49__length1 = data_length1;
									_tmp49__length2 = data_length2;
									_tmp50_ = self->data;
									_tmp50__length1 = self->data_length1;
									_tmp50__length2 = self->data_length2;
									_tmp50__length3 = self->data_length3;
									_tmp51_ = _tmp50_[(((i * _tmp50__length2) + j) * _tmp50__length3) + index];
									_tmp49_[(i * _tmp49__length2) + j] = _tmp51_;
								}
							}
						}
					}
				}
			}
			_tmp52_ = data;
			_tmp52__length1 = data_length1;
			_tmp52__length2 = data_length2;
			_tmp53_ = ft_matrix_new_from_array (_tmp52_, _tmp52__length1, _tmp52__length2);
			result = _tmp53_;
			data = (g_free (data), NULL);
			return result;
		}
		default:
		{
			g_assert_not_reached ();
		}
	}
}

FtMatrix*
ft_matrix3_d_get_matrix (FtMatrix3D* self,
                         gint axis,
                         gint index)
{
	gboolean _tmp0_;
	FtMatrix* _tmp1_;
	FtMatrix* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = ft_matrix3_d_validate_index (self, &axis, &index);
	if (!_tmp0_) {
		result = NULL;
		return result;
	}
	_tmp1_ = ft_matrix3_d_get_matrix_internal (self, axis, index);
	result = _tmp1_;
	return result;
}

gdouble
ft_matrix3_d_sum (FtMatrix3D* self)
{
	gdouble _result_ = 0.0;
	gdouble result;
	g_return_val_if_fail (self != NULL, -1.0);
	_result_ = 0.0;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp0_ = FALSE;
			_tmp0_ = TRUE;
			while (TRUE) {
				gdouble* _tmp2_;
				gint _tmp2__length1;
				gint _tmp2__length2;
				gint _tmp2__length3;
				gint _tmp3_;
				if (!_tmp0_) {
					gint _tmp1_;
					_tmp1_ = i;
					i = _tmp1_ + 1;
				}
				_tmp0_ = FALSE;
				_tmp2_ = self->data;
				_tmp2__length1 = self->data_length1;
				_tmp2__length2 = self->data_length2;
				_tmp2__length3 = self->data_length3;
				_tmp3_ = _tmp2__length1;
				if (!(i < _tmp3_)) {
					break;
				}
				{
					gint j = 0;
					j = 0;
					{
						gboolean _tmp4_ = FALSE;
						_tmp4_ = TRUE;
						while (TRUE) {
							gdouble* _tmp6_;
							gint _tmp6__length1;
							gint _tmp6__length2;
							gint _tmp6__length3;
							gint _tmp7_;
							if (!_tmp4_) {
								gint _tmp5_;
								_tmp5_ = j;
								j = _tmp5_ + 1;
							}
							_tmp4_ = FALSE;
							_tmp6_ = self->data;
							_tmp6__length1 = self->data_length1;
							_tmp6__length2 = self->data_length2;
							_tmp6__length3 = self->data_length3;
							_tmp7_ = _tmp6__length2;
							if (!(j < _tmp7_)) {
								break;
							}
							{
								gint k = 0;
								k = 0;
								{
									gboolean _tmp8_ = FALSE;
									_tmp8_ = TRUE;
									while (TRUE) {
										gdouble* _tmp10_;
										gint _tmp10__length1;
										gint _tmp10__length2;
										gint _tmp10__length3;
										gint _tmp11_;
										gdouble* _tmp12_;
										gint _tmp12__length1;
										gint _tmp12__length2;
										gint _tmp12__length3;
										gdouble _tmp13_;
										if (!_tmp8_) {
											gint _tmp9_;
											_tmp9_ = k;
											k = _tmp9_ + 1;
										}
										_tmp8_ = FALSE;
										_tmp10_ = self->data;
										_tmp10__length1 = self->data_length1;
										_tmp10__length2 = self->data_length2;
										_tmp10__length3 = self->data_length3;
										_tmp11_ = _tmp10__length3;
										if (!(k < _tmp11_)) {
											break;
										}
										_tmp12_ = self->data;
										_tmp12__length1 = self->data_length1;
										_tmp12__length2 = self->data_length2;
										_tmp12__length3 = self->data_length3;
										_tmp13_ = _tmp12_[(((i * _tmp12__length2) + j) * _tmp12__length3) + k];
										_result_ += _tmp13_;
									}
								}
							}
						}
					}
				}
			}
		}
	}
	result = _result_;
	return result;
}

gdouble
ft_matrix3_d_min (FtMatrix3D* self)
{
	gdouble _tmp0_ = 0.0;
	gboolean _tmp1_ = FALSE;
	gboolean _tmp2_ = FALSE;
	guint* _tmp3_;
	gint _tmp3__length1;
	guint _tmp4_;
	gdouble _result_ = 0.0;
	gdouble result;
	g_return_val_if_fail (self != NULL, -1.0);
	_tmp3_ = self->shape;
	_tmp3__length1 = self->shape_length1;
	_tmp4_ = _tmp3_[0];
	if (_tmp4_ > ((guint) 0)) {
		guint* _tmp5_;
		gint _tmp5__length1;
		guint _tmp6_;
		_tmp5_ = self->shape;
		_tmp5__length1 = self->shape_length1;
		_tmp6_ = _tmp5_[1];
		_tmp2_ = _tmp6_ > ((guint) 0);
	} else {
		_tmp2_ = FALSE;
	}
	if (_tmp2_) {
		guint* _tmp7_;
		gint _tmp7__length1;
		guint _tmp8_;
		_tmp7_ = self->shape;
		_tmp7__length1 = self->shape_length1;
		_tmp8_ = _tmp7_[2];
		_tmp1_ = _tmp8_ > ((guint) 0);
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		gdouble* _tmp9_;
		gint _tmp9__length1;
		gint _tmp9__length2;
		gint _tmp9__length3;
		gdouble _tmp10_;
		_tmp9_ = self->data;
		_tmp9__length1 = self->data_length1;
		_tmp9__length2 = self->data_length2;
		_tmp9__length3 = self->data_length3;
		_tmp10_ = _tmp9_[(((0 * _tmp9__length2) + 0) * _tmp9__length3) + 0];
		_tmp0_ = _tmp10_;
	} else {
		_tmp0_ = ((double) NAN);
	}
	_result_ = _tmp0_;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp11_ = FALSE;
			_tmp11_ = TRUE;
			while (TRUE) {
				gdouble* _tmp13_;
				gint _tmp13__length1;
				gint _tmp13__length2;
				gint _tmp13__length3;
				gint _tmp14_;
				if (!_tmp11_) {
					gint _tmp12_;
					_tmp12_ = i;
					i = _tmp12_ + 1;
				}
				_tmp11_ = FALSE;
				_tmp13_ = self->data;
				_tmp13__length1 = self->data_length1;
				_tmp13__length2 = self->data_length2;
				_tmp13__length3 = self->data_length3;
				_tmp14_ = _tmp13__length1;
				if (!(i < _tmp14_)) {
					break;
				}
				{
					gint j = 0;
					j = 0;
					{
						gboolean _tmp15_ = FALSE;
						_tmp15_ = TRUE;
						while (TRUE) {
							gdouble* _tmp17_;
							gint _tmp17__length1;
							gint _tmp17__length2;
							gint _tmp17__length3;
							gint _tmp18_;
							if (!_tmp15_) {
								gint _tmp16_;
								_tmp16_ = j;
								j = _tmp16_ + 1;
							}
							_tmp15_ = FALSE;
							_tmp17_ = self->data;
							_tmp17__length1 = self->data_length1;
							_tmp17__length2 = self->data_length2;
							_tmp17__length3 = self->data_length3;
							_tmp18_ = _tmp17__length2;
							if (!(j < _tmp18_)) {
								break;
							}
							{
								gint k = 0;
								k = 0;
								{
									gboolean _tmp19_ = FALSE;
									_tmp19_ = TRUE;
									while (TRUE) {
										gdouble* _tmp21_;
										gint _tmp21__length1;
										gint _tmp21__length2;
										gint _tmp21__length3;
										gint _tmp22_;
										gdouble* _tmp23_;
										gint _tmp23__length1;
										gint _tmp23__length2;
										gint _tmp23__length3;
										gdouble _tmp24_;
										if (!_tmp19_) {
											gint _tmp20_;
											_tmp20_ = k;
											k = _tmp20_ + 1;
										}
										_tmp19_ = FALSE;
										_tmp21_ = self->data;
										_tmp21__length1 = self->data_length1;
										_tmp21__length2 = self->data_length2;
										_tmp21__length3 = self->data_length3;
										_tmp22_ = _tmp21__length3;
										if (!(k < _tmp22_)) {
											break;
										}
										_tmp23_ = self->data;
										_tmp23__length1 = self->data_length1;
										_tmp23__length2 = self->data_length2;
										_tmp23__length3 = self->data_length3;
										_tmp24_ = _tmp23_[(((i * _tmp23__length2) + j) * _tmp23__length3) + k];
										if (_result_ > _tmp24_) {
											gdouble* _tmp25_;
											gint _tmp25__length1;
											gint _tmp25__length2;
											gint _tmp25__length3;
											gdouble _tmp26_;
											_tmp25_ = self->data;
											_tmp25__length1 = self->data_length1;
											_tmp25__length2 = self->data_length2;
											_tmp25__length3 = self->data_length3;
											_tmp26_ = _tmp25_[(((i * _tmp25__length2) + j) * _tmp25__length3) + k];
											_result_ = _tmp26_;
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}
	result = _result_;
	return result;
}

gdouble
ft_matrix3_d_max (FtMatrix3D* self)
{
	gdouble _tmp0_ = 0.0;
	gboolean _tmp1_ = FALSE;
	gboolean _tmp2_ = FALSE;
	guint* _tmp3_;
	gint _tmp3__length1;
	guint _tmp4_;
	gdouble _result_ = 0.0;
	gdouble result;
	g_return_val_if_fail (self != NULL, -1.0);
	_tmp3_ = self->shape;
	_tmp3__length1 = self->shape_length1;
	_tmp4_ = _tmp3_[0];
	if (_tmp4_ > ((guint) 0)) {
		guint* _tmp5_;
		gint _tmp5__length1;
		guint _tmp6_;
		_tmp5_ = self->shape;
		_tmp5__length1 = self->shape_length1;
		_tmp6_ = _tmp5_[1];
		_tmp2_ = _tmp6_ > ((guint) 0);
	} else {
		_tmp2_ = FALSE;
	}
	if (_tmp2_) {
		guint* _tmp7_;
		gint _tmp7__length1;
		guint _tmp8_;
		_tmp7_ = self->shape;
		_tmp7__length1 = self->shape_length1;
		_tmp8_ = _tmp7_[2];
		_tmp1_ = _tmp8_ > ((guint) 0);
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		gdouble* _tmp9_;
		gint _tmp9__length1;
		gint _tmp9__length2;
		gint _tmp9__length3;
		gdouble _tmp10_;
		_tmp9_ = self->data;
		_tmp9__length1 = self->data_length1;
		_tmp9__length2 = self->data_length2;
		_tmp9__length3 = self->data_length3;
		_tmp10_ = _tmp9_[(((0 * _tmp9__length2) + 0) * _tmp9__length3) + 0];
		_tmp0_ = _tmp10_;
	} else {
		_tmp0_ = ((double) NAN);
	}
	_result_ = _tmp0_;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp11_ = FALSE;
			_tmp11_ = TRUE;
			while (TRUE) {
				gdouble* _tmp13_;
				gint _tmp13__length1;
				gint _tmp13__length2;
				gint _tmp13__length3;
				gint _tmp14_;
				if (!_tmp11_) {
					gint _tmp12_;
					_tmp12_ = i;
					i = _tmp12_ + 1;
				}
				_tmp11_ = FALSE;
				_tmp13_ = self->data;
				_tmp13__length1 = self->data_length1;
				_tmp13__length2 = self->data_length2;
				_tmp13__length3 = self->data_length3;
				_tmp14_ = _tmp13__length1;
				if (!(i < _tmp14_)) {
					break;
				}
				{
					gint j = 0;
					j = 0;
					{
						gboolean _tmp15_ = FALSE;
						_tmp15_ = TRUE;
						while (TRUE) {
							gdouble* _tmp17_;
							gint _tmp17__length1;
							gint _tmp17__length2;
							gint _tmp17__length3;
							gint _tmp18_;
							if (!_tmp15_) {
								gint _tmp16_;
								_tmp16_ = j;
								j = _tmp16_ + 1;
							}
							_tmp15_ = FALSE;
							_tmp17_ = self->data;
							_tmp17__length1 = self->data_length1;
							_tmp17__length2 = self->data_length2;
							_tmp17__length3 = self->data_length3;
							_tmp18_ = _tmp17__length2;
							if (!(j < _tmp18_)) {
								break;
							}
							{
								gint k = 0;
								k = 0;
								{
									gboolean _tmp19_ = FALSE;
									_tmp19_ = TRUE;
									while (TRUE) {
										gdouble* _tmp21_;
										gint _tmp21__length1;
										gint _tmp21__length2;
										gint _tmp21__length3;
										gint _tmp22_;
										gdouble* _tmp23_;
										gint _tmp23__length1;
										gint _tmp23__length2;
										gint _tmp23__length3;
										gdouble _tmp24_;
										if (!_tmp19_) {
											gint _tmp20_;
											_tmp20_ = k;
											k = _tmp20_ + 1;
										}
										_tmp19_ = FALSE;
										_tmp21_ = self->data;
										_tmp21__length1 = self->data_length1;
										_tmp21__length2 = self->data_length2;
										_tmp21__length3 = self->data_length3;
										_tmp22_ = _tmp21__length3;
										if (!(k < _tmp22_)) {
											break;
										}
										_tmp23_ = self->data;
										_tmp23__length1 = self->data_length1;
										_tmp23__length2 = self->data_length2;
										_tmp23__length3 = self->data_length3;
										_tmp24_ = _tmp23_[(((i * _tmp23__length2) + j) * _tmp23__length3) + k];
										if (_result_ < _tmp24_) {
											gdouble* _tmp25_;
											gint _tmp25__length1;
											gint _tmp25__length2;
											gint _tmp25__length3;
											gdouble _tmp26_;
											_tmp25_ = self->data;
											_tmp25__length1 = self->data_length1;
											_tmp25__length2 = self->data_length2;
											_tmp25__length3 = self->data_length3;
											_tmp26_ = _tmp25_[(((i * _tmp25__length2) + j) * _tmp25__length3) + k];
											_result_ = _tmp26_;
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}
	result = _result_;
	return result;
}

/**
         * Split an array into multiple sub-arrays along given axis.
         *
         * For example, splitting along the last axis. You can visualise it as an array of vectors.
         * Splitting will replace those vectors with numeric values, and will return same number of
         * matrices as the vectors length.
         */
FtMatrix**
ft_matrix3_d_unstack (FtMatrix3D* self,
                      gint axis,
                      gint* result_length1)
{
	gboolean _tmp0_;
	guint* shape = NULL;
	guint* _tmp1_;
	gint shape_length1;
	gint _shape_size_;
	FtMatrix** _result_ = NULL;
	guint* _tmp10_;
	gint _tmp10__length1;
	guint _tmp11_;
	FtMatrix** _tmp12_;
	gint _result__length1;
	gint __result__size_;
	FtMatrix** _tmp19_;
	gint _tmp19__length1;
	FtMatrix** result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = ft_matrix3_d_validate_axis (self, &axis);
	_vala_assert (_tmp0_, "validate_axis (ref axis)");
	_tmp1_ = g_new0 (guint, 2);
	_tmp1_[0] = (guint) 0;
	_tmp1_[1] = (guint) 0;
	shape = _tmp1_;
	shape_length1 = 2;
	_shape_size_ = shape_length1;
	{
		gint index = 0;
		index = 0;
		{
			gboolean _tmp2_ = FALSE;
			_tmp2_ = TRUE;
			while (TRUE) {
				if (!_tmp2_) {
					gint _tmp3_;
					_tmp3_ = index;
					index = _tmp3_ + 1;
				}
				_tmp2_ = FALSE;
				if (!(index < FT_MATRIX3_D_DIMENSIONS)) {
					break;
				}
				if (index < axis) {
					guint* _tmp4_;
					gint _tmp4__length1;
					guint* _tmp5_;
					gint _tmp5__length1;
					guint _tmp6_;
					_tmp4_ = shape;
					_tmp4__length1 = shape_length1;
					_tmp5_ = self->shape;
					_tmp5__length1 = self->shape_length1;
					_tmp6_ = _tmp5_[index];
					_tmp4_[index] = _tmp6_;
				} else {
					if (index > axis) {
						guint* _tmp7_;
						gint _tmp7__length1;
						guint* _tmp8_;
						gint _tmp8__length1;
						guint _tmp9_;
						_tmp7_ = shape;
						_tmp7__length1 = shape_length1;
						_tmp8_ = self->shape;
						_tmp8__length1 = self->shape_length1;
						_tmp9_ = _tmp8_[index];
						_tmp7_[index - 1] = _tmp9_;
					}
				}
			}
		}
	}
	_tmp10_ = self->shape;
	_tmp10__length1 = self->shape_length1;
	_tmp11_ = _tmp10_[axis];
	_tmp12_ = g_new0 (FtMatrix*, _tmp11_ + 1);
	_result_ = _tmp12_;
	_result__length1 = _tmp11_;
	__result__size_ = _result__length1;
	{
		gint index = 0;
		index = 0;
		{
			gboolean _tmp13_ = FALSE;
			_tmp13_ = TRUE;
			while (TRUE) {
				guint* _tmp15_;
				gint _tmp15__length1;
				guint _tmp16_;
				FtMatrix** _tmp17_;
				gint _tmp17__length1;
				FtMatrix* _tmp18_;
				if (!_tmp13_) {
					gint _tmp14_;
					_tmp14_ = index;
					index = _tmp14_ + 1;
				}
				_tmp13_ = FALSE;
				_tmp15_ = self->shape;
				_tmp15__length1 = self->shape_length1;
				_tmp16_ = _tmp15_[axis];
				if (!(((guint) index) < _tmp16_)) {
					break;
				}
				_tmp17_ = _result_;
				_tmp17__length1 = _result__length1;
				_tmp18_ = ft_matrix3_d_get_matrix (self, axis, index);
				_ft_matrix_free0 (_tmp17_[index]);
				_tmp17_[index] = _tmp18_;
			}
		}
	}
	_tmp19_ = _result_;
	_tmp19__length1 = _result__length1;
	if (result_length1) {
		*result_length1 = _tmp19__length1;
	}
	result = _tmp19_;
	shape = (g_free (shape), NULL);
	return result;
}

static void
ft_matrix3_d_instance_init (FtMatrix3D * self)
{
}

void
ft_matrix3_d_free (FtMatrix3D * self)
{
	self->shape = (g_free (self->shape), NULL);
	self->shape = NULL;
	self->shape_length1 = 0;
	self->data = (g_free (self->data), NULL);
	self->data = NULL;
	self->data_length1 = 0;
	self->data_length2 = 0;
	self->data_length3 = 0;
	self->shape = (g_free (self->shape), NULL);
	self->data = (g_free (self->data), NULL);
	g_slice_free (FtMatrix3D, self);
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

