由于找不到文件或目录的问题,我目前无法在其 docker 容器中启动 SQL Server 2022。但错误消息的输出没有给出我所缺少的任何线索。该容器能够在今天之前启动(我对主机进行了更新并重新启动,没有任何更改应该不允许执行):
Attaching to db-1
db-1 | SQL Server 2022 will run as non-root by default.
db-1 | This container is running as user mssql.
db-1 | Your master database file is owned by mssql.
db-1 | To learn more visit https://go.microsoft.com/fwlink/?linkid=2099216.
db-1 | This program has encountered a fatal error and cannot continue running at Mon Jan 15 16:34:36 2024
db-1 | The following diagnostic information is available:
db-1 |
db-1 | Reason: 0x00000001
db-1 …Run Code Online (Sandbox Code Playgroud) 在 C 语言中,许多运算都采用位移位,其中经常使用整数文字。例如,考虑以下代码片段:
#define test_bit(n, flag) (1UL << (n) & (flag))
Run Code Online (Sandbox Code Playgroud)
据我所知,整数文字后缀UL应该抑制移位中不需要的行为,例如对有符号整数进行符号扩展可能会导致设置多个位。但是,如果情况只是进行左移,如上所示,我们还需要整数文字后缀吗?
由于左移不会导致意外行为,因此我无法弄清楚其目的是什么。像上面这样的代码经常出现在Linux内核等项目中,这让我觉得一定是有需要的。UL有谁知道这种情况下后缀的用途吗?
显示一个玩具示例,K=2但问题主要与高g基数和相关K>>1:
df = pl.DataFrame(dict(\n g=[1, 2, 1, 2, 1, 2],\n v=[1, 2, 3, 4, 5, 6],\n))\n\nK = 2\n\ndf.with_columns((col.v.shift(k+1).over(\'g\').alias(f\'s{k}\') for k in range(K)))\nRun Code Online (Sandbox Code Playgroud)\n\xe2\x95\xad\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\xac\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\xac\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\xac\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x95\xae\n\xe2\x94\x82 g \xe2\x94\x86 v \xe2\x94\x86 s0 \xe2\x94\x86 s1 \xe2\x94\x82\n\xe2\x94\x82 i64 \xe2\x94\x86 i64 \xe2\x94\x86 i64 \xe2\x94\x86 i64 \xe2\x94\x82\n\xe2\x95\x9e\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\xaa\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\xaa\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\xaa\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\xa1\n\xe2\x94\x82 1 \xe2\x94\x86 1 \xe2\x94\x86 null \xe2\x94\x86 null \xe2\x94\x82\n\xe2\x94\x82 2 \xe2\x94\x86 2 \xe2\x94\x86 null \xe2\x94\x86 null \xe2\x94\x82\n\xe2\x94\x82 1 \xe2\x94\x86 3 \xe2\x94\x86 1 \xe2\x94\x86 null \xe2\x94\x82\n\xe2\x94\x82 2 \xe2\x94\x86 4 \xe2\x94\x86 2 \xe2\x94\x86 null \xe2\x94\x82\n\xe2\x94\x82 1 …Run Code Online (Sandbox Code Playgroud) 三个点的项目是一个<ul>标签。每次li单击某个项目时,应用程序都会使用 routerLink 附加查询字符串(/bands、 /bands?active=false 和 /bands?active=true)导航到路线。
网页中从 Bands 开始的部分(属于band-list组件)是 router-outlet 根据路由显示的内容。下面的网格是根据查询参数“active”加载的。然后,每次li单击某个项目时,网格都会重新加载。
此外,“刷新数据”按钮会重新加载网格。
我正在尝试使用反应式编程来实现以下逻辑:
在初始化时,band-list组件应根据active路由中的查询参数加载网格。
每次用户单击 a 时li,网格都应重新加载。如果在此之前单击li网格仍在加载(发出 http 请求),则应取消正在进行的 http 请求(在我看来,这就像一个switchMap运算符)。
如果用户单击refresh data button并且网格已完成加载其数据,则网格应该加载。但是,如果网格仍在加载其数据(在 http 请求中间),则单击不应执行任何操作,即,进程内加载数据操作应完成,并且按钮中的单击实际上会被忽略(这看起来就像exhaustMap我一样:S)
另外,每次执行http操作时,当http操作尚未完成时,应该显示一条消息告诉“正在加载...”,并且应该清空网格中的数据。当 http 请求完成时,“正在加载...”消息应被删除,并且数据应显示在网格中。
我在组件中实现了代码,band-list就像下一个代码块一样,但我不确定该defer运算符在我的解决方案中的使用。我使用了该defer运算符,因为如果当前请求正在使用 defer 运算符内的变量进行处理,我需要维护状态,isLoading并且还要更新此变量作为运算符中的副作用操作tap,并使用此变量作为副作用在filter运营商中。
我的问题是:根据反应式编程,这是一种很好的方法吗?我可以做得更好吗?
@Component({
selector: 'app-band-list',
templateUrl: 'band-list.component.html', …Run Code Online (Sandbox Code Playgroud) 我正在尝试编写一个与numpy.sum双精度数组一样快的 C 程序,但似乎失败了。
以下是我衡量 numpy 性能的方法:
import numpy as np
import time
SIZE=4000000
REPS=5
xs = np.random.rand(SIZE)
print(xs.dtype)
for _ in range(REPS):
start = time.perf_counter()
r = np.sum(xs)
end = time.perf_counter()
print(f"{SIZE / (end-start) / 10**6:.2f} MFLOPS ({r:.2f})")
Run Code Online (Sandbox Code Playgroud)
输出是:
float64
2941.61 MFLOPS (2000279.78)
3083.56 MFLOPS (2000279.78)
3406.18 MFLOPS (2000279.78)
3712.33 MFLOPS (2000279.78)
3661.15 MFLOPS (2000279.78)
Run Code Online (Sandbox Code Playgroud)
现在尝试在 C 中做类似的事情:
float64
2941.61 MFLOPS (2000279.78)
3083.56 MFLOPS (2000279.78)
3406.18 MFLOPS (2000279.78)
3712.33 MFLOPS (2000279.78)
3661.15 MFLOPS (2000279.78)
Run Code Online (Sandbox Code Playgroud)
编译并gcc -o main …
我有一个光栅图像(20231031_110019.png,尽管它可以是任何格式,jpg,png,bmp)并且想单独
计算该栅格中离散区域的面积(我将它们称为“岛屿”,尽管它们实际上是培养皿上的真菌生长区域)。
我正在尝试使用 R 中的 spatstat 包来执行此操作。我发现一篇文章指出以下代码可以做到这一点:
library(spatstat)
## create example data
dd <- dilation(redwood, 0.5, polygonal=FALSE)
## find connected components
P <- connected(dd)
## convert to a tessellation
B <- tess(image=P)
## compute area of each tile
answer <- tile.areas(B)
Run Code Online (Sandbox Code Playgroud)
执行膨胀命令需要一个 owin 对象(上述实例中的 redwood),但我无法找到一种方法将栅格转换为 owin 对象,而无需使用 maptools 包,而该包在 CRAN 上已不再可用。我也无法使用 devtools 安装存档版本的 maptools。
解决这个问题的方法是什么?
还有另一种方法可以将栅格转换为可用的对象吗?
是否有同样简单的方法来计算光栅图像中真菌“岛”的面积?
非常感谢!
艾米丽
我正在 R 中解决一个有趣的问题(可能使用igraph和/或tidygraph库),我需要在图表上找到满足某些条件的所有可能路径。问题可以简化为:
我有16 个不同的节点,可以分为4组,每个节点都有一个特征,称之为颜色。*注意:以下可能不是表示数据的最佳方式,但希望它能传达情况。
nodes_set_1 <- c("red", "blue", "orange")
nodes_set_2 <- c("green", "blue", "red", "yellow", "purple")
nodes_set_3 <- c("blue", "green", "red", "orange", "purple")
nodes_set_4 <- c("orange", "blue", "green")
Run Code Online (Sandbox Code Playgroud)
我现在需要找到这些节点之间满足以下三个条件的所有可能路径: (1) 每条路径必须恰好包含每组中的一个节点。(2) 图形是从nodes_set_1到nodes_set_2到nodes_set_3到nodes_set_4
(3) 单个路径中颜色不能重复。
例如,以下路径是有效的:
path_1 <- c(nodes_set_1[1], nodes_set_2[1], nodes_set_3[1], nodes_set_4[1])
下面的路径将无效,因为颜色“蓝色”重复:
path_2 <- c(nodes_set_1[2], nodes_set_2[2], nodes_set_3[2], nodes_set_4[2])
我希望得到一些关于设置和解决这个问题的建议。找到一种有效确定是否不存在有效解决方案的方法也将令人惊奇。
谢谢你!
我正在将一个程序从 Pascal 翻译成 C。我已经很多年没有使用 C 语言了。这是相关的代码片段:
typedef struct querec *queptr;
struct querec {
char item;
queptr next;
};
struct queue {
queptr front,
rear;
};
struct queue qnum[5];
char item;
const char remove(struct queue *q)
{
queptr p;
char remove_result;
p = q->front;
remove_result = p->item;
q->front = p->next;
if (q->front == NULL)
q->rear = NULL;
return remove_result;
}
main()
{
...
item = remove(&qnum[3]);
}
Run Code Online (Sandbox Code Playgroud)
它不会在 Visual Studio 2015 中编译,报告以下内容:
Warning C4133 'function': incompatible types - from 'queue *' …Run Code Online (Sandbox Code Playgroud) 所以我对 R 还很陌生,我正在阅读 R for Data Science(2e) 这本书。
我从书中复制了下面所示的代码,它返回了不同的输出。我不知道为什么
书上的代码
x <- c(1 / 49 * 49, sqrt(2) ^ 2)
x
#> [1] 1 2
print(x, digits = 16)
#> [1] 0.9999999999999999 2.0000000000000004
Run Code Online (Sandbox Code Playgroud)
我的代码
print(sqrt(2)^2, digits = 16)
#[1] 2
#then tried saving it to an object, same output
sq_2 <- sqrt(2)^2
print(sq_2, digits = 16)
#[1] 2
Run Code Online (Sandbox Code Playgroud)
我还尝试将其保存为向量(单个项目),相同的输出
注意:问题是与类似代码的近似值不同。