问题列表 - 第36061页

什么是银行冲突?(做Cuda/OpenCL编程)

我一直在阅读CUDA和OpenCL的编程指南,我无法弄清楚银行冲突是什么.他们只是倾向于如何解决问题而不详细说明主题本身.任何人都可以帮我理解吗?如果帮助是在CUDA/OpenCL的背景下,或者只是计算机科学中的银行冲突,我没有偏好.

cuda nvidia opencl bank-conflict

91
推荐指数
4
解决办法
4万
查看次数

抛出与OnePerRequestModule相关的Ninject Intermittent异常

我刚刚将Ninject的现有实现从1.5升级到2.0.我现在看到在短时间内发生许多请求时会出现间歇性异常.

这是抛出的异常.

类型: System.ArgumentException
消息:已添加具有相同键的项.
来源: Ninject
堆栈跟踪: 在System.ThrowHelper.ThrowArgumentException(ExceptionResource资源)
在System.Collections.Generic.Dictionary`2.Insert(TKEY的关键,TValue值,布尔加)
在System.Collections.Generic.Dictionary`2.Add (TKEY的键,TValue值)
在Ninject.Components.ComponentContainer.CreateNewInstance(类型分量类型的实现)
在Ninject.Components.ComponentContainer.ResolveInstance(类型分量类型的实现)
在Ninject.Components.ComponentContainer.Get(类型分量)
在Ninject.Components.ComponentContainer <CreateNewInstance> b__6(的ParameterInfo参数)
在System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
在System.Linq.Buffer`1..ctor(IEnumerable`1源)
在System.Linq的.inumerable.ToArray [TSource](IEnumerable`1 source)
位于Ninject.Compone上的Ninject.Compone上的Ninject.Components.Component.CreateNewInstance(类型组件,类型实现)
Ninject.Compone上的Ninject.Compone上的Ninject.Components.Component.ResolveInstance(Type组件,类型实现)
. 在Ninject.KernelBase.CreateContext(IRequest请求,IBinding绑定)的
Ninject.Components.ComponentContainer.GetT 获取(类型组件
)
在Ninject.KernelBase.<> c__DisplayClassa.<解决> b__6(IBinding结合)
在System.Linq.Enumerable.<> c__DisplayClass12`3.<CombineSelectors> b__11(TSource X)
在System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext ()
在System.Linq.Enumerable.<CastIterator> d__aa`1.MoveNext()
在System.Linq.Enumerable.Single [TSource](IEnumerable`1源)
在Ninject.ResolutionExtensions.Get [T](IResolutionRoot根,IParameter []参数)
NameOfConsumingSite .Application_BeginRequest(Object sender,EventArgs e)...

如果我OnePerRequestModulehttpModulesweb.config中删除该项,则不会抛出异常,但这会增加大量开销.

如果他们可以提供帮助我提前感谢任何人!

ninject httpmodule ninject.web ninject-2

6
推荐指数
1
解决办法
705
查看次数

使用php修复不均匀的Div

我有一个看起来像这样的问题:

我的文本字符串如下:

<div>
    content
    <div>
         <div>
         content
              <div>

         </div>
    </div>
Run Code Online (Sandbox Code Playgroud)

如果你注意到我错过了一些div,当我在其他地方使用这些内容时,这可能会破坏我的主题.

解决这类问题的最佳方法是什么?这就是我自己拥有的,但往往不够好.此函数试图通过不修复它来解决问题,而是将其装入以防止破坏的html破坏我的其他html的可能性.

 function ($string)
 {
     $div_open = substr_count($string, "<div");   
     $div_close = substr_count($string, "</div>"); 

     while ($div_close<$div_open)
     {    
         $string = "$string</div>";
         $div_close = substr_count($string, "</div>");
         if ($i>1000){echo 'pop 3'; exit;}else{$i++;}
     }
     while ($div_close>$div_open)
     {    
         $string = "<div>$string";
         $div_open = substr_count($string, "<div");
         if ($i>1000){echo 'pop 4 '; exit;}else{$i++;}
     }

     return $string;
 }
Run Code Online (Sandbox Code Playgroud)

有没有更好的办法?

php html-parsing

1
推荐指数
1
解决办法
191
查看次数

按比例在FormResize上重新定位图像

我有一个带有TImages的Delphi表单.实际上,它是一个带有"图标"的"假"桌面(TImages).

当用户调整表单大小(例如,缩放或最大化表单)时,表单上的图标应按比例对齐.

现在,我正在用图像做这样的事情:

ImageX.Left:=Round(ImageX.Left * (Width / OldWidth));
ImageX.Top:=Round(ImageX.Top * (Height / OldHeight));
Run Code Online (Sandbox Code Playgroud)

现在这没关系,只要我开始使最大化的形式更小.

