
namespace XELF.Framework {

	public partial struct Matrix {
		/// <summary>
		/// 和
		/// </summary>
		/// <param name="a"></param>
		/// <param name="b"></param>
		/// <param name="result"></param>
		public static void Add(ref Matrix a, ref Matrix b, out Matrix result) {
			result = new Matrix();
			result.M11 = a.M11 + b.M11; result.M12 = a.M12 + b.M12; result.M13 = a.M13 + b.M13; result.M14 = a.M14 + b.M14;
			result.M21 = a.M21 + b.M21; result.M22 = a.M22 + b.M22; result.M23 = a.M23 + b.M23; result.M24 = a.M24 + b.M24;
			result.M31 = a.M31 + b.M31; result.M32 = a.M32 + b.M32; result.M33 = a.M33 + b.M33; result.M34 = a.M34 + b.M34;
			result.M41 = a.M41 + b.M41; result.M42 = a.M42 + b.M42; result.M43 = a.M43 + b.M43; result.M44 = a.M44 + b.M44;
		}
		/// <summary>
		/// 和
		/// </summary>
		/// <param name="a"></param>
		/// <param name="b"></param>
		public static Matrix Add(Matrix a, Matrix b) {
			Matrix result;
			Add(ref a, ref b, out result);
			return result;
		}
	}

	public partial struct Matrix {
		/// <summary>
		/// 差
		/// </summary>
		/// <param name="a"></param>
		/// <param name="b"></param>
		/// <param name="result"></param>
		public static void Subtract(ref Matrix a, ref Matrix b, out Matrix result) {
			result = new Matrix();
			result.M11 = a.M11 - b.M11; result.M12 = a.M12 - b.M12; result.M13 = a.M13 - b.M13; result.M14 = a.M14 - b.M14;
			result.M21 = a.M21 - b.M21; result.M22 = a.M22 - b.M22; result.M23 = a.M23 - b.M23; result.M24 = a.M24 - b.M24;
			result.M31 = a.M31 - b.M31; result.M32 = a.M32 - b.M32; result.M33 = a.M33 - b.M33; result.M34 = a.M34 - b.M34;
			result.M41 = a.M41 - b.M41; result.M42 = a.M42 - b.M42; result.M43 = a.M43 - b.M43; result.M44 = a.M44 - b.M44;
		}
		/// <summary>
		/// 差
		/// </summary>
		/// <param name="a"></param>
		/// <param name="b"></param>
		public static Matrix Subtract(Matrix a, Matrix b) {
			Matrix result;
			Subtract(ref a, ref b, out result);
			return result;
		}
	}

}
