我有一个:
> romberg := proc(f::algebraic, a, b, N,print_table)
local R,h,k,row,col;
R := array(0..N,0..N);
# Compute column 0, Trapezoid Rule approximations of
# 1,2,4,8,..2^N subintervals
h := evalf(b - a);
R[0,0] := evalf(h/2 * (f(a)+f(b)));
for row from 1 to N do;
h := h/2;
R[row,0] := evalf(0.5*R[row-1,0] +
sum(h*f(a+(2*k-1)*h),k=1..2^(row-1)));
# Compute [row,1]:[row,row], via Richardson extrapolation
for col from 1 to row do;
R[row,col] := ((4^col)*R[row,col-1] - R[row-1,col-1]) /
(4^col - 1);
end do;
end do;
# Display results if requested
if (print_table) then
for row from 0 to N do;
for col from 0 to row do;
printf("%12.10f ",R[row,col]);
end do;
printf("\n");
end do;
end if;
return(R[N,N]);
end proc:
f:=x->1/(1+x^2);
val:=romberg(f,0,1,4,true)
我尝试使用索引滚动到滚动条的任何部分:
<span id="quote-{{quote.id}}" ng-repeat="quote in quotes">{{quote.text}}</span>
然而,quotePosition.top的值总是等于10,这是$scope.jumpToQuote = function (quote) {
$scope.quoteSelected = quote;
var quotePosition = $ionicPosition.position(angular.element(document.getElementById('quote-'+quote)));
$ionicScrollDelegate.$getByHandle('quotes-box').scrollTo(quotePosition.left, quotePosition.top, true);
}
的顶部偏移量。
答案 0 :(得分:4)
据我所知,您需要将document.getElementById('quote-'+quote)
替换为document.getElementById('quote-'+quote.id)
,您正在连接整个quote
对象而不是id
。