<commit_before>#![doc="Defines generic traits for numbers on which
SciRust library works.
"]


// std imports
use std::num::{Int, SignedInt, Float};

// complex numbers
pub use external::complex::{Complex32, Complex64};

// local imports
use entry::{Entry, Zero, One};


/// Defines basic requirements for a matrix of numbers
pub trait Number : Entry
    + Clone
    + Copy
    + Add<Self,Self>
    + Sub<Self, Self> 
    + Mul<Self, Self> 
    + Div<Self, Self>
    + PartialEq
    + One
    + Zero{

    #[inline]
    fn is_float(&self) -> bool {
        false
    }

    #[inline]
    fn is_int(&self) -> bool {
        false
    }

    #[inline]
    fn is_complex(&self) -> bool {
        false
    }

    fn is_signed(&self) -> bool;
}


pub trait Signed: Number + Neg<Self> {
    fn abs_val(&self) -> Self;
    fn signum(&self) -> Self;
    fn is_positive(&self) -> bool;
    fn is_negative(&self) -> bool;
}

<commit_msg>power<commit_after>#![doc="Defines generic traits for numbers on which
SciRust library works.
"]


// std imports
use std::num::{Int, SignedInt, Float};

// complex numbers
pub use external::complex::{Complex32, Complex64};

// local imports
use entry::{Entry, Zero, One};


/// Defines basic requirements for a matrix of numbers
pub trait Number : Entry
    + Clone
    + Copy
    + Add<Self,Self>
    + Sub<Self, Self> 
    + Mul<Self, Self> 
    + Div<Self, Self>
    + PartialEq
    + One
    + Zero{

    #[inline]
    fn is_float(&self) -> bool {
        false
    }

    #[inline]
    fn is_int(&self) -> bool {
        false
    }

    #[inline]
    fn is_complex(&self) -> bool {
        false
    }

    fn is_signed(&self) -> bool;

    fn power(&self, n : uint)-> Self{
        if n == 0 {
            return One::one();
        }
        let mut result = *self;
        for _ in range(0, n - 1){
            result = result.mul(self);
        }
        result
    }
}


pub trait Signed: Number + Neg<Self> {
    fn abs_val(&self) -> Self;
    fn signum(&self) -> Self;
    fn is_positive(&self) -> bool;
    fn is_negative(&self) -> bool;
}


{'fraction_non_alphanumeric': 0.14395393474088292, 'fraction_numerical': 0.00527831094049904, 'mean_word_length': 2.183206106870229, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 30, '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': '5060474', 'n_tokens_mistral': 713, 'n_tokens_neox': 696, 'n_words': 196}