我有一个带NaNs的载体:
CREATE TABLE IF NOT EXISTS PERSONS(
ID INTEGER NOT NULL AUTO_INCREMENT,
LAST_NAME VARCHAR(25) NULL,
FIRST_NAME VARCHAR(25) NULL,
ADDRESS VARCHAR(25) NULL,
CITY VARCHAR(25) NULL,
ZIP_CODE BIGINT(5) NULL,
TEL VARCHAR(13) NULL,
PERSON_TYPES ENUM("ADMIN","EXPERT","THIRD_PARTY","CUSTOMER"),
MAJ TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (ID)
);
CREATE TABLE IF NOT EXISTS INSUREES(
ID INTEGER NOT NULL UNIQUE,
BONUS_MALUS REAL(5,2) DEFAULT 1.0,
FOREIGN KEY (ID) REFERENCES PERSONS(ID) ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS THIRD_PARTIES(
ID INTEGER NOT NULL UNIQUE,
COMPAGNY VARCHAR(128) NULL,
FOREIGN KEY (ID) REFERENCES INSUREES(ID) ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS EXPERTS(
ID INTEGER NOT NULL UNIQUE,
RANK BIGINT(4) NULL,
FOREIGN KEY (ID) REFERENCES PERSONS(ID) ON DELETE CASCADE
)comment = "";
CREATE TABLE IF NOT EXISTS CUSTOMERS(
ID INTEGER NOT NULL UNIQUE,
ID_CARD VARCHAR(100),
SEPA VARCHAR(100),
FOREIGN KEY(ID) REFERENCES INSUREES(ID) ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS ADMINS(
ID INTEGER NOT NULL UNIQUE,
ROLE VARCHAR(128) NULL,
FOREIGN KEY (ID) REFERENCES PERSONS(ID) ON DELETE CASCADE
);
另一个具有不同值的向量:
v1 = [NaN NaN NaN NaN NaN];
和线性索引:
v2 = [1 4 6 8 9];
我想根据线性索引将v2中的值分配给v1,因此结果为:
idx = [1 0 4 0 3];
答案 0 :(得分:8)
v1(idx ~= 0) = v2(idx(idx ~= 0))
这需要
" v1
中的值idx
不等于零"
并为其指定
中的值" v2
,在索引idx
,其中idx
也不等于零"