Class: CAVector

Inherits:
CAWrap
  • Object
show all
Defined in:
ext/carray_gsl.c,
lib/carray-gsl/core.rb

Instance Method Summary collapse

Instance Method Details

#*(other) ⇒ Object



701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
# File 'lib/carray-gsl/core.rb', line 701

def * (other)
  case other
  when CAVector
    CArray.attach(self, other) {
      out = self.gv * other.gv
      case out
      when GSL::Matrix
        return out.ca.m
      when GSL::Vector
        return out.ca.v
      else
        return out
      end
    }
  when CAMatrix
    CArray.attach(self, other) {
      return (self.gv * other.gm).ca.v
    }
  when CArray
    CArray.attach(self, other) {
      return (self[] * other).v
    }
  else
    attach {
      return (self.gv * other).ca.v   
    }
  end
end

#normObject



741
742
743
744
745
# File 'lib/carray-gsl/core.rb', line 741

def norm
  attach {
    return self.gv.nrm2
  }
end

#normalize(nrm = 1.0) ⇒ Object



747
748
749
750
751
# File 'lib/carray-gsl/core.rb', line 747

def normalize (nrm=1.0)
  attach {
    return self.gv.normalize(nrm).ca.v
  }
end

#normalize!Object



753
754
755
756
757
758
# File 'lib/carray-gsl/core.rb', line 753

def normalize!
  attach {
    self.gv.normalize!(nrm)
  }
  return self
end

#tObject



732
733
734
735
736
737
738
739
# File 'lib/carray-gsl/core.rb', line 732

def t
  case rank
  when 1
    return self.reshape(elements,1).v
  else
    return t_orig.v
  end
end

#t_origObject



730
# File 'lib/carray-gsl/core.rb', line 730

alias t_orig t