在这种情况下,最右边的图像部分地由表单的边框切割(它们离开表单的客户区域).

如果我重新定位这些图像以适合客户区域,那么在缩小到最大尺寸时图标的位置会变形.

任何更好的算法/修复的想法?

谢谢!

forms delphi scaling resize

2
推荐指数
1
解决办法
591
查看次数

如何在iOS应用程序中嵌入配置文件

我在iOS企业开发人员计划文档中读到,可以在应用程序中嵌入配置文件.

我想知道这是怎么做到的.它是简单地添加到IPA的Payload目录中,还是包含在项目目录中?

我也想知道这种技术是否通常适用于所有部署模式/程序,还是仅用于企业分发部署?

iphone enterprise ios

19
推荐指数
1
解决办法
2万
查看次数

需要帮助重构这个Javascript if/else语句

这是我当前的if/else语句:

var current_class = $(this).closest("article").attr("class")

if (current_class == 'opened')
{
  $(this).closest("article").removeClass('opened');
  $(this).closest("article").addClass('closed');
}
else
{
  $(this).closest("article").removeClass('closed');
  $(this).closest("article").addClass('opened');
}
Run Code Online (Sandbox Code Playgroud)

是否有更短的方式来写所有这些?看起来......超重.:)

javascript refactoring if-statement

1
推荐指数
1
解决办法
315
查看次数

可以realloc缩小左侧的数组(仅限C)吗?

我想移动我记忆中的一大块数据.不幸的是,这些数据被保存为数组,我无法改变它.我不能使用循环数组,因为我不想改变的一些fortran方法也使用相同的内存.最重要的是,在运动之间非常频繁地访问阵列.所以我可以这样做:

int *array = (int*) malloc(sizeof(int)*5);
int *array2=NULL;
//Now i want to move my data one step to the left
array=(int*) realloc(array,6);
array2=array+1;
memmove(array,array2,5*sizeof(int));
array=(int*) realloc(array,5);
Run Code Online (Sandbox Code Playgroud)

这应该工作正常,但它看起来很浪费;).如果我可以告诉我的编译器拿走缩小数组左侧的数据,我的数据会在内存中蔓延,但我不需要进行任何复制.像这样:

int *array = (int*) malloc(sizeof(int)*5);
//Now i want to move my data one step to the left
array=(int*) realloc(array,6);
array=(int*) realloc_using_right_part_of_the_array(array,5);
Run Code Online (Sandbox Code Playgroud)

所以基本上我想用指针完成,array+1剩下的4个字节被释放.我打得四处free()malloc(),但它没有工作......我知道,realloc的还可能会导致的memcpy调用,但不是每次!所以它可能会更快,不是吗?

c realloc shrink

4
推荐指数
1
解决办法
1444
查看次数

F#类型如何转移到C#?

如果在F#中我有以下方法:

drawBox
drawSphere
paintImage
Run Code Online (Sandbox Code Playgroud)

它们会被转移到C#,完全一样吗?

如果是这种情况,那么它不会破坏C#中的命名约定,其中方法应该是PascalCase吗?

或者我应该在F#中使用PascalCase来解决这个问题吗?

c# f# naming-conventions

5
推荐指数
2
解决办法
405
查看次数

如果可用,使用C#方法组有什么好处吗?

处理类似的事情时,List<string>您可以写下以下内容:

list.ForEach(x => Console.WriteLine(x));
Run Code Online (Sandbox Code Playgroud)

或者您可以使用方法组执行相同的操作:

list.ForEach(Console.WriteLine);
Run Code Online (Sandbox Code Playgroud)

我更喜欢第二行代码,因为它对我来说看起来更干净,但这有什么好处吗?

c# method-group

19
推荐指数
4
解决办法
2240
查看次数

AJAX轮询频率 - 长期民意调查还是不长期民意调查?

我正在构建一个需要相对不变的数据库轮询的网页组件.我可以看到两种不同的方法,我想知道其中一种是否比其他方法更好,或者我是否缺少第三种选择.

1)每隔1或2秒发送一次AJAX请求以检查更新.无论是否有新数据,每个请求都会立即返回.
2)触发单个AJAX请求,该请求在收到数据或发生超时之前不会返回.在其中任何一个发生时,它会触发下一个请求.(我认为这叫做长轮询?)

数据库查询的数量与之相同,但使用#2,从浏览器发出的请求将减少,这可以节省带宽和客户端资源.对于服务器,最好让一个PHP请求保持活动状态并在查询之间休眠,或者每隔几秒触发一次,轮询数据库,然后关闭?或者没有区别,我对此太过强调了?

编辑:我想我还应该声明这是一个更大的网络应用程序的聊天小部件.通信的轻微延迟不会杀死用户,因为聊天是次要功能.

php ajax performance comet long-polling

14
推荐指数
1
解决办法
4621
查看次数