#ifndef T222_H
# define T222_H
# ifndef GPK_STD_H
#  include <gpk_std.h>
# endif
# include <stdio.h>
# include <math.h>
# include "m22.h"
# include "v2.h"

class tensor222 {
	double d[2][2][2];
	int *i[3];

	public:
	double operator()(int i, int j, int k) C	{return d[i][j][k];}
	tensor222();
	tensor222(double a000, double a001, double a010, double a011,
				double a100, double a101, double a110, double a111);
    tensor222& indices(int& ii, int& jj, int& kk)
						{i[1]=&ii; i[2]=&jj; i[3]=&kk; return *this;}
	tensor222& index0(int& ii)	{i[0]=&ii; return *this;}
	tensor222& index1(int& ii)	{i[1]=&ii; return *this;}
	tensor222& index2(int& ii)	{i[2]=&ii; return *this;}
	tensor222 operator-() C;
	static tensor222 identity();
	double norm_2() C;
	double norm() C	{return ::sqrt(norm_2());}
	double max() C;
	};

tensor222 operator-(C tensor222& a, C tensor222& b);
tensor222 operator-(C tensor222& a);
matrix22 operator*(C tensor222& a, C vector2& b);
matrix22 operator*(C vector2& a, C tensor222& b);
matrix22 mid(C tensor222& b, C vector2& a);
tensor222 mid(C tensor222& b, C matrix22& a);
tensor222 tail(C tensor222& b, C matrix22& a);
tensor222 operator+(C tensor222& a, C tensor222& b);
tensor222 operator*(C tensor222& b, double a);
tensor222 operator*(double a, C tensor222& b);


inline tensor222 operator*(double a, C tensor222& b)
		{return b*a;}
#endif
