<commit_before>#region Math.NET Iridium (LGPL) by Ruegg
// Math.NET Iridium, part of the Math.NET Project
// http://mathnet.opensourcedotnet.info
//
// Copyright (c) 2004-2008, <NAME>, http://christoph.ruegg.name
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published 
// by the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program 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 Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public 
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#endregion

using System;
using System.Text;
using System.Collections.Generic;
using MathNet.Numerics.Properties;
using MathNet.Numerics.Distributions;

namespace MathNet.Numerics.LinearAlgebra
{

    /// <summary>
    /// Complex Vector.
    /// </summary>
    [Serializable]
    public class ComplexVector :
        IVector<Complex>,
        IList<Complex>,
        ICloneable
    {

        private Complex[] _data;
        private int _length;

        /// <summary>
        /// Gets dimensionality of the vector.
        /// </summary>
        public int Length
        {
            get { return _length; }
        }

        /// <summary>
        /// Gets or sets the element indexed by <c>i</c>
        /// in the <c>Vector</c>.
        /// </summary>
        /// <param name="i">Dimension index.</param>
        public Complex this[int i]
        {
            get { return _data[i]; }
            set { _data[i] = value; }
        }

        #region Constructors and static constructive methods

        /// <summary>
        /// Constructs an n-dimensional vector of zeros.
        /// </summary>
        /// <param name="n">Dimensionality of vector.</param>
        public
        ComplexVector(
            int n
            )
        {
            _length = n;
            _data = new Complex[_length];
        }

        /// <summary>
        /// Constructs an n-dimensional unit vector for i'th coordinate.
        /// </summary>
        /// <param name="n">Dimensionality of vector.</param>
        /// <param name="i">Coordinate index.</param>
        public
        ComplexVector(
            int n,
            int i
            )
        {
            _length = n;
            _data = new Complex[_length];
            _data[i] = 1.0;
        }

        /// <summary>
        /// Constructs an n-dimensional constant vector.
        /// </summary>
        /// <param name="n">Dimensionality of vector.</param>
        /// <param name="value">Fill the vector with this scalar value.</param>
        public
        ComplexVector(
            int n,
            Complex value
            )
        {
            _length = n;
            _data = new Complex[_length];
            for(int i = 0; i < _length; i++)
            {
                _data[i] = value;
            }
        }

        /// <summary>
        /// Constructs a vector from a 1-D array, directly using
        /// the provided array as internal data structure.
        /// </summary>
        /// <param name="components">One-dimensional array of doubles.</param>
        /// <seealso cref="Create(Complex[])"/>
        public
        ComplexVector(
            Complex[] components
            )
        {
            _length = components.Length;
            _data = components;
        }

        /// <summary>
        /// Constructs a vector from a copy of a 1-D array.
        /// </summary>
        /// <param name="components">One-dimensional array of doubles.</param>
        public static
        ComplexVector
        Create(
            Complex[] components
            )
        {
            if(null == components)
            {
                throw new ArgumentNullException("components");
            }

            Complex[] newData = new Complex[components.Length];
            components.CopyTo(newData, 0);

            return new ComplexVector(newData);
        }

        /// <summary>
        /// Constructs a complex vector from a real and an imaginary vector.
        /// </summary>
        /// <param name="realComponents">One-dimensional array of doubles representing the real part of the vector.</param>
        /// <param name="imagComponents">One-dimensional array of doubles representing the imaginary part of the vector.</param>
        public static
        ComplexVector
        Create(
            IList<double> realComponents,
            IList<double> imagComponents
            )
        {
            if(null == realComponents)
            {
                throw new ArgumentNullException("realComponents");
            }

            if(null == imagComponents)
            {
                throw new ArgumentNullException("imagComponents");
            }

            if(realComponents.Count != imagComponents.Count)
            {
                throw new ArgumentException(Properties.Resources.ArgumentVectorsSameLengths);
            }

            Complex[] newData = new Complex[realComponents.Count];
            for(int i = 0; i < newData.Length; i++)
            {
                newData[i] = new Complex(realComponents[i], imagComponents[i]);
            }

            return new ComplexVector(newData);
        }

        // TODO: Add Random Vector Generations Methods here

        /// <summary>
        /// Generates an n-dimensional vector filled with 1.
        /// </summary>
        /// <param name="n">Dimensionality of vector.</param>
        public static
        ComplexVector
        Ones(
            int n
            )
        {
            return new ComplexVector(n, 1.0);
        }

        /// <summary>
        /// Generates an n-dimensional vector filled with 0.
        /// </summary>
        /// <param name="n">Dimensionality of vector.</param>
        public static
        ComplexVector
        Zeros(
            int n
            )
        {
            return new ComplexVector(n);
        }

        /// <summary><commit_msg>IRID-181 - Create ComplexVector from Vector<commit_after>#region Math.NET Iridium (LGPL) by Ruegg
// Math.NET Iridium, part of the Math.NET Project
// http://mathnet.opensourcedotnet.info
//
// Copyright (c) 2004-2008, <NAME>, http://christoph.ruegg.name
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published 
// by the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program 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 Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public 
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#endregion

using System;
using System.Text;
using System.Collections.Generic;
using MathNet.Numerics.Properties;
using MathNet.Numerics.Distributions;

namespace MathNet.Numerics.LinearAlgebra
{

    /// <summary>
    /// Complex Vector.
    /// </summary>
    [Serializable]
    public class ComplexVector :
        IVector<Complex>,
        IList<Complex>,
        ICloneable
    {

        private Complex[] _data;
        private int _length;

        /// <summary>
        /// Gets dimensionality of the vector.
        /// </summary>
        public int Length
        {
            get { return _length; }
        }

        /// <summary>
        /// Gets or sets the element indexed by <c>i</c>
        /// in the <c>Vector</c>.
        /// </summary>
        /// <param name="i">Dimension index.</param>
        public Complex this[int i]
        {
            get { return _data[i]; }
            set { _data[i] = value; }
        }

        #region Constructors and static constructive methods

        /// <summary>
        /// Constructs an n-dimensional vector of zeros.
        /// </summary>
        /// <param name="n">Dimensionality of vector.</param>
        public
        ComplexVector(
            int n
            )
        {
            _length = n;
            _data = new Complex[_length];
        }

        /// <summary>
        /// Constructs an n-dimensional unit vector for i'th coordinate.
        /// </summary>
        /// <param name="n">Dimensionality of vector.</param>
        /// <param name="i">Coordinate index.</param>
        public
        ComplexVector(
            int n,
            int i
            )
        {
            _length = n;
            _data = new Complex[_length];
            _data[i] = 1.0;
        }

        /// <summary>
        /// Constructs an n-dimensional constant vector.
        /// </summary>
        /// <param name="n">Dimensionality of vector.</param>
        /// <param name="value">Fill the vector with this scalar value.</param>
        public
        ComplexVector(
            int n,
            Complex value
            )
        {
            _length = n;
            _data = new Complex[_length];
            for(int i = 0; i < _length; i++)
            {
                _data[i] = value;
            }
        }

        /// <summary>
        /// Constructs a vector from a 1-D array, directly using
        /// the provided array as internal data structure.
        /// </summary>
        /// <param name="components">One-dimensional array of doubles.</param>
        /// <seealso cref="Create(Complex[])"/>
        public
        ComplexVector(
            Complex[] components
            )
        {
            _length = components.Length;
            _data = components;
        }

        /// <summary>
        /// Constructs a vector from a copy of a 1-D array.
        /// </summary>
        /// <param name="components">One-dimensional array of doubles.</param>
        public static
        ComplexVector
        Create(
            Complex[] components
            )
        {
            if(null == components)
            {
                throw new ArgumentNullException("components");
            }

            Complex[] newData = new Complex[components.Length];
            components.CopyTo(newData, 0);

            return new ComplexVector(newData);
        }

        /// <summary>
        /// Constructs a complex vector from a real and an imaginary vector.
        /// </summary>
        /// <param name="realComponents">One-dimensional array of doubles representing the real part of the vector.</param>
        /// <param name="imagComponents">One-dimensional array of doubles representing the imaginary part of the vector.</param>
        public static
        ComplexVector
        Create(
            IList<double> realComponents,
            IList<double> imagComponents
            )
        {
            if(null == realComponents)
            {
                throw new ArgumentNullException("realComponents");
            }

            if(null == imagComponents)
            {
                throw new ArgumentNullException("imagComponents");
            }

            if(realComponents.Count != imagComponents.Count)
            {
                throw new ArgumentException(Properties.Resources.ArgumentVectorsSameLengths);
            }

            Complex[] newData = new Complex[realComponents.Count];
            for(int i = 0; i < newData.Length; i++)
            {
                newData[i] = new Complex(realComponents[i], imagComponents[i]);
            }

            return new ComplexVector(newData);
        }

        /// <summary>
        /// Constructs a complex vector from a real vector.
        /// </summary>
        /// <param name="realComponents">One-dimensional array of doubles representing the real part of the vector.</param>
        public static
        ComplexVector
        Create(
            IList<double> realComponents
            )
        {
            if(null == realComponents)
            {
                throw new ArgumentNullException("realComponents");
            }

            Complex[] newData = new Complex[realComponents.Count];
            for(int i = 0; i < newData.Length; i++)
            {
                newData[i] = new Complex(realComponents[i], 0d);
            }

            return new ComplexVector(newData);
        }

        // TODO: Add Random Vector Generations Methods here

        /// <summary>
        /// Generates an n-dimensional vector filled with 1.
        /// </summary>
        /// <param name="n">Dimensionality of vector.</param>
        public static
        ComplexVector
        Ones(
            int n
            )
        {
            return new ComplexVector(n, 1.0);
        }

        /// <summary>
        /// Generates an n-dimensional vector filled with 0.
        /// </summary>
        /// <param name="n">Dimensionality of vector.</param>
        public static
        ComplexVector
        Zeros(
            int n
            )
        {
            return new ComplexVector(n);
        }

        /// <summary>
{'fraction_non_alphanumeric': 0.1066914498141264, 'fraction_numerical': 0.004535315985130112, 'mean_word_length': 1.532191265060241, 'pattern_counts': {'":': 0, '<': 127, '<?xml version=': 0, '>': 122, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1692554', 'n_tokens_mistral': 3414, 'n_tokens_neox': 3279, 'n_words': 1047}