由买买提看人间百态

topics

全部话题 - 话题: temp1
1 2 下页 末页 (共2页)
r******e
发帖数: 115
1
来自主题: Statistics版 - SAS问题再请教
我有两个data set. 第一个set, temp1 有三列
date_n t count
1 100 3
1 103 2
1 106 7
.. .. ..
1 300 11
2 102 2
2 107 1
2 111 1
.. .. ..
2 300 5
3 100 4
.. .. ..
100 300 1
第二个set, temp2 有两列
date_n t
1 100
1 101
1 102
.. ..
100 300
temp2 的行比temp1多(temp1 的行, temp2都有 )
现在要生成第三个data set, temp3. temp3有三列 date_n , t, count,
temp 3 前两列date_n, t... 阅读全帖
c**r
发帖数: 150
2
来自主题: Programming版 - 定义 单链表 数组,会不会很奇怪

////////////////////////////////////////////////////////////////////
void node_insert(int Loc, struct node *pvlist, struct node *newvstr, int *
Clist)
//Clist记载了某个node对应的链表的长度
{
int i=1, clist=*Clist;
struct node *temp, *temp1;
temp=temp1=pvlist;

if(Loc==0){
if(temp->value==-1){
temp->value=newvstr->value;
}
else{
newvstr->next=temp->next;
temp=newvstr;
}
}
else{//问题出现在这!!
while(i temp1=temp1->next;
i++;... 阅读全帖
c**r
发帖数: 150
3
来自主题: Programming版 - 定义 单链表 数组,会不会很奇怪

////////////////////////////////////////////////////////////////////
void node_insert(int Loc, struct node *pvlist, struct node *newvstr, int *
Clist)
//Clist记载了某个node对应的链表的长度
{
int i=1, clist=*Clist;
struct node *temp, *temp1;
temp=temp1=pvlist;

if(Loc==0){
if(temp->value==-1){
temp->value=newvstr->value;
}
else{
newvstr->next=temp->next;
temp=newvstr;
}
}
else{//问题出现在这!!
while(i temp1=temp1->next;
i++;... 阅读全帖
c***2
发帖数: 838
4
来自主题: JobHunting版 - 找最大俩数的代码怎么写?
doing the tournament with complexity N+lgN in the cost of extra stack spaces
used for recursion
straightforward 2-pass scanning takes N-1+N-2=2N-3 with no extra space
Tournament:
void find_max_2max(int a[], int start, int end, int *max, int *max2)
{
int i, mid;
int max00,max01,max10,max11;
int temp1,temp2;

if(start==end){
*max=a[start];
*max2=a[start];
return;
}

if(end-start==1){
*max=MAX(a[start],a[end]);
*max2=MIN(a[start]... 阅读全帖
c*****g
发帖数: 33
5
来自主题: JobHunting版 - 今天晚上上一题
若是以相邻的移动为配对
先右再左 == 向左移一步
先左再右 == 向右移一步
先假设x为正 (负数的话其实答案是一样的 只是移动方向相反)
先从0开始同一方向累加至最靠近x的点z(超过x也可以, 若x正好在中间, 取小的那点为
z)
若是z=x, 那就找到
若是z>x, 那就向左移(z-x)步, 也就是要移动2(z-x)次
若是z 简单实作一下
if(x == 0)
return 0;
int counter = 0;
int acc = 0;
float temp1 = 0; // 其实可省略
while(acc {
counter++;
temp1++;
acc = acc + temp1;
}
if(acc-abs(x) return counter+(acc-abs(x))*2;... 阅读全帖
G********L
发帖数: 12
6
可能要这样才能满足楼主的要求。
proc sort data=one;
by company year product;
run;
data two (drop=count temp1 temp2);
set one;
by year notsorted;
retain count temp1 temp2;
if _n_=1 then do;
temp2=0;
temp1=company;
end;
if temp1 NE company and first.year then temp2=count;
if first.year then count=0;

count+1;
newvar=temp2+count;
temp1=company;
run;
f*******n
发帖数: 8
7
来自主题: JobHunting版 - 问一算法题
我贴一下O(n)算法的实现吧,大家自己琢磨
#include "stdio.h"
//轮换
void Cycle(int Data[],int Lenth,int Start)
{
      int Cur_index,Temp1,Temp2;
      Cur_index=(Start*2)%(Lenth+1);
      Temp1=Data[Cur_index-1];
      Data[Cur_index-1]=Data[Start-1];
   
     while(Cur_index!=Start)
     {
   &... 阅读全帖
s*********s
发帖数: 318
8
来自主题: JobHunting版 - 问个面试题
http://tiny/1fpew40ab/stacques5347howt
好像也没有明确答案。
我save了一份答案,号称O(N),不知道对不对?
#include "stdio.h"
//轮换
void Cycle(int Data[], int Length, int Start) {
int Cur_index, Temp1, Temp2;
Cur_index = (Start * 2) % (Length + 1);
Temp1 = Data[Cur_index - 1];
Data[Cur_index - 1] = Data[Start - 1];
while (Cur_index != Start) {
Temp2 = Data[(Cur_index * 2) % (Length + 1) - 1];
Data[(Cur_index * 2) % (Length + 1) - 1] = Temp1;
Temp1 = Temp2;
Cur_index = (Cur_in... 阅读全帖
I*******g
发帖数: 7600
9
来自主题: JobHunting版 - 问一个G家面试题
很简单:
只要两个变量
Space:O(1)
Time: O(n)
BigInteger bit = new BigInteger("0");
int temp1 =0;
for(int x:array){
if (!bit.testBit(x)){
bit =bit.setBit(x);
temp1 ^= x;
}
}

for(int x:array){
temp1 ^= x;
}
System.out.println(temp1);
s*****a
发帖数: 2735
10
谢water 和 wuyi。
我的问题可能不在textscan,应该是loop上太菜了(原谅我是新手,哈哈)
我还是考虑吧文件贴出来,请认识的帮看看,run run。
data file:
https://www.dropbox.com/s/83nd46ny7gunyhv/data.csv
test code:
https://www.dropbox.com/s/vvzfw6uhhgkekbd/test.m
————————————————————————————————————-
test code copy:(我两个方法都出错了,虽然能够正常读入)
%% input 1
fid_t = fopen(...
'C:\**\data.csv', ... % <------------- address
'r');
while ~feof(fid_t)
temp1 = fgetl(fid_t);
temp2 = regexprep(temp1, '"', '');
line = csv2cell(temp2);

if strcmp(... 阅读全帖
w****h
发帖数: 212
11
来自主题: Programming版 - 问一个关于C++指针的问题
有一段代码:
Node** List;
Node* temp1=*List;
*List=temp1;
那么,我的理解是,(*List)是一个指向Node类型的指针,temp1又是个指向Node类型
的指针,最后一句是把(*List)赋值为temp1这个指针。
不知道对不对。问题是,为什么不直接用Node* List,而用Node** List?
s*****a
发帖数: 2735
12
来自主题: Computation版 - matlab 做不规则 数据输入,求教
谢了个小程序,用来读入不规则的data,能够读入,但是会报错。
应该是loop上太菜了(原谅我是新手,真不好意思)
我把文件贴出来,请认识的帮看看,run run。
这个问题困扰很久了,还有自己的方法可能真的有点笨,请指点,万分感谢。
data file:
https://www.dropbox.com/s/83nd46ny7gunyhv/data.csv
test code:
https://www.dropbox.com/s/vvzfw6uhhgkekbd/test.m
————————————————————————————————————-
test code copy:(下边两个方法都出错了,虽然能够正常读入)
%% input 1
fid_t = fopen(...
'C:\**\data.csv', ... % <------------- address
'r');
while ~feof(fid_t)
temp1 = fgetl(fid_t);
temp2 = regexprep(temp1, '"', '');
line = c... 阅读全帖
s**********l
发帖数: 395
13
Sorry, I cannot type in Chinese now.
Hi All,
I need to use the combination conditions of two variables: temp1 or temp2
and another eight variables: c01-c08 to define the value of r1 and r2.
However, I did not get what I wanted.
The data and the results should be like this(only selected several variables
):
C08 C05 C07 C02 temp1 temp2 r1 r2
1385 6 4 74 0.8 0.2 60 103
445 4 5 91 0.2 0.7 103 103
170 15 5 67 0.1 0.5 12 ... 阅读全帖
a*****n
发帖数: 230
14
I have been waiting for this for 10 years. But this noon, I saw this line:
The byte code compiler and interpreter now include new instructions that
allow many scalar subsetting and assignment and scalar arithmetic operations
to be handled more efficiently. This can result in significant performance
improvements in scalar numerical code.
I immediately downloaded the latest R build and benchmark against a KD-tree
code I wrote.
R Build from 20 days ago: 8.45 minutes
R build of today: 5.01 minutes
A... 阅读全帖
Y*****y
发帖数: 361
15
恩,这个分组idea我明白,不太明白的是code里面最后的实现。那里是用j作为index从
头扫到尾,然后对每个inputArray[j]进行判断,如果indexOf1这一位是1,update
temp1到inputArray[j],否则update temp2到inputArray[j]。最后的输出结果temp1和
temp2。
作为一个例子,假设N1,N2是出现过一次的数,且N1在那位上是1,N2是0。假设N3,N4出
现过两次,N3该位是1,N4是0。如果这个inputArray是这样的,{N3,N4,N1,N2,N3,N4},
用上面code里面的方法,最后temp1指向第二个N3,temp2指向第二个N4,得出的结果好
像不太对。 就算不用code里面的方法,我的疑问是,对这个例子,如何可以不重新排
序或空间复杂度是O(1),而直接把原来的数组分成两个组,且具有你说的那个性质(N1
和N2被划分到不同的组,每个组里面其他元素都出现两次)。
或者我的理解有问题,多谢指教。

在一起
被简化
s****e
发帖数: 638
16
来自主题: JobHunting版 - 这题有最优解法么
扫描一遍数组,<=0的数字不管,大于数组长度的数字扔掉,其余的重新排列在数组中

扫描第二遍,返回第一个小于等于0的数组index。
int findPosMissing(int* arr, int size) {
for (int i=0; i if (arr[i] == i+1) continue;
int temp = arr[i];
arr[i] = 0;
int temp1;
while (true) {
if (temp <=0 ) break;
if (temp > size ) break;
if (arr[temp-1] == temp) break;
temp1 = arr[temp-1];
arr[temp-1]= temp;
temp = temp1;
}
}
for (int i=0; i if (arr[i]<=0){
return i+1;
... 阅读全帖
s****e
发帖数: 638
17
来自主题: JobHunting版 - 这题有最优解法么
扫描一遍数组,<=0的数字不管,大于数组长度的数字扔掉,其余的重新排列在数组中

扫描第二遍,返回第一个小于等于0的数组index。
int findPosMissing(int* arr, int size) {
for (int i=0; i if (arr[i] == i+1) continue;
int temp = arr[i];
arr[i] = 0;
int temp1;
while (true) {
if (temp <=0 ) break;
if (temp > size ) break;
if (arr[temp-1] == temp) break;
temp1 = arr[temp-1];
arr[temp-1]= temp;
temp = temp1;
}
}
for (int i=0; i if (arr[i]<=0){
return i+1;
... 阅读全帖
t****t
发帖数: 6806
18
来自主题: JobHunting版 - 三妹比三哥还威武啊
你们说的反转链表是不是这种
template
T* reverse_linklist(T* p)
{
T * temp1, * temp2;
temp2=NULL;
while (p) {
temp1=p->next;
p->next=temp2;
temp2=p;
p=temp1;
}
return temp2;
}
d**e
发帖数: 6098
19
来自主题: JobHunting版 - [合集] 三妹比三哥还威武啊
☆─────────────────────────────────────☆
yangcheng (牛魔王) 于 (Tue Apr 24 16:57:24 2012, 美东) 提到:
自称做过无数iPhone
问objective C, 语法都不知道,说忘了。
最近做java 。 cloud啊, hadoop啊,
然后问Java
说equals是比较class, 我问她是不是和instaneof 弄混了 她说java没这个关键字。就
是equals()。
然后我还被告知Object 没有wait() method, 只有Thread有。
☆─────────────────────────────────────☆
danicahu (katelyn) 于 (Tue Apr 24 16:58:13 2012, 美东) 提到:
^_^
☆─────────────────────────────────────☆
colwell2008 (colwell2008) 于 (Tue Apr 24 17:12:57 2012, 美东) 提到:
难道那些... 阅读全帖
a**********0
发帖数: 422
20
来自主题: JobHunting版 - 求问permutation这个题
如果有duplicates 用下面这个算法
import java.util.*;
public class PermutationsII {

public ArrayList> permuteUnique(int[] num) {

Arrays.sort(num);
ArrayList> myResult = new ArrayList Integer>>();

ArrayList temp1 = new ArrayList();
for(int i = 0; i<= num.length-1; i++)
temp1.add(num[i]);

myResult.add(temp1);

while(nextPermutation(num)){
... 阅读全帖
a**********0
发帖数: 422
21
来自主题: JobHunting版 - 如何避免permutation中的重复计数
java代码
import java.util.*;
public class PermutationsII {

public ArrayList> permuteUnique(int[] num) {

Arrays.sort(num);
ArrayList> myResult = new ArrayList Integer>>();

ArrayList temp1 = new ArrayList();
for(int i = 0; i<= num.length-1; i++)
temp1.add(num[i]);

myResult.add(temp1);

while(nextPermutation(num)){
ArrayList<... 阅读全帖
h*****y
发帖数: 298
22
来自主题: JobHunting版 - 发一个Startup的面经 - Affirm
recursion比较robust但是短时间内不好写. 因为你没有可以用的语法树,所以要花力
气来tokenize. 只有用Stack才有希望在规定时间里写完,虽然这样的程序完全没有用。
public class EvalExpression {
private Stack results = new Stack();
private Stack operators = new Stack();
private Stack> vars = new Stack >>();
private static final String ADD = "add";
private static final String MULT = "mult";
private static final String LET = "let";
private static final String LPAREN... 阅读全帖
u*********e
发帖数: 9616
23
gejkl,
Thank you very much for helping me answering my question. I was doing
research myself and figuring out the issue. You are right. I rewrite the
query to get rid of cursor and use PATH XML instead.
One interesting thing I observed is that after I updated my sp and run the
report, it gave out an error msg:
"An error occurred during local report processing.Exception has been thrown
by the target of an invocation. String was not recognized as a valid
DateTime.Couldn't store <> in Stmt_Date_Cre... 阅读全帖
u*********e
发帖数: 9616
24
Thanks for the feedback.
I cleaned up the variables and use smalldatetime instead of nvarchar for the
comparison.
ALTER PROCEDURE [dbo].[SP_REPORT_GET_STATUS_DATES]
@Statement_Year SMALLINT,
@Statement_Month TINYINT

AS
BEGIN
declare @Results table (Group_Code nvarchar(10) not null,
Group_Member_Code nvarchar(10) not null,
Stmt_Date_Created nvarchar(10) null,
Stmt_Date_Updated nvarch... 阅读全帖
g****a
发帖数: 60
25
the program is very simple
=================
#!/bin/csh
cat *.h include/*.h > temp1
grep ^#define temp1 > temp2
=====================
but after showing :
Selected SIMSCRIPT II.5 (1.8) for OpenLook 3.0 on Sun Sparc
it just stay there for ever. after I stop the program using
Ctl-D, I saw temp1 is there.
why.
d*******1
发帖数: 293
26
来自主题: Statistics版 - 请教 SAS macro function 的问题
我用下面的code, 但是出错,好像是参数类型传递错误
%macro derv(lambda);
%global dl;
%let temp1 = %sysfunc(exp(-&lambda));
%let dl = %sysevalf(10/&lambda + 25*&temp1/(1-&temp1) - 27.21);
%mend derv;
Data;
Lam_1 = 0.1;
%derv(Lam_1);
出错 (我把它改成 %derv(0.1) 就没有问题, 但是dl的值有问题,不知道用的时候,可不可以这样用)
ERROR: A character operand was found in the %EVAL function or %IF condition
where a numeric operand is required.
我这儿需要把Lam_1转换成numeric type吗? 用什么函数可以转化?
另外, 对于Macro parameters, 好像只有输入参数,可以把参数设置成输出参数吗,要不
然,觉得很不方便,要不断使用global v
A*********u
发帖数: 8976
27
来自主题: Statistics版 - 请教 SAS macro function 的问题
如果只是计算,为啥一定要用macro呢

我用下面的code, 但是出错,好像是参数类型传递错误
%macro derv(lambda);
%global dl;
%let temp1 = %sysfunc(exp(-&lambda));
%let dl = %sysevalf(10/&lambda + 25*&temp1/(1-&temp1) - 27.21);
%mend derv;
Data;
Lam_1 = 0.1;
%derv(Lam_1);
出错 (我把它改成 %derv(0.1) 就没有问题, 但是dl的值有问题,不知道用的时候,可不
可以这样用)
ERROR: A character operand was found in the %EVAL function or %IF condition
where a numeric operand is required.
我这儿需要把Lam_1转换成numeric type吗? 用什么函数可以转化?
另外, 对于Macro parameters, 好像只有输入参数,可以把参数设置成输出参数吗,要不
r******e
发帖数: 115
28
来自主题: Statistics版 - 问个sas问题
我有一个数据 temp, 里面有三列
date time value
1 2 2.3
1 4 1.3
1 5 2.5
2 1 1.4
2 2 5.2
2 3 3.4
2 4 2.1
2 5 1.6
3 3 1
3 4 2.4
3 5 2.7
.. .. ..
现在想要生成数据 temp1 只有两列, 一列是不同的date, 另一列是所有date相同的val
ue的和, 比方说第一个date是1, 一共有三个value, 和是2.3+1.3+2.5=6.1, 那么temp1
的第一列是
date sum
1 6.1
.. ..
请问如何用sas实现temp1?
谢谢
c*****y
发帖数: 90
29
实际上分组是虚的,并没有重新排序呀。真正的操作是当indexOf1这一位是1的时候与
temp1进行XOR,而当indexOf1这一位是0,与temp2进行XOR。以你的例
子:temp1=N1^N3^N3=N1,temp2=N2^N4^N4=N2。这样结果就出来了。

},
N1
t*********n
发帖数: 89
30
来自主题: JobHunting版 - 问一个facebook的电面
void calculateBit(string &result, const string b,int k){
result.push_back('0');
int carry = 0;
int i;
for (i=1; i<=b.size(); i++) {

int m =b[b.size()-i]-'0';
int r=0;
if (i>result.size()) {
result = '0'+result;
}
r = result[result.size()-i]-'0';
int sum = m*k + carry + r;
result[result.size()-i] = sum%10+'0';
carry = sum/10;
}


while (carry!=0) {
if (i>result.size()) {
... 阅读全帖
t*********n
发帖数: 89
31
发个自己的吧,请指正...努力学习2爷中...
int maxProfit3(vector &prices) {
// Start typing your C/C++ solution below
// DO NOT write int main() function
if(!prices.size())
return 0;
vector a;
vector b;
vector::iterator it;
int min = prices[0];
int profit = 0;
for(it=prices.begin(); it if(*it min = *it;
int temp = *it - min;
if(temp > profit){
a.push_back(temp);
prof... 阅读全帖
t*********n
发帖数: 89
32
发个自己的吧,请指正...努力学习2爷中...
int maxProfit3(vector &prices) {
// Start typing your C/C++ solution below
// DO NOT write int main() function
if(!prices.size())
return 0;
vector a;
vector b;
vector::iterator it;
int min = prices[0];
int profit = 0;
for(it=prices.begin(); it if(*it min = *it;
int temp = *it - min;
if(temp > profit){
a.push_back(temp);
prof... 阅读全帖
p*******f
发帖数: 521
33

e.g.
select * from
(select id, name.... from t1, t2 where....) temp1,
(select id, name.... from t1, t2 where....) temp2
where temp1... temp2.....
or you can have temp table inside another temp table.
k***n
发帖数: 997
34
来自主题: Database版 - sql 题目求助
1, 有一个客户_good_.dbo.transactions, 其中包括
acct: unique customer identifier, purchdate: date when purchase occurred,
purchasemt: purchase amount
要求:select all acct with first purchase happened in 2012 and his total
purchase amount > 250$
2, 还是这个table, find the proportion of customers that made more than one
purchases in 2012 fiscal year. return a table where col1 is number of
customers that made more than one purchases in 2012 fiscal year, col2 total
number of customers ever purchased from us, col3 s... 阅读全帖
g*******s
发帖数: 490
35
来自主题: Hardware版 - 帮忙诊断一个笔记本过热的问题
HP的dv系列,8400m gs的独显,两个东西本身都是臭名昭著有过热问题的东西,这个不
去管他。
现在的症状是,gpu只要一开机温度就蹭蹭蹭往上跑,开机1分钟等进入系统打开测温软
件(speedfan)已经80度了,然后时间长了,显卡driver就没反应,然后自动蓝屏。
其他温度,hdd大概就30-40度正常, 然后core0, core1, temp1, temp2大概平时在40-
50度左右,但是比如执行计算,压缩一个大文件,2秒之内, core0, core1, temp1,
temp2都可以飚到80-90度也就是和gpu差不多的温度,压缩完之后倒是会降回来。
看到这里,大致上应该是gpu也就是8400m gs有问题了,不过我在windows系统里
disable 8400m gs(bios改不了),然后系统自动换到集成显卡,结果是蓝屏蓝的更快。
机器拆开看了,灰尘都清理了,没有明显哪个地方被烧了的痕迹,运行的时候,硬盘背
后的显卡那边却是烫的可以,手摸着就感觉出来了,不过摸风扇排风口那里感觉还可以
,以前有更热的时候机器也没怎么样。
以上一切的起因是我某天晚上更新了direc
F***Q
发帖数: 6599
36
below is the "sensors" output for a dual-xeon server of mine. mostly idle.
cheap CPU cooler, really cheap server box (took from an older server), room
is AC cooled though.
----------------------------
coretemp-isa-0000
Adapter: ISA adapter
Physical id 0: +42.0°C (high = +83.0°C, crit = +93.0°C)
Core 0: +33.0°C (high = +83.0°C, crit = +93.0°C)
Core 1: +31.0°C (high = +83.0°C, crit = +93.0°C)
Core 2: +30.0°C (high = +83.0°C, crit = +93.0°C)
Core 3: +30.0°C (hi... 阅读全帖
t****t
发帖数: 6806
37
来自主题: Programming版 - 一道c++的考古题
今天我有点无聊, 就说说这个temp object的事情
如果完全不优化, 实际上这个程序的结果应该是
1 5 4
可以用g++ -fno-elide-constructors 得到这个结果.
调用的顺序是
A::A(&a); // A a
A::A(&c, a); // foo(a) (1)
A::A(&temp1, c); // A(c) (2)
A::A(&ab, temp1); // A ab=... (3)
A::A(&temp2, ab); // return ab (4)
A::A(&d, temp2); // A d=.... (5)
dtor就省掉了.
这5个里面, (1)和(5)是不能省的, 这两个都不是temp object.
1 3 2的结果是把两个temp object省了.
1 2 1的结果是把(3)也省了, 这个叫做named return value optimization. VC8事实上
有这个功能,如果你用release编译,那结果就是1 2 1.
标准是这样写的
P********e
发帖数: 2610
38
来自主题: Programming版 - 一道c++的考古题
我FT,标准什么时候说,(3)可以省了?
你帖的,第一句,(2)可以省略,第二句话(4)可以省略
ab is a variable, without (3), it's un_initialized local variable, which
doesnot make sense to me.

今天我有点无聊, 就说说这个temp object的事情
如果完全不优化, 实际上这个程序的结果应该是
1 5 4
可以用g++ -fno-elide-constructors 得到这个结果.
调用的顺序是
A::A(&a); // A a
A::A(&c, a); // foo(a) (1)
A::A(&temp1, c); // A(c) (2)
A::A(&ab, temp1); // A ab=... (3)
A::A(&temp2, ab); // return ab (4)
A::A(&d, temp2); // A d=.... (5)
dtor就省掉了.
这5个里面, (1)和(5)是不能省的,
H***a
发帖数: 735
39
来自主题: Programming版 - 问一个关于C++指针的问题
Node** List的定义是用来存放指向Node类型的指针的指针。
这段代码有两个问题:
1.第二行,temp1和*List share同一个地址,这样做是很危险的,容易导致memory leak
;而第三行完全不明白在干什么,就像我跟你说明天是端午节,你明白了以后马上跟我
说“你知道么?明天是端午节。” ...#^$^#%$@#$%$#
2.Node是你定义的一个类吧,Node** List只给了List地址,并没有开辟空间,也就是说List本身没有instantiated,内容是不确定的;第二行temp1也就跟着不确定。
N******K
发帖数: 10202
40
p1 = new object1
p2 = new object2
p3 = new object3
p4 = new object4
function A(input (i.e., const): p1, p2 , output p3 p4)
{
temp1= shared_ptr(new ObjectTemp1)
temp2= shared_ptr(new ObjectTemp2)
do somthing using p1 p2 temp 1 temp2 to update p3 p4
} //delete temp1, delete temp2
输入 输出 都已经new好了
内部加工加工
内部new出来的 {}结束统统释放
N******K
发帖数: 10202
41
当有成员变量 m_ClassA_member 的时候
p1 = new object1;
p2 = new object2;
p3 = new object3;
p4 = new object4;
ClasseA::function A(input (i.e., const): p1, p2 , output p3 p4)
{
temp1= shared_ptr(new ObjectTemp1);
temp2= shared_ptr(new ObjectTemp2);
m_ClassA_member = new(xxx);
do somthing using p1 p2 temp 1 temp2 to update p3 p4
} //delete temp1, delete temp2
ClassA()
{
m_ClassA_member = nullptr;
}
~ClassA()
{
if (m_ClassA_member != nullptr)
delete m_ClassA_member ;
}
z****e
发帖数: 54598
42
来自主题: Programming版 - 这几天写了大概两万行代码
很多是dsl还有各种templates自动生成的
我真正写的部分并不多
我有意把各个步骤拆开,以便于debug
我写的dsl里面有这种语句
3+a*b^3
转换成java代码就是
Number $temp1 = b.pow(3);
Number $temp2 = a*$temp1;
Number $temp3 = 3+$temp2;
return $temp3;
还会将其包装成main方法,以及生成static main函数
以便于需要时候自己运行
一行就会变成很多行,但是debug起来就很简单
N******K
发帖数: 10202
43
网上搜了搜 没啥合适的库 要么太老了 要么就有大坑 这些库都不能互联互通
所以自己搞一个库 有什么问题自己清楚
本库的目标是
(1)实现新的图像分析算法
(2)充分利用已有的算法:把本库作为一个接口 调用其他各个c++矩阵库和图像算法库
实现步骤:
一维数组是基础 对应的是内存的连续线性存储
数组的一个元素可是一个double也可以是一个double裸数组
然后二维 也就是矩阵 各个元素线性映射(存储)到一维数组
矩阵每一个元素是一个double, float 或 int
不仅仅是存储 而且是有线性计算 定义+ - * /
复杂的运算可以调用eigen或者其他c++库
然后三维 是图像 各个元素线性映射(存储)到一位数组
图像的一个元素(像素)可是一个double也可以是一个double裸数组 或者float int8 等
图像主要实现的是各种计算 比如滤波器
打算一直造到4维数组 图像序列
这个目前要用于存数据 还没想好相关计算
不定义 像素这个类:
(1)如果一个像素是是3double x 3double结构(比如tensor) 那么就存为连续9个
double
定义像... 阅读全帖
N******K
发帖数: 10202
44
来自主题: Programming版 - 问个c++ struct和指针问题
我举个例子
矩阵加法 每个都是1024x0124大小
A=B+C+D
具体这样 temp1=B+C; temp2=temp1+D; A=temp2;
这里面很多数据共享的问题
比如 简单的 A=B;
A是一个矩阵 A=B 是不是要把所有元素都复制一遍? 显然不用
A.data=B.data; 就行了
A.data 可以是 shared_part
如果要对A只做读操作 A不用重新分配一块内存
如果要对A做写操作 那就测试一下A.data有没有别人在用 还有人用的话 那就复制一块
A重新分配一块内存 复制A.data指向的数据
当然 你要搞多线程 多个线程写一个矩阵 会出问题 你要加锁
锁。lock()
测试一下A.data有没有别人在用 还有人用的话 A重新分配一块内存
锁。unlock()
不过 数值计算一般不会这么搞
如果B没用了 析构函数里面 {data.reset()} 就可以了 不会把数据真给删掉了
W*****7
发帖数: 830
45
Code:
\begin{figure}[htp]
\centering
\includegraphics[bb=1.0in 5.2in 7.5in 9.3in, width=0.9\textwidth]{figures/
temp.pdf}
\caption{\label{fig:temp1} XXXXXXXXXXXX.}
\end{figure}
Use Figure \ref{fig: temp1}, then I got "Figure ??"
What was wrong?THanks.
d*****n
发帖数: 65
46
来自主题: Statistics版 - overall mean in sas for several variables
proc summary data=one;
var x y z;
output out=temp1(drop=_type_ _freq_) mean= ;
proc transpose data=temp1 out=temp2 prefix=mean;
proc summary data=temp2;
var mean1;
output out=data(drop=_type_ _freq_) mean= ;
run;
s*******f
发帖数: 148
47
来自主题: Statistics版 - A quick question about masking in macro
Thanks for the reply! There's some strange problem when i use %qscan here:(
It does work great if i assign the string to a macro var with %let statement:
log:
3688 %let a=%str('a','b'*'c','d');
3689 %put temp1=%qscan(&a,1,*);
temp1='a','b'
3690 %put temp2=%qscan(&a,2,*);
temp2='c','d'
which is exactly what i want. However, for some reason, the scanned value
will include the single parenthesis in my macro program...
code:
%macro m1 / parmbuff;
...
%let cc=%qscan(&syspbuff,&i,*);
%p
h********o
发帖数: 103
48
来自主题: Statistics版 - SAS问题请教
That's Cartesian product of tables:
========================================
DATA TEMP1;
DO DATE_N = 1 TO 31;
OUTPUT;
END;
RUN;
DATA TEMP2;
DO T = 1000 TO 2000;
OUTPUT;
END;
RUN;
PROC SQL;
CREATE TABLE TEMP AS
SELECT * FROM TEMP1, TEMP2;
QUIT;
d******9
发帖数: 404
49
来自主题: Statistics版 - 问个sas问题
You can use SQL or Data step to do it.
Proc SQL;
Create table Temp1 as
select distinct date as Date, sum(value) as Sum
from Temp
group by date;
quit;
Or using data step:
Proc sort data=temp;
By date;
run;
Data Temp1(keep=date sum);
set temp;
bydate;
if first.date then sum=0;
Sum + value;
if last.date then output;
run;
k*****u
发帖数: 1688
50
来自主题: Statistics版 - 一个SAS问题,合并行
抛砖引玉,用一个很繁琐的办法写出来了。呵呵。不过凭感觉,我觉得应该有很简单的
办法。
data a;
input ID Attr1 $ Attr2 $;
cards;
1 A1 B1
1 A2 B2
1 A3 B3
2 A4 B4
3 A5 B5
3 A6 B6
3 A7 B7
3 A8 B8
4 A9 B9
4 A10 B10
;
run;
proc sort data=a;
by id;
run;
data a;
set a;
by id;
retain id2;
if first.id then id2=0;
id2=id2+1;
output;
run;
proc print data=a;
run;
proc sql;
create table temp1 as
select count(1) as cnt
from a
group by id;
select ... 阅读全帖
1 2 下页 末页 (共2页)