Class: NVector

### Home Classes Methods

### In Files

- src/na_linalg.c
- nmatrix.rb

### Parent

cNArray

### Methods

- #*
- #**
- #+
- #-
- #/
- #coerce_rev

### Files

- ChangeLog
- MANIFEST
- SPEC.en.txt
- Makefile
- depend

### Class/Module Index

Quicksearch

- FFTW
- NArray
- NArrayScalar
- NMath
- NMatrix
- NMatrixLU
- NVector

No matching classes.

# NVector

------ NVector ------

### Constants

CLASS_DIMENSION

### Public Instance Methods

*(other) click to toggle source

    # File nmatrix.rb, line 188
    def *(other)
      case other
      when NMatrix
        NVector.mul_add( NArray.refer(self).newdim!(0), other, 1 )
      when NVector
        NArray.mul_add( NArray.refer(self), other, 0 ) # inner product
      when NArray
        if other.instance_of?(NArray)
          NVector.mul( NArray.refer(self), other.newdim(0) )
        else
          other.coerce_rev( self, :* )
        end
      when Numeric
        NVector.mul( NArray.refer(self), other )
      else
        raise TypeError,"Illegal operation: NVector * %s" % other.class
      end
    end

**(n) click to toggle source

    # File nmatrix.rb, line 226
    def **(n)
      if n==2
        self*self
      else
        raise ArgumentError,"Only v**2 is implemented"
      end
    end

+(other) click to toggle source

    # File nmatrix.rb, line 164
    def +(other)
      case other
      when NVector
        return super(NArray.refer(other))
      when NArray
        unless other.instance_of?(NArray)
          return other.coerce_rev( self, :+ )
        end
      end
      raise TypeError,"Illegal operation: NVector + %s" % other.class
    end

-(other) click to toggle source

    # File nmatrix.rb, line 176
    def -(other)
      case other
      when NVector
        return super(NArray.refer(other))
      when NArray
        unless other.instance_of?(NArray)
          return other.coerce_rev( self, :- )
        end
      end
      raise TypeError,"Illegal operation: NVector - %s" % other.class
    end

/(other) click to toggle source

    # File nmatrix.rb, line 207
    def /(other)
      case other
      when NMatrix
        other.lu.solve(self)
      when NVector
        raise TypeError,"Illegal operation: NVector / %s" % other.class
      when NArray
        if other.instance_of?(NArray)
          NVector.div( NArray.refer(self), other.newdim(0) )
        else
          other.coerce_rev( self, :/ )
        end
      when Numeric
        NVector.div( NArray.refer(self), other )
      else
        raise TypeError,"Illegal operation: NVector / %s" % other.class
      end
    end

coerce_rev(other,id) click to toggle source

    # File nmatrix.rb, line 234
    def coerce_rev(other,id)
      case id
      when :*
          if other.instance_of?(NArray)
            return NVector.mul( other.newdim(0), self )
          end
          if other.instance_of?(NArrayScalar)
            return NVector.mul( other, self )
          end
      end
      raise TypeError,"Illegal operation: %s %s NVector" %
        [other.class, id.id2name]
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.