PDL::Ops 2.4.3
Sponsored Links
PDL::Ops 2.4.3 Ranking & Summary
File size:
2.1 MB
Platform:
Any Platform
License:
Perl Artistic License
Price:
Downloads:
847
Date added:
2007-06-29
Publisher:
PDL::Ops team
PDL::Ops 2.4.3 description
PDL::Ops Perl module contains fundamental mathematical operators.
This module provides the functions used by PDL to overload the basic mathematical operators (+ - / * etc.) and functions (sin sqrt etc.)
It also includes the function log10, which should be a perl function so that we can overload it!
Matrix multiplication (the operator x) is handled by the module PDL::Primitive.
$doc
$c = $name $a, $b, 0; # explicit call with trailing 0
$c = $a $op $b; # overloaded call
$a->inplace->$name($b,0); # modify $a inplace
It can be made to work inplace with the $a->inplace syntax. This function is used to overload the binary $optxt operator. Note that when calling this function explicitly you need to supply a third argument that should generally be zero (see first example). This restriction is expected to go away in future releases. EOD } # sub: biop()
#simple binary functions sub bifunc { my ($name,$func,$swap,$doc,%extra) = @_; my $funcov = ref $func eq ARRAY ? $func->[1] : $func; my $isop=0; if ($funcov =~ s/^op//) { $isop = 1; } my $funcovp = protect_chars $funcov; $func = $func->[0] if ref $func eq ARRAY; if ($swap) { $extra{HdrCode} .= << EOH; pdl *tmp; if (swap) { tmp = a; a = b; b = tmp; } EOH } my $ovcall; # is this one to be used as a function or operator ? if ($isop) { $ovcall = "$c = $a $funcov $b; # overloaded use"; } else { $ovcall = "$c = $funcov $a, $b; # overloaded use"; } pp_def($name, HandleBad => 1, NoBadifNaN => 1, Pars => a(); b(); [o]c();, OtherPars => int swap, Inplace => [ a ], # quick and dirty solution to get ->inplace do its job Code => "$c() = $func($a(),$b());", BadCode => if ( $ISBAD(a()) || $ISBAD(b()) ) $SETBAD(c()); else . "n $c() = $func($a(),$b());n", CopyBadStatusCode => if ( $BADFLAGCACHE() ) { if ( a == c && $ISPDLSTATEGOOD(a) ) { PDL->propogate_badflag( c, 1 ); /* have inplace op AND badflag has changed */ } $SETPDLSTATEBAD(c); }, %extra, Doc => << "EOD"); =for ref
$doc
$c = $a->$name($b,0); # explicit function call
$ovcall
$a->inplace->$name($b,0); # modify $a inplace
It can be made to work inplace with the $a->inplace syntax. This function is used to overload the binary $funcovp function. Note that when calling this function explicitly you need to supply a third argument that should generally be zero (see first example). This restriction is expected to go away in future releases. EOD } # sub: bifunc()
# simple unary functions and operators sub ufunc { my ($name,$func,$doc,%extra) = @_; my $funcov = ref $func eq ARRAY ? $func->[1] : $func; my $funcovp = protect_chars $funcov; $func = $func->[0] if ref $func eq ARRAY;
# handle exceptions
my $badcode = $ISBAD(a());
if ( exists $extra{Exception} ) {
# $badcode .= " || $extra{Exception}";
# print "Warning: ignored exception for $namen";
delete $exists{Exception};
}
# do not have to worry about propogation of the badflag when
# inplace since only input piddle is a, hence its badflag
# wont change
# UNLESS an exception occurs...
pp_def($name,
Pars => a(); [o]b(),
HandleBad => 1,
NoBadifNaN => 1,
Inplace => 1,
Code =>
"$b() = $func($a());",
BadCode =>
if ( . $badcode . )
$SETBAD(b());
else . "n $b() = $func($a());n",
%extra,
Doc => << "EOD");
=for ref
$doc
$b = $funcov $a;
$a->inplace->$name; # modify $a inplace
It can be made to work inplace with the $a->inplace syntax. This function is used to overload the unary $funcovp operator/function. EOD } # sub: ufunc()
######################################################################
# we trap some illegal operations here -- see the Exception option # note, for the ufunc()s, the checks do not work too well # for unsigned integer types (ie < 0) # # XXX needs thinking about # - have to integrate into Code section as well (so # 12/pdl(2,4,0,3) is trapped and flagged bad) # --> complicated # - perhaps could use type %{ %} ? # # ==> currently have commented out the exception code, since # want to see if can use NaN/Inf for bad values # (would solve many problems for F,D types) # # there is an issue over how we handle comparison operators # - see Primitive/primitive.pd/zcover() for more discussion #
## arithmetic ops # no swap biop(plus,+,0,add two piddles); biop(mult,*,0,multiply two piddles);
# all those need swapping biop(minus,-,1,subtract two piddles); biop(divide,/,1,divide two piddles, Exception => $b() == 0 );
## note: divide should perhaps trap division by zero as well
## comparison ops # need swapping biop(gt,>,1,the binary > (greater than) operation); biop(lt,<,1,the binary < (less than) operation); biop(le,<=,1,the binary <= (less equal) operation); biop(ge,>=,1,the binary >= (greater equal) operation); # no swap required biop(eq,==,0,binary equal to operation (==)); biop(ne,!=,0,binary not equal to operation (!=));
## bit ops # those need to be limited to the right types my $T = [B,U,S,L]; # the sensible types here biop(shiftleft,<<,1,leftshift a$ by $b,GenericTypes => $T); biop(shiftright,>>,1,leftshift a$ by $b,GenericTypes => $T); biop(or2,|,0,binary or of two piddles,GenericTypes => $T); biop(and2,&,0,binary and of two piddles,GenericTypes => $T); biop(xor,^,0,binary exclusive or of two piddles,GenericTypes => $T);
# really an ufunc ufunc(bitnot,~,unary bit negation,GenericTypes => $T);
# some standard binary functions bifunc(power,[pow,op**],1,raise piddle $a to the power b,GenericTypes => [D]); bifunc(atan2,atan2,1,elementwise atan2 of two piddles,GenericTypes => [D]); bifunc(modulo,[MOD,op%],1,elementwise modulo operation); bifunc(spaceship,[SPACE,op<=>],1,elementwise ~ operation);
# some standard unary functions ufunc(sqrt,sqrt,elementwise square root, Exception => $a() < 0 ); ufunc(abs,[ABS,abs],elementwise absolute value,GenericTypes => [D,F,S,L]); ufunc(sin,sin,the sin function); ufunc(cos,cos,the cos function); ufunc(not,!,the elementwise not operation); ufunc(exp,exp,the exponential function,GenericTypes => [D]); ufunc(log,log,the natural logarithm,GenericTypes => [D], Exception => $a() <= 0 );
pp_export_nothing();
# make log10() work on scalars (returning scalars) # as well as piddles ufunc(log10,log10,the base 10 logarithm, GenericTypes => [D], Exception => $a() <= 0, PMCode => sub PDL::log10 { my $x = shift; if ( ! UNIVERSAL::isa($x,"PDL") ) { return log($x) / log(10); } my $y; if ( $x->is_inplace ) { $x->set_inplace(0); $y = $x; } elsif( ref($x) eq "PDL"){ #PDL Objects, use nullcreate: $y = PDL->nullcreate($x); }else{ #PDL-Derived Object, use copy: (Consistent with # Auto-creation docs in Objects.pod) $y = $x->copy; } &PDL::_log10_int( $x, $y ); return $y; }; );
# note: the extra code that adding HandleBad => 1 creates is # unneeded here. Things could be made clever enough to work this out, # but its very low priority. # It does add doc information though, and lets people know its been # looked at for bad value support # DJB adds: not completely sure about this now that I have added code # to avoid a valgrind-reported error (see the CacheBadFlagInit rule # in PP.pm) # # Cant this be handled in Core.pm when .= is overloaded ? # pp_def( assgn, # HandleBad => 1, Pars => a(); [o]b();, Code => $b() = $a();, # BadCode => # if ( $ISBAD(a()) ) { $SETBAD(b()); } else { $b() = $a(); }, Doc => Plain numerical assignment. This is used to implement the ".=" operator, ); # pp_def assgn
#pp_export_nothing();
pp_done();
This module provides the functions used by PDL to overload the basic mathematical operators (+ - / * etc.) and functions (sin sqrt etc.)
It also includes the function log10, which should be a perl function so that we can overload it!
Matrix multiplication (the operator x) is handled by the module PDL::Primitive.
$doc
$c = $name $a, $b, 0; # explicit call with trailing 0
$c = $a $op $b; # overloaded call
$a->inplace->$name($b,0); # modify $a inplace
It can be made to work inplace with the $a->inplace syntax. This function is used to overload the binary $optxt operator. Note that when calling this function explicitly you need to supply a third argument that should generally be zero (see first example). This restriction is expected to go away in future releases. EOD } # sub: biop()
#simple binary functions sub bifunc { my ($name,$func,$swap,$doc,%extra) = @_; my $funcov = ref $func eq ARRAY ? $func->[1] : $func; my $isop=0; if ($funcov =~ s/^op//) { $isop = 1; } my $funcovp = protect_chars $funcov; $func = $func->[0] if ref $func eq ARRAY; if ($swap) { $extra{HdrCode} .= << EOH; pdl *tmp; if (swap) { tmp = a; a = b; b = tmp; } EOH } my $ovcall; # is this one to be used as a function or operator ? if ($isop) { $ovcall = "$c = $a $funcov $b; # overloaded use"; } else { $ovcall = "$c = $funcov $a, $b; # overloaded use"; } pp_def($name, HandleBad => 1, NoBadifNaN => 1, Pars => a(); b(); [o]c();, OtherPars => int swap, Inplace => [ a ], # quick and dirty solution to get ->inplace do its job Code => "$c() = $func($a(),$b());", BadCode => if ( $ISBAD(a()) || $ISBAD(b()) ) $SETBAD(c()); else . "n $c() = $func($a(),$b());n", CopyBadStatusCode => if ( $BADFLAGCACHE() ) { if ( a == c && $ISPDLSTATEGOOD(a) ) { PDL->propogate_badflag( c, 1 ); /* have inplace op AND badflag has changed */ } $SETPDLSTATEBAD(c); }, %extra, Doc => << "EOD"); =for ref
$doc
$c = $a->$name($b,0); # explicit function call
$ovcall
$a->inplace->$name($b,0); # modify $a inplace
It can be made to work inplace with the $a->inplace syntax. This function is used to overload the binary $funcovp function. Note that when calling this function explicitly you need to supply a third argument that should generally be zero (see first example). This restriction is expected to go away in future releases. EOD } # sub: bifunc()
# simple unary functions and operators sub ufunc { my ($name,$func,$doc,%extra) = @_; my $funcov = ref $func eq ARRAY ? $func->[1] : $func; my $funcovp = protect_chars $funcov; $func = $func->[0] if ref $func eq ARRAY;
# handle exceptions
my $badcode = $ISBAD(a());
if ( exists $extra{Exception} ) {
# $badcode .= " || $extra{Exception}";
# print "Warning: ignored exception for $namen";
delete $exists{Exception};
}
# do not have to worry about propogation of the badflag when
# inplace since only input piddle is a, hence its badflag
# wont change
# UNLESS an exception occurs...
pp_def($name,
Pars => a(); [o]b(),
HandleBad => 1,
NoBadifNaN => 1,
Inplace => 1,
Code =>
"$b() = $func($a());",
BadCode =>
if ( . $badcode . )
$SETBAD(b());
else . "n $b() = $func($a());n",
%extra,
Doc => << "EOD");
=for ref
$doc
$b = $funcov $a;
$a->inplace->$name; # modify $a inplace
It can be made to work inplace with the $a->inplace syntax. This function is used to overload the unary $funcovp operator/function. EOD } # sub: ufunc()
######################################################################
# we trap some illegal operations here -- see the Exception option # note, for the ufunc()s, the checks do not work too well # for unsigned integer types (ie < 0) # # XXX needs thinking about # - have to integrate into Code section as well (so # 12/pdl(2,4,0,3) is trapped and flagged bad) # --> complicated # - perhaps could use type %{ %} ? # # ==> currently have commented out the exception code, since # want to see if can use NaN/Inf for bad values # (would solve many problems for F,D types) # # there is an issue over how we handle comparison operators # - see Primitive/primitive.pd/zcover() for more discussion #
## arithmetic ops # no swap biop(plus,+,0,add two piddles); biop(mult,*,0,multiply two piddles);
# all those need swapping biop(minus,-,1,subtract two piddles); biop(divide,/,1,divide two piddles, Exception => $b() == 0 );
## note: divide should perhaps trap division by zero as well
## comparison ops # need swapping biop(gt,>,1,the binary > (greater than) operation); biop(lt,<,1,the binary < (less than) operation); biop(le,<=,1,the binary <= (less equal) operation); biop(ge,>=,1,the binary >= (greater equal) operation); # no swap required biop(eq,==,0,binary equal to operation (==)); biop(ne,!=,0,binary not equal to operation (!=));
## bit ops # those need to be limited to the right types my $T = [B,U,S,L]; # the sensible types here biop(shiftleft,<<,1,leftshift a$ by $b,GenericTypes => $T); biop(shiftright,>>,1,leftshift a$ by $b,GenericTypes => $T); biop(or2,|,0,binary or of two piddles,GenericTypes => $T); biop(and2,&,0,binary and of two piddles,GenericTypes => $T); biop(xor,^,0,binary exclusive or of two piddles,GenericTypes => $T);
# really an ufunc ufunc(bitnot,~,unary bit negation,GenericTypes => $T);
# some standard binary functions bifunc(power,[pow,op**],1,raise piddle $a to the power b,GenericTypes => [D]); bifunc(atan2,atan2,1,elementwise atan2 of two piddles,GenericTypes => [D]); bifunc(modulo,[MOD,op%],1,elementwise modulo operation); bifunc(spaceship,[SPACE,op<=>],1,elementwise ~ operation);
# some standard unary functions ufunc(sqrt,sqrt,elementwise square root, Exception => $a() < 0 ); ufunc(abs,[ABS,abs],elementwise absolute value,GenericTypes => [D,F,S,L]); ufunc(sin,sin,the sin function); ufunc(cos,cos,the cos function); ufunc(not,!,the elementwise not operation); ufunc(exp,exp,the exponential function,GenericTypes => [D]); ufunc(log,log,the natural logarithm,GenericTypes => [D], Exception => $a() <= 0 );
pp_export_nothing();
# make log10() work on scalars (returning scalars) # as well as piddles ufunc(log10,log10,the base 10 logarithm, GenericTypes => [D], Exception => $a() <= 0, PMCode => sub PDL::log10 { my $x = shift; if ( ! UNIVERSAL::isa($x,"PDL") ) { return log($x) / log(10); } my $y; if ( $x->is_inplace ) { $x->set_inplace(0); $y = $x; } elsif( ref($x) eq "PDL"){ #PDL Objects, use nullcreate: $y = PDL->nullcreate($x); }else{ #PDL-Derived Object, use copy: (Consistent with # Auto-creation docs in Objects.pod) $y = $x->copy; } &PDL::_log10_int( $x, $y ); return $y; }; );
# note: the extra code that adding HandleBad => 1 creates is # unneeded here. Things could be made clever enough to work this out, # but its very low priority. # It does add doc information though, and lets people know its been # looked at for bad value support # DJB adds: not completely sure about this now that I have added code # to avoid a valgrind-reported error (see the CacheBadFlagInit rule # in PP.pm) # # Cant this be handled in Core.pm when .= is overloaded ? # pp_def( assgn, # HandleBad => 1, Pars => a(); [o]b();, Code => $b() = $a();, # BadCode => # if ( $ISBAD(a()) ) { $SETBAD(b()); } else { $b() = $a(); }, Doc => Plain numerical assignment. This is used to implement the ".=" operator, ); # pp_def assgn
#pp_export_nothing();
pp_done();
PDL::Ops 2.4.3 Screenshot
PDL::Ops 2.4.3 Keywords
PDL
GenericTypes
ISBAD
ARRAY
Ops 2.4.3
Ops Perl
Mathematical Operators
used to
to work
Perl module
be made
to overload
Inplace
b
FUNC
1
Bookmark PDL::Ops 2.4.3
PDL::Ops 2.4.3 Copyright
WareSeeker periodically updates pricing and software information of PDL::Ops 2.4.3 full version from the publisher, so some information may be slightly out-of-date. You should confirm all information before relying on it. Software piracy is theft, Using crack, password, serial numbers, registration codes, key generators is illegal and prevent future development of PDL::Ops 2.4.3 Edition. Download links are directly from our publisher sites, torrent files or links from rapidshare.com, yousendit.com or megaupload.com are not allowed
Featured Software
Want to place your software product here?
Please contact us for consideration.
Contact WareSeeker.com
Related Information
liver function
functionalism
functional training
functional resume
functions
kidney function
functional groups
functional training exercises
function grapher
trigonometric functions
liver function test
functionality
high functioning autism
trig functions
liver function tests
exceptional customer service
functions of management
c++ mathematical operators
Related Software
PDL::Tips is a Perl module with small tidbits of useful arcana. Free Download
PDL::API is a Perl module for making piddles from Perl and C/XS code. Free Download
PDL::MatrixOps Perl module contains some useful Matrix operations. Free Download
PDL::IO::Misc is a Perl module with misc IO routines for PDL. Free Download
PDL::IO::FITS Perl module offers a simple FITS support for PDL. Free Download
PDL::Bad - PDL does not process bad values. Free Download
PDL::Slices is a Perl module used for indexing, slicing, and dicing. Free Download
PDL::FAQ is a Perl module for frequently asked questions about PDL. Free Download
Latest Software
Popular Software
Favourite Software