///
/// This file is part of ILNumerics Community Edition.
///
/// ILNumerics Community Edition - high performance computing for applications.
/// Copyright (C) 2006 - 2012 Haymo Kutschbach, http://ilnumerics.net
///
/// ILNumerics Community Edition is free software: you can redistribute it and/or modify
/// it under the terms of the GNU General Public License version 3 as published by
/// the Free Software Foundation.
///
/// ILNumerics Community Edition is distributed in the hope that it will be useful,
/// but WITHOUT ANY WARRANTY; without even the implied warranty of
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/// GNU General Public License for more details.
///
/// You should have received a copy of the GNU General Public License
/// along with ILNumerics Community Edition. See the file License.txt in the root
/// of your distribution package. If not, see .
///
/// In addition this software uses the following components and/or licenses:
///
/// =================================================================================
/// The Open Toolkit Library License
///
/// Copyright (c) 2006 - 2009 the Open Toolkit library.
///
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights to
/// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
/// the Software, and to permit persons to whom the Software is furnished to do
/// so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in all
/// copies or substantial portions of the Software.
///
/// =================================================================================
///
using System;
using ILNumerics;
using ILNumerics.Misc;
using ILNumerics.Storage;
using ILNumerics.Native;
using ILNumerics.Exceptions;
namespace ILNumerics {
public abstract partial class ILDenseArray {
///
/// Elementwise subtraction operator
///
/// Left side
/// Right side
/// Result of subtraction
/// The operator is defined for both arrays of the same numeric 'ElementType' (double, float, complex,
/// fcomplex, int, long, byte).
/// If the array elements are of an unsupported type
public static ILRetArray operator -(ILDenseArray A, ILDenseArray B) {
using (ILScope.Enter(A,B))
// TODO: check if (A.GetType() == typeof(ILDenseArray)) is faster due to JIT optimizations
if (A is ILDenseArray< double>) {
return (ILRetArray)(object)ILMath.subtract((A as ILDenseArray).C, (B as ILDenseArray).C);
} else if (A is ILDenseArray) {
return (ILRetArray)(object)ILMath.subtract((A as ILDenseArray).C, (B as ILDenseArray).C);
} else if (A is ILDenseArray) {
return (ILRetArray)(object)ILMath.subtract((A as ILDenseArray).C, (B as ILDenseArray).C);
} else if (A is ILDenseArray) {
return (ILRetArray)(object)ILMath.subtract((A as ILDenseArray).C, (B as ILDenseArray).C);
} else if (A is ILDenseArray) {
return (ILRetArray)(object)ILMath.subtract((A as ILDenseArray).C, (B as ILDenseArray).C);
} else if (A is ILDenseArray) {
return (ILRetArray)(object)ILMath.subtract((A as ILDenseArray).C, (B as ILDenseArray).C);
} else if (A is ILDenseArray) {
return (ILRetArray)(object)ILMath.subtract((A as ILDenseArray).C, (B as ILDenseArray).C);
} else {
throw new ILArgumentException("Operator - not defined for arrays of element type '" + typeof(ElementType).Name + "'");
}
}
///
/// Elementwise addition operator
///
/// Left side
/// Right side
/// Result of addition
/// The operator is defined for both arrays of the same numeric 'ElementType' (double, float, complex,
/// fcomplex, int, long, byte).
/// If the array elements are of an unsupported type
public static ILRetArray operator +(ILDenseArray A, ILDenseArray B) {
using (ILScope.Enter(A, B))
if (A is ILDenseArray< double>) {
return (ILRetArray)(object)ILMath.add((A as ILDenseArray).C, (B as ILDenseArray).C);
} else if (A is ILDenseArray) {
return (ILRetArray)(object)ILMath.add((A as ILDenseArray).C, (B as ILDenseArray).C);
} else if (A is ILDenseArray) {
return (ILRetArray)(object)ILMath.add((A as ILDenseArray).C, (B as ILDenseArray).C);
} else if (A is ILDenseArray) {
return (ILRetArray)(object)ILMath.add((A as ILDenseArray).C, (B as ILDenseArray).C);
} else if (A is ILDenseArray) {
return (ILRetArray)(object)ILMath.add((A as ILDenseArray).C, (B as ILDenseArray).C);
} else if (A is ILDenseArray) {
return (ILRetArray)(object)ILMath.add((A as ILDenseArray).C, (B as ILDenseArray).C);
} else if (A is ILDenseArray) {
return (ILRetArray)(object)ILMath.add((A as ILDenseArray).C, (B as ILDenseArray).C);
} else {
throw new ILArgumentException("Operator + not defined for arrays of element type '" + typeof(ElementType).Name + "'");
}
}
///
/// Elementwise multiplication operator
///
/// Left side
/// Right side
/// Result of multiplication
/// The operator is defined for both arrays of the same numeric 'ElementType' (double, float, complex,
/// fcomplex, int, long, byte).
/// If the array elements are of an unsupported type
public static ILRetArray operator *(ILDenseArray A, ILDenseArray B) {
using (ILScope.Enter(A, B))
if (A is ILDenseArray< double>) {
return (ILRetArray)(object)ILMath.multiplyElem((A as ILDenseArray).C, (B as ILDenseArray).C);
} else if (A is ILDenseArray) {
return (ILRetArray)(object)ILMath.multiplyElem((A as ILDenseArray).C, (B as ILDenseArray).C);
} else if (A is ILDenseArray) {
return (ILRetArray)(object)ILMath.multiplyElem((A as ILDenseArray).C, (B as ILDenseArray).C);
} else if (A is ILDenseArray) {
return (ILRetArray)(object)ILMath.multiplyElem((A as ILDenseArray).C, (B as ILDenseArray).C);
} else if (A is ILDenseArray) {
return (ILRetArray)(object)ILMath.multiplyElem((A as ILDenseArray).C, (B as ILDenseArray).C);
} else if (A is ILDenseArray) {
return (ILRetArray)(object)ILMath.multiplyElem((A as ILDenseArray).C, (B as ILDenseArray).C);
} else if (A is ILDenseArray) {
return (ILRetArray)(object)ILMath.multiplyElem((A as ILDenseArray).C, (B as ILDenseArray).C);
} else {
throw new ILArgumentException("Operator * not defined for arrays of element type '" + typeof(ElementType).Name + "'");
}
}
/////
///// Elementwise exponentiation operator ----------- CAUTION! THE ^ OPERATOR HAS LOWER PRECEEDENCE AS THE *,+,-... OPERATORS!
/////
///// Bases
///// Exponents
///// Result of exponentiation of base elements A and exponents in B
///// The operator is defined for both arrays of the same numeric 'ElementType' (double, float, complex,
///// fcomplex, int, long, byte).
///// If the array elements are of an unsupported type
//public static ILRetArray operator ^(ILDenseArray A, ILDenseArray B) {
// if (A is ILDenseArray< double >) {
// return (ILRetArray)(object)ILMath.pow((A as ILDenseArray).C, (B as ILDenseArray).C);
// } else if (A is ILDenseArray) {
// return (ILRetArray)(object)ILMath.pow((A as ILDenseArray).C, (B as ILDenseArray).C);
// } else if (A is ILDenseArray) {
// return (ILRetArray)(object)ILMath.pow((A as ILDenseArray).C, (B as ILDenseArray).C);
// } else if (A is ILDenseArray) {
// return (ILRetArray)(object)ILMath.pow((A as ILDenseArray).C, (B as ILDenseArray).C);
// } else if (A is ILDenseArray) {
// return (ILRetArray)(object)ILMath.pow((A as ILDenseArray).C, (B as ILDenseArray).C);
// } else if (A is ILDenseArray) {
// return (ILRetArray)(object)ILMath.pow((A as ILDenseArray).C, (B as ILDenseArray).C);
// } else if (A is ILDenseArray) {
// return (ILRetArray)(object)ILMath.pow((A as ILDenseArray).C, (B as ILDenseArray).C);
// } else {
// throw new ILArgumentException("Operator * not defined for "+ A.GetType().Name + " and " + B.GetType().Name);
// }
//}
///
/// Elementwise division operator
///
/// Left side
/// Right side
/// Result of division
/// The operator is defined for both arrays of the same numeric 'ElementType' (double, float, complex,
/// fcomplex, int, long, byte).
/// If the array elements are of an unsupported type
public static ILRetArray operator /(ILDenseArray A, ILDenseArray B) {
using (ILScope.Enter(A, B))
if (A is ILDenseArray< double>) {
return (ILRetArray)(object)ILMath.divide((A as ILDenseArray).C, (B as ILDenseArray).C);
} else if (A is ILDenseArray) {
return (ILRetArray)(object)ILMath.divide((A as ILDenseArray).C, (B as ILDenseArray).C);
} else if (A is ILDenseArray) {
return (ILRetArray)(object)ILMath.divide((A as ILDenseArray).C, (B as ILDenseArray).C);
} else if (A is ILDenseArray) {
return (ILRetArray)(object)ILMath.divide((A as ILDenseArray).C, (B as ILDenseArray).C);
} else if (A is ILDenseArray) {
return (ILRetArray)(object)ILMath.divide((A as ILDenseArray).C, (B as ILDenseArray).C);
} else if (A is ILDenseArray) {
return (ILRetArray)(object)ILMath.divide((A as ILDenseArray).C, (B as ILDenseArray).C);
} else if (A is ILDenseArray) {
return (ILRetArray)(object)ILMath.divide((A as ILDenseArray).C, (B as ILDenseArray).C);
} else {
throw new ILArgumentException("Operator / not defined for arrays of element type '" + typeof(ElementType).Name + "'");
}
}
///
/// Elementwise modulus operator
///
/// Left side
/// Right side
/// Result of modulus operation
/// The operator is defined for 2 arrays of the same numeric real element types: double, float, int, long, byte.
/// If the array elements are of an unsupported type
public static ILRetArray operator %(ILDenseArray A, ILDenseArray B) {
using (ILScope.Enter(A, B))
if (A is ILDenseArray< double>) {
return (ILRetArray)(object)ILMath.mod((A as ILDenseArray).C, (B as ILDenseArray).C);
} else if (A is ILDenseArray) {
return (ILRetArray)(object)ILMath.mod((A as ILDenseArray).C, (B as ILDenseArray).C);
} else if (A is ILDenseArray) {
return (ILRetArray)(object)ILMath.mod((A as ILDenseArray).C, (B as ILDenseArray).C);
} else if (A is ILDenseArray) {
return (ILRetArray)(object)ILMath.mod((A as ILDenseArray).C, (B as ILDenseArray).C);
} else if (A is ILDenseArray) {
return (ILRetArray)(object)ILMath.mod((A as ILDenseArray).C, (B as ILDenseArray).C);
} else {
throw new ILArgumentException("Operator % not defined for arrays of element type '" + typeof(ElementType).Name + "'");
}
}
///
/// 'Equalty' operator of two arrays
///
/// Left side
/// Right side
/// Logical array of same size than A and B, result of operation along all elements
/// Sizes and types of A and B must match.
public static ILRetLogical operator ==(ILDenseArray A, ILDenseArray B) {
using (ILScope.Enter(A, B)) {
if (object.Equals(A, null)) {
if (object.Equals(B, null)) {
return true;
} else {
return false;
}
} else {
if (object.Equals(B, null)) {
return false;
}
}
if (false) {
} else if (A is ILDenseArray< double> && B is ILDenseArray< double>) {
return ILMath.eq((A as ILDenseArray< double>).C, (B as ILDenseArray< double>).C);
#region HYCALPER AUTO GENERATED CODE
} else if (A is ILDenseArray && B is ILDenseArray) {
return ILMath.eq((A as ILDenseArray).C, (B as ILDenseArray).C);
} else if (A is ILDenseArray && B is ILDenseArray) {
return ILMath.eq((A as ILDenseArray).C, (B as ILDenseArray).C);
} else if (A is ILDenseArray && B is ILDenseArray) {
return ILMath.eq((A as ILDenseArray).C, (B as ILDenseArray).C);
} else if (A is ILDenseArray && B is ILDenseArray) {
return ILMath.eq((A as ILDenseArray).C, (B as ILDenseArray).C);
} else if (A is ILDenseArray && B is ILDenseArray) {
return ILMath.eq((A as ILDenseArray).C, (B as ILDenseArray).C);
} else if (A is ILDenseArray && B is ILDenseArray) {
return ILMath.eq((A as ILDenseArray).C, (B as ILDenseArray).C);
#endregion HYCALPER AUTO GENERATED CODE
} else if (A is ILDenseArray && B is ILDenseArray) {
return ILMath.eq((A as ILDenseArray).C, (B as ILDenseArray).C);
} else {
throw new ILArgumentTypeException("Operator '==' not defined for arrays of element type '" + typeof(ElementType).Name + "'");
}
}
}
///
/// 'unequalty' operator of two arrays
///
/// Left side
/// Right side
/// Logical array of same size than A and B, result of operation along all elements
/// Sizes and types of A and B must match.
public static ILRetLogical operator !=(ILDenseArray A, ILDenseArray B) {
using (ILScope.Enter(A, B)) {
if (object.Equals(A, null)) {
if (object.Equals(B, null)) {
return false;
} else {
return true;
}
} else {
if (object.Equals(B, null)) {
return true;
}
}
if (false) {
} else if (A is ILDenseArray< double> && B is ILDenseArray< double>) {
return ILMath.neq((A as ILDenseArray< double>).C, (B as ILDenseArray< double>).C);
#region HYCALPER AUTO GENERATED CODE
} else if (A is ILDenseArray && B is ILDenseArray) {
return ILMath.neq((A as ILDenseArray).C, (B as ILDenseArray).C);
} else if (A is ILDenseArray && B is ILDenseArray) {
return ILMath.neq((A as ILDenseArray).C, (B as ILDenseArray).C);
} else if (A is ILDenseArray && B is ILDenseArray) {
return ILMath.neq((A as ILDenseArray).C, (B as ILDenseArray).C);
} else if (A is ILDenseArray && B is ILDenseArray) {
return ILMath.neq((A as ILDenseArray).C, (B as ILDenseArray).C);
} else if (A is ILDenseArray && B is ILDenseArray) {
return ILMath.neq((A as ILDenseArray).C, (B as ILDenseArray).C);
} else if (A is ILDenseArray && B is ILDenseArray) {
return ILMath.neq((A as ILDenseArray).C, (B as ILDenseArray).C);
#endregion HYCALPER AUTO GENERATED CODE
} else if (A is ILDenseArray && B is ILDenseArray) {
return ILMath.neq((A as ILDenseArray).C, (B as ILDenseArray).C);
} else {
throw new ILArgumentTypeException("Operator '!=' not defined for arrays of element type '" + typeof(ElementType).Name + "'");
}
}
}
///
/// 'greater or equal' operator of two arrays
///
/// Left side
/// Right side
/// Logical array of same size than A and B, result of operation along all elements
/// Sizes and types of A and B must match.
public static ILRetLogical operator >=(ILDenseArray A, ILDenseArray B) {
using (ILScope.Enter(A, B)) {
if (false) {
} else if (A is ILDenseArray< double> && B is ILDenseArray< double>) {
return ILMath.ge((A as ILDenseArray< double>).C, (B as ILDenseArray< double>).C);
#region HYCALPER AUTO GENERATED CODE
} else if (A is ILDenseArray && B is ILDenseArray) {
return ILMath.ge((A as ILDenseArray).C, (B as ILDenseArray).C);
} else if (A is ILDenseArray && B is ILDenseArray) {
return ILMath.ge((A as ILDenseArray).C, (B as ILDenseArray).C);
} else if (A is ILDenseArray && B is ILDenseArray) {
return ILMath.ge((A as ILDenseArray).C, (B as ILDenseArray).C);
} else if (A is ILDenseArray && B is ILDenseArray) {
return ILMath.ge((A as ILDenseArray).C, (B as ILDenseArray).C);
} else if (A is ILDenseArray && B is ILDenseArray) {
return ILMath.ge((A as ILDenseArray