Class: Vector

### Home Classes Methods

### In Files

- lib/classifier/extensions/vector.rb

### Parent

Object

### Methods

- #magnitude
- #normalize

### Class/Module Index

Quicksearch

- Classifier
- Classifier::Bayes
- Classifier::ContentNode
- Classifier::LSI
- Classifier::WordList
- GSL
- GSL::Matrix
- GSL::Vector
- Array
- Matrix
- Object
- String
- Vector

No matching classes.

# Vector

### Public Instance Methods

magnitude() click to toggle source

    # File lib/classifier/extensions/vector.rb, line 22
    def magnitude
      sumsqs = 0.0
      self.size.times do |i|
        sumsqs += self[i] ** 2.0
      end
      Math.sqrt(sumsqs)
    end

normalize() click to toggle source

    # File lib/classifier/extensions/vector.rb, line 29
    def normalize
      nv = []
      mag = self.magnitude
      self.size.times do |i|

        nv << (self[i] / mag)

      end
      Vector[*nv]
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.