///
/// 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 System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using ILNumerics.Storage;
using ILNumerics.Misc;
using ILNumerics.Native;
using ILNumerics.Exceptions;
namespace ILNumerics {
public partial class ILMath {
///
/// Create double array with all elements initialized to 0
///
/// Size description
/// Zeros-filled array.
public static ILRetArray zeros(params int[] size) {
return (ILRetArray)zeros(NumericType.Double, new ILSize(size));
}
///
/// Create double array with all elements initialized to 0
///
/// Size descriptor
/// Zeros-filled array.
public static ILRetArray zeros(ILSize size) {
return (ILRetArray)zeros(NumericType.Double, size);
}
///
/// Create array with all elements initialized to default(T)
///
/// Element type
/// Size descriptor
/// New array, initialized to default(T)
public static ILRetArray zeros(ILSize size) {
return array(default(T), size);
}
///
/// Create new array of arbitrary element type, initialized to '0'
///
/// Element type
/// Size description
/// New array having the size determined by 'dims', initialized to '0'
/// For T deriving from Sytem.ValueType elements will be '0'. All other element types
/// will be initialized to default(T).
public static ILRetArray zeros(params int[] size) {
return array(default(T), new ILSize(size));
}
///
/// Create array initialized with all elements set to zero
///
/// Numeric type specification. One value out of the types listed in the
/// enum.
/// Size descriptor
/// Array of inner type corresponding to argument.
/// The array returned may be casted to the appropriate actual type afterwards.
///
///
/// The following types are supported:
/// - Double
/// - Single
/// - Complex
/// - FComplex
/// - Byte
/// - Int32
/// - Int64
///
///
/// This function is provided for downward compatibility reasons only and will be removed in a future update. It is recommended to use the or overloads instead.
/// The interface of this function does not confirm to the rules of functions in ILNumerics. Therefore, in order to prevent for potential memory issues, the return value should be converted to
/// a concrete array type explicitely:
///
///
/// ILArray<double> A = todouble(zeros(NumericType.double, size(10,20)));
///
/// // better and easier would be:
/// ILArray<double> B = zeros<double>(10,20);
///
///
///
[Obsolete("Use overload ILMath.zeros instead!")]
public static ILBaseArray zeros(NumericType type, ILSize size) {
switch (type) {
case NumericType.Double:
return zeros(size);
case NumericType.Single:
return zeros(size);
case NumericType.Complex:
return zeros(size);
case NumericType.FComplex:
return zeros(size);
case NumericType.Byte:
return zeros(size);
case NumericType.Int32:
return zeros(size);
case NumericType.Int64:
return zeros(size);
default:
return zeros(size);
}
}
}
